diff --git a/src/V3FileLine.h b/src/V3FileLine.h
index a8b82ca5d..1da9689cb 100644
--- a/src/V3FileLine.h
+++ b/src/V3FileLine.h
@@ -124,6 +124,8 @@ public:
V3LangCode language() const { return singleton().numberToLang(m_filenameno); }
string ascii() const;
const string filename() const { return singleton().numberToName(m_filenameno); }
+ bool filenameIsGlobal() const { return (filename() == commandLineFilename()
+ || filename() == internalDefineFilename()); }
const string filenameLetters() const { return singleton().filenameLetters(m_filenameno); }
const string filebasename() const;
const string filebasenameNoExt() const;
@@ -147,6 +149,8 @@ public:
void tracingOn(bool flag) { warnOn(V3ErrorCode::I_TRACING, flag); }
// METHODS - Global
+ static string commandLineFilename() { return "COMMAND_LINE"; }
+ static string internalDefineFilename() { return "INTERNAL_VERILATOR_DEFINE"; }
static void globalWarnLintOff(bool flag) {
defaultFileLine().warnLintOff(flag); }
static void globalWarnStyleOff(bool flag) {
diff --git a/src/V3PreShell.cpp b/src/V3PreShell.cpp
index c2b42f71e..379bad192 100644
--- a/src/V3PreShell.cpp
+++ b/src/V3PreShell.cpp
@@ -60,11 +60,11 @@ protected:
// Create the implementation pointer
if (env) {}
if (!s_preprocp) {
- FileLine* cmdfl = new FileLine("COMMAND_LINE", 0);
+ FileLine* cmdfl = new FileLine(FileLine::commandLineFilename(), 0);
s_preprocp = V3PreProc::createPreProc(cmdfl);
s_preprocp->debug(debug());
// Default defines
- FileLine* prefl = new FileLine("INTERNAL_VERILATOR_DEFINE", 0);
+ FileLine* prefl = new FileLine(FileLine::internalDefineFilename(), 0);
s_preprocp->defineCmdLine(prefl, "VERILATOR", "1"); // LEAK_OK
s_preprocp->defineCmdLine(prefl, "verilator", "1"); // LEAK_OK
s_preprocp->defineCmdLine(prefl, "verilator3", "1"); // LEAK_OK
@@ -178,7 +178,7 @@ void V3PreShell::preprocInclude(FileLine* fl, const string& modname) {
V3PreShellImp::s_preImp.preprocInclude(fl, modname);
}
void V3PreShell::defineCmdLine(const string& name, const string& value) {
- FileLine* prefl = new FileLine("COMMAND_LINE_DEFINE", 0);
+ FileLine* prefl = new FileLine(FileLine::commandLineFilename(), 0);
V3PreShellImp::s_preprocp->defineCmdLine(prefl, name, value);
}
void V3PreShell::undef(const string& name) {
diff --git a/src/Verilator.cpp b/src/Verilator.cpp
index 243cb74d9..b34ab5b5e 100644
--- a/src/Verilator.cpp
+++ b/src/Verilator.cpp
@@ -127,7 +127,8 @@ void V3Global::readFiles() {
const V3StringList& vFiles = v3Global.opt.vFiles();
for (V3StringList::const_iterator it = vFiles.begin(); it != vFiles.end(); ++it) {
string filename = *it;
- parser.parseFile(new FileLine("COMMAND_LINE", 0), filename, false,
+ parser.parseFile(new FileLine(FileLine::commandLineFilename(), 0),
+ filename, false,
"Cannot find file containing module: ");
}
@@ -137,7 +138,8 @@ void V3Global::readFiles() {
const V3StringSet& libraryFiles = v3Global.opt.libraryFiles();
for (V3StringSet::const_iterator it = libraryFiles.begin(); it != libraryFiles.end(); ++it) {
string filename = *it;
- parser.parseFile(new FileLine("COMMAND_LINE", 0), filename, true,
+ parser.parseFile(new FileLine(FileLine::commandLineFilename(), 0),
+ filename, true,
"Cannot find file containing library module: ");
}
//v3Global.rootp()->dumpTreeFile(v3Global.debugFilename("parse.tree"));
@@ -582,7 +584,8 @@ int main(int argc, char** argv, char** env) {
// Command option parsing
v3Global.opt.bin(argv[0]);
string argString = V3Options::argString(argc-1, argv+1);
- v3Global.opt.parseOpts(new FileLine("COMMAND_LINE", 0), argc-1, argv+1);
+ v3Global.opt.parseOpts(new FileLine(FileLine::commandLineFilename(), 0),
+ argc-1, argv+1);
if (!v3Global.opt.outFormatOk()
&& !v3Global.opt.preprocOnly()
&& !v3Global.opt.lintOnly()
diff --git a/test_regress/t/t_xml_first.out b/test_regress/t/t_xml_first.out
index e6743605d..22f21a67a 100644
--- a/test_regress/t/t_xml_first.out
+++ b/test_regress/t/t_xml_first.out
@@ -4,77 +4,76 @@
-
-
+
-
+
-
- |
- |
+
+ |
+ |
|
|
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
+
-
-
+
+
-
-
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
+
+
diff --git a/test_regress/t/t_xml_tag.out b/test_regress/t/t_xml_tag.out
index 22911aa85..136a38426 100644
--- a/test_regress/t/t_xml_tag.out
+++ b/test_regress/t/t_xml_tag.out
@@ -4,81 +4,80 @@
-
-
+
-
+
-
- |
+
+ |
|
|
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
+
+