diff options
author | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2013-08-07 18:49:47 +0000 |
---|---|---|
committer | John Thompson <John.Thompson.JTSoftware@gmail.com> | 2013-08-07 18:49:47 +0000 |
commit | 4ed963a0bac4a09b9a8770166c96128b92893494 (patch) | |
tree | 866023e50ec9dd18df543dd68b4d41ee57ecdba3 /clang-tools-extra/modularize/PreprocessorTracker.cpp | |
parent | 885727581c10332bef9e97f247d3ed9e5e974d40 (diff) | |
download | bcm5719-llvm-4ed963a0bac4a09b9a8770166c96128b92893494.tar.gz bcm5719-llvm-4ed963a0bac4a09b9a8770166c96128b92893494.zip |
Fixed incorrect header guard/nested header mechanism.
llvm-svn: 187898
Diffstat (limited to 'clang-tools-extra/modularize/PreprocessorTracker.cpp')
-rw-r--r-- | clang-tools-extra/modularize/PreprocessorTracker.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp index 841cc58b0a5..a4bfd8b3b12 100644 --- a/clang-tools-extra/modularize/PreprocessorTracker.cpp +++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp @@ -223,6 +223,7 @@ #include "clang/Lex/PPCallbacks.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/StringPool.h" +#include "llvm/ADT/SmallSet.h" #include "PreprocessorTracker.h" namespace Modularize { @@ -806,6 +807,7 @@ public: // Handle entering a preprocessing session. void handlePreprocessorEntry(clang::Preprocessor &PP, llvm::StringRef rootHeaderFile) { + HeadersInThisCompile.clear(); assert((HeaderStack.size() == 0) && "Header stack should be empty."); pushHeaderHandle(addHeader(rootHeaderFile)); PP.addPPCallbacks(new PreprocessorCallbacks(*this, PP, rootHeaderFile)); @@ -819,12 +821,11 @@ public: if (HeaderPath.startswith("<")) return; HeaderHandle H = addHeader(HeaderPath); - if (H != getCurrentHeaderHandle()) { - // Check for nested header. - if (!InNestedHeader) - InNestedHeader = isHeaderHandleInStack(H); + if (H != getCurrentHeaderHandle()) pushHeaderHandle(H); - } + // Check for nested header. + if (!InNestedHeader) + InNestedHeader = !HeadersInThisCompile.insert(H); } // Handle exiting a header source file. void handleHeaderExit(llvm::StringRef HeaderPath) { @@ -1167,6 +1168,7 @@ private: std::vector<HeaderHandle> HeaderStack; std::vector<HeaderInclusionPath> InclusionPaths; InclusionPathHandle CurrentInclusionPathHandle; + llvm::SmallSet<HeaderHandle, 128> HeadersInThisCompile; MacroExpansionMap MacroExpansions; ConditionalExpansionMap ConditionalExpansions; bool InNestedHeader; |