aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-06-21 05:06:04 +0000
committerChris Lattner <sabre@nondot.org>2009-06-21 05:06:04 +0000
commit7ee5d5f97b3fa709038ff7fd640dc775efaadc26 (patch)
tree94ad4c8268c7b77b3b828c9cc0f0c868930c20aa /utils
parent8070ea3f068980d08cc10381f4c9369d19a91353 (diff)
downloadexternal_llvm-7ee5d5f97b3fa709038ff7fd640dc775efaadc26.zip
external_llvm-7ee5d5f97b3fa709038ff7fd640dc775efaadc26.tar.gz
external_llvm-7ee5d5f97b3fa709038ff7fd640dc775efaadc26.tar.bz2
move include searching logic from TGLexer to SourceMgr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73845 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/TGLexer.cpp17
-rw-r--r--utils/TableGen/TGLexer.h7
-rw-r--r--utils/TableGen/TGParser.h2
-rw-r--r--utils/TableGen/TableGen.cpp6
4 files changed, 7 insertions, 25 deletions
diff --git a/utils/TableGen/TGLexer.cpp b/utils/TableGen/TGLexer.cpp
index 578930c..a1ccdbe 100644
--- a/utils/TableGen/TGLexer.cpp
+++ b/utils/TableGen/TGLexer.cpp
@@ -278,24 +278,15 @@ bool TGLexer::LexInclude() {
// Get the string.
std::string Filename = CurStrVal;
- // Try to find the file.
- MemoryBuffer *NewBuf = MemoryBuffer::getFile(Filename.c_str());
-
- // If the file didn't exist directly, see if it's in an include path.
- for (unsigned i = 0, e = IncludeDirectories.size(); i != e && !NewBuf; ++i) {
- std::string IncFile = IncludeDirectories[i] + "/" + Filename;
- NewBuf = MemoryBuffer::getFile(IncFile.c_str());
- }
-
- if (NewBuf == 0) {
+
+ CurBuffer = SrcMgr.AddIncludeFile(Filename, SMLoc::getFromPointer(CurPtr));
+ if (CurBuffer == ~0U) {
PrintError(getLoc(), "Could not find include file '" + Filename + "'");
return true;
}
// Save the line number and lex buffer of the includer.
- CurBuffer = SrcMgr.AddNewSourceBuffer(NewBuf, SMLoc::getFromPointer(CurPtr));
-
- CurBuf = NewBuf;
+ CurBuf = SrcMgr.getMemoryBuffer(CurBuffer);
CurPtr = CurBuf->getBufferStart();
return false;
}
diff --git a/utils/TableGen/TGLexer.h b/utils/TableGen/TGLexer.h
index 38a1d2f..2d1958e 100644
--- a/utils/TableGen/TGLexer.h
+++ b/utils/TableGen/TGLexer.h
@@ -73,17 +73,10 @@ class TGLexer {
/// by the SourceMgr object.
int CurBuffer;
- // IncludeDirectories - This is the list of directories we should search for
- // include files in.
- std::vector<std::string> IncludeDirectories;
public:
TGLexer(SourceMgr &SrcMgr);
~TGLexer() {}
- void setIncludeDirs(const std::vector<std::string> &Dirs) {
- IncludeDirectories = Dirs;
- }
-
tgtok::TokKind Lex() {
return CurCode = LexToken();
}
diff --git a/utils/TableGen/TGParser.h b/utils/TableGen/TGParser.h
index d06e958..9f4b634 100644
--- a/utils/TableGen/TGParser.h
+++ b/utils/TableGen/TGParser.h
@@ -49,8 +49,6 @@ class TGParser {
public:
TGParser(SourceMgr &SrcMgr) : Lex(SrcMgr), CurMultiClass(0) {}
- void setIncludeDirs(const std::vector<std::string> &D){Lex.setIncludeDirs(D);}
-
/// ParseFile - Main entrypoint for parsing a tblgen file. These parser
/// routines return true on error, or false on success.
bool ParseFile();
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp
index 0d5d86f..cb83cf3 100644
--- a/utils/TableGen/TableGen.cpp
+++ b/utils/TableGen/TableGen.cpp
@@ -146,12 +146,12 @@ static bool ParseFile(const std::string &Filename,
// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(F, SMLoc());
-
- TGParser Parser(SrcMgr);
// Record the location of the include directory so that the lexer can find
// it later.
- Parser.setIncludeDirs(IncludeDirs);
+ SrcMgr.setIncludeDirs(IncludeDirs);
+
+ TGParser Parser(SrcMgr);
return Parser.ParseFile();
}