diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/TableGen/Main.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/TableGen/TGLexer.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/TableGen/TGLexer.h | 13 | ||||
| -rw-r--r-- | llvm/lib/TableGen/TGParser.h | 2 |
4 files changed, 23 insertions, 10 deletions
diff --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp index d0ca756016f..e1cd6237832 100644 --- a/llvm/lib/TableGen/Main.cpp +++ b/llvm/lib/TableGen/Main.cpp @@ -64,11 +64,11 @@ static int createDependencyFile(const TGParser &Parser, const char *argv0) { return 1; } DepOut.os() << OutputFilename << ":"; - const std::vector<std::string> &Dependencies = Parser.getDependencies(); - for (std::vector<std::string>::const_iterator I = Dependencies.begin(), - E = Dependencies.end(); + const TGLexer::DependenciesMapTy &Dependencies = Parser.getDependencies(); + for (TGLexer::DependenciesMapTy::const_iterator I = Dependencies.begin(), + E = Dependencies.end(); I != E; ++I) { - DepOut.os() << " " << (*I); + DepOut.os() << " " << I->first; } DepOut.os() << "\n"; DepOut.keep(); diff --git a/llvm/lib/TableGen/TGLexer.cpp b/llvm/lib/TableGen/TGLexer.cpp index e75abcfa38b..c6be4f8a118 100644 --- a/llvm/lib/TableGen/TGLexer.cpp +++ b/llvm/lib/TableGen/TGLexer.cpp @@ -309,7 +309,15 @@ bool TGLexer::LexInclude() { return true; } - Dependencies.push_back(IncludedFile); + DependenciesMapTy::const_iterator Found = Dependencies.find(IncludedFile); + if (Found != Dependencies.end()) { + PrintError(getLoc(), + "File '" + IncludedFile + "' has already been included."); + SrcMgr.PrintMessage(Found->second, SourceMgr::DK_Note, + "previously included here"); + return true; + } + Dependencies.insert(std::make_pair(IncludedFile, getLoc())); // Save the line number and lex buffer of the includer. CurBuf = SrcMgr.getMemoryBuffer(CurBuffer); CurPtr = CurBuf->getBufferStart(); diff --git a/llvm/lib/TableGen/TGLexer.h b/llvm/lib/TableGen/TGLexer.h index a0818f9db74..d1bd70d2eca 100644 --- a/llvm/lib/TableGen/TGLexer.h +++ b/llvm/lib/TableGen/TGLexer.h @@ -15,9 +15,10 @@ #define TGLEXER_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/SMLoc.h" #include <cassert> +#include <map> #include <string> -#include <vector> namespace llvm { class MemoryBuffer; @@ -73,9 +74,13 @@ class TGLexer { /// CurBuffer - This is the current buffer index we're lexing from as managed /// by the SourceMgr object. int CurBuffer; + +public: + typedef std::map<std::string, SMLoc> DependenciesMapTy; +private: /// Dependencies - This is the list of all included files. - std::vector<std::string> Dependencies; - + DependenciesMapTy Dependencies; + public: TGLexer(SourceMgr &SrcMgr); ~TGLexer() {} @@ -84,7 +89,7 @@ public: return CurCode = LexToken(); } - const std::vector<std::string> &getDependencies() const { + const DependenciesMapTy &getDependencies() const { return Dependencies; } diff --git a/llvm/lib/TableGen/TGParser.h b/llvm/lib/TableGen/TGParser.h index e55805d5525..044e3a02ba4 100644 --- a/llvm/lib/TableGen/TGParser.h +++ b/llvm/lib/TableGen/TGParser.h @@ -96,7 +96,7 @@ public: bool TokError(const Twine &Msg) const { return Error(Lex.getLoc(), Msg); } - const std::vector<std::string> &getDependencies() const { + const TGLexer::DependenciesMapTy &getDependencies() const { return Lex.getDependencies(); } |

