Index: llvm/lib/TableGen/Main.cpp =================================================================== --- llvm/lib/TableGen/Main.cpp +++ llvm/lib/TableGen/Main.cpp @@ -73,7 +73,7 @@ EC.message() + "\n"); DepOut.os() << OutputFilename << ":"; for (const auto &Dep : Parser.getDependencies()) { - DepOut.os() << ' ' << Dep.first; + DepOut.os() << ' ' << Dep.first(); } DepOut.os() << "\n"; DepOut.keep(); Index: llvm/lib/TableGen/TGLexer.h =================================================================== --- llvm/lib/TableGen/TGLexer.h +++ llvm/lib/TableGen/TGLexer.h @@ -19,7 +19,6 @@ #include "llvm/Support/DataTypes.h" #include "llvm/Support/SMLoc.h" #include -#include #include #include @@ -87,10 +86,11 @@ unsigned CurBuffer = 0; public: - typedef std::map DependenciesMapTy; + typedef StringSet<> DependenciesSetTy; + private: /// Dependencies - This is the list of all included files. - DependenciesMapTy Dependencies; + DependenciesSetTy Dependencies; public: TGLexer(SourceMgr &SrcMgr, ArrayRef Macros); @@ -99,7 +99,7 @@ return CurCode = LexToken(CurPtr == CurBuf.begin()); } - const DependenciesMapTy &getDependencies() const { + const DependenciesSetTy &getDependencies() const { return Dependencies; } Index: llvm/lib/TableGen/TGLexer.cpp =================================================================== --- llvm/lib/TableGen/TGLexer.cpp +++ llvm/lib/TableGen/TGLexer.cpp @@ -379,15 +379,7 @@ return true; } - 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())); + Dependencies.insert(IncludedFile); // Save the line number and lex buffer of the includer. CurBuf = SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(); CurPtr = CurBuf.begin(); Index: llvm/lib/TableGen/TGParser.h =================================================================== --- llvm/lib/TableGen/TGParser.h +++ llvm/lib/TableGen/TGParser.h @@ -129,7 +129,7 @@ bool TokError(const Twine &Msg) const { return Error(Lex.getLoc(), Msg); } - const TGLexer::DependenciesMapTy &getDependencies() const { + const TGLexer::DependenciesSetTy &getDependencies() const { return Lex.getDependencies(); } Index: llvm/test/TableGen/duplicate-include.inc =================================================================== --- /dev/null +++ llvm/test/TableGen/duplicate-include.inc @@ -0,0 +1,8 @@ + +#ifndef DUPLICATE_INCLUDE +#define DUPLICATE_INCLUDE + +// This is used by the duplicate-include.td test +def InInclude; + +#endif Index: llvm/test/TableGen/duplicate-include.td =================================================================== --- /dev/null +++ llvm/test/TableGen/duplicate-include.td @@ -0,0 +1,6 @@ +// RUN: llvm-tblgen -I %p %s | FileCheck %s + +// CHECK: def InInclude + +include "AllowDuplicateInclude.inc" +include "AllowDuplicateInclude.inc"