[llvm-commits] CVS: llvm/utils/TableGen/FileLexer.l TableGen.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Mar 2 17:47:25 PST 2006
Changes in directory llvm/utils/TableGen:
FileLexer.l updated: 1.26 -> 1.27
TableGen.cpp updated: 1.42 -> 1.43
---
Log message:
add support for multiple include directories
---
Diffs of the changes: (+16 -12)
FileLexer.l | 18 +++++++++++-------
TableGen.cpp | 10 +++++-----
2 files changed, 16 insertions(+), 12 deletions(-)
Index: llvm/utils/TableGen/FileLexer.l
diff -u llvm/utils/TableGen/FileLexer.l:1.26 llvm/utils/TableGen/FileLexer.l:1.27
--- llvm/utils/TableGen/FileLexer.l:1.26 Mon Feb 13 23:13:13 2006
+++ llvm/utils/TableGen/FileLexer.l Thu Mar 2 19:47:14 2006
@@ -36,7 +36,7 @@
namespace llvm {
// Global variable recording the location of the include directory
-std::string IncludeDirectory;
+std::vector<std::string> IncludeDirectories;
/// ParseInt - This has to handle the special case of binary numbers 0b0101
///
@@ -74,7 +74,8 @@
/// ParseFile - this function begins the parsing of the specified tablegen file.
///
-void ParseFile(const std::string &Filename, const std::string & IncludeDir) {
+void ParseFile(const std::string &Filename,
+ const std::vector<std::string> &IncludeDirs) {
FILE *F = stdin;
if (Filename != "-") {
F = fopen(Filename.c_str(), "r");
@@ -90,7 +91,7 @@
// Record the location of the include directory so that the lexer can find
// it later.
- IncludeDirectory = IncludeDir;
+ IncludeDirectories = IncludeDirs;
Filein = F;
Filelineno = 1;
@@ -124,10 +125,13 @@
// If we couldn't find the file in the current directory, look for it in
// the include directories.
//
- // NOTE: Right now, there is only one directory. We need to eventually add
- // support for more.
- std::string NextFilename = IncludeDirectory + "/" + Filename;
- yyin = fopen(NextFilename.c_str(), "r");
+ std::string NextFilename;
+ for (unsigned i = 0, e = IncludeDirectories.size(); i != e; ++i) {
+ NextFilename = IncludeDirectories[i] + "/" + Filename;
+ if (yyin = fopen(NextFilename.c_str(), "r"))
+ break;
+ }
+
if (yyin == 0) {
err() << "Could not find include file '" << Filename << "'!\n";
exit(1);
Index: llvm/utils/TableGen/TableGen.cpp
diff -u llvm/utils/TableGen/TableGen.cpp:1.42 llvm/utils/TableGen/TableGen.cpp:1.43
--- llvm/utils/TableGen/TableGen.cpp:1.42 Sun Dec 25 23:08:55 2005
+++ llvm/utils/TableGen/TableGen.cpp Thu Mar 2 19:47:14 2006
@@ -82,14 +82,14 @@
cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input file>"), cl::init("-"));
- cl::opt<std::string>
- IncludeDir("I", cl::desc("Directory of include files"),
- cl::value_desc("directory"), cl::init(""));
+ cl::list<std::string>
+ IncludeDirs("I", cl::desc("Directory of include files"),
+ cl::value_desc("directory"));
}
namespace llvm {
void ParseFile(const std::string &Filename,
- const std::string &IncludeDir);
+ const std::vector<std::string> &IncludeDirs);
}
RecordKeeper llvm::Records;
@@ -420,7 +420,7 @@
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv);
- ParseFile(InputFilename, IncludeDir);
+ ParseFile(InputFilename, IncludeDirs);
std::ostream *Out = &std::cout;
if (OutputFilename != "-") {
More information about the llvm-commits
mailing list