summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/modularize/PreprocessorTracker.cpp
diff options
context:
space:
mode:
authorArnold Schwaighofer <aschwaighofer@apple.com>2013-08-05 22:03:41 +0000
committerArnold Schwaighofer <aschwaighofer@apple.com>2013-08-05 22:03:41 +0000
commit30448e607e89b92a22df6e1760a874f6067c820f (patch)
tree1920baa94525dc0552a4f278e21cd433930fe691 /clang-tools-extra/modularize/PreprocessorTracker.cpp
parentd728355a1c32c846e0125b84d7a25bca8b89698c (diff)
downloadbcm5719-llvm-30448e607e89b92a22df6e1760a874f6067c820f.tar.gz
bcm5719-llvm-30448e607e89b92a22df6e1760a874f6067c820f.zip
Reverting r187736. It broke some public bots:
http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/10248 http://bb.pgr.jp/builders/cmake-clang-i686-mingw32/builds/3327 llvm-svn: 187746
Diffstat (limited to 'clang-tools-extra/modularize/PreprocessorTracker.cpp')
-rw-r--r--clang-tools-extra/modularize/PreprocessorTracker.cpp36
1 files changed, 11 insertions, 25 deletions
diff --git a/clang-tools-extra/modularize/PreprocessorTracker.cpp b/clang-tools-extra/modularize/PreprocessorTracker.cpp
index d787e6c1c88..9077a6059a0 100644
--- a/clang-tools-extra/modularize/PreprocessorTracker.cpp
+++ b/clang-tools-extra/modularize/PreprocessorTracker.cpp
@@ -818,12 +818,8 @@ 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);
- }
}
// Handle exiting a header source file.
void handleHeaderExit(llvm::StringRef HeaderPath) {
@@ -835,7 +831,6 @@ public:
while ((H != getCurrentHeaderHandle()) && (HeaderStack.size() != 0))
popHeaderHandle();
}
- InNestedHeader = false;
}
// Lookup/add string.
@@ -844,13 +839,11 @@ public:
// Get the handle of a header file entry.
// Return HeaderHandleInvalid if not found.
HeaderHandle findHeaderHandle(llvm::StringRef HeaderPath) const {
- std::string CanonicalPath(HeaderPath);
- std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
HeaderHandle H = 0;
for (std::vector<StringHandle>::const_iterator I = HeaderPaths.begin(),
E = HeaderPaths.end();
I != E; ++I, ++H) {
- if (**I == CanonicalPath)
+ if (**I == HeaderPath)
return H;
}
return HeaderHandleInvalid;
@@ -859,12 +852,12 @@ public:
// Add a new header file entry, or return existing handle.
// Return the header handle.
HeaderHandle addHeader(llvm::StringRef HeaderPath) {
- std::string CanonicalPath(HeaderPath);
- std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
- HeaderHandle H = findHeaderHandle(CanonicalPath);
+ std::string canonicalPath(HeaderPath);
+ std::replace(canonicalPath.begin(), canonicalPath.end(), '\\', '/');
+ HeaderHandle H = findHeaderHandle(canonicalPath);
if (H == HeaderHandleInvalid) {
H = HeaderPaths.size();
- HeaderPaths.push_back(addString(CanonicalPath));
+ HeaderPaths.push_back(addString(canonicalPath));
}
return H;
}
@@ -1000,9 +993,6 @@ public:
bool ConditionValue,
llvm::StringRef ConditionUnexpanded,
InclusionPathHandle InclusionPathHandle) {
- // Ignore header guards, assuming the header guard is the only conditional.
- if (InNestedHeader)
- return;
StringHandle ConditionUnexpandedHandle(addString(ConditionUnexpanded));
PPItemKey InstanceKey(PP, ConditionUnexpandedHandle, H, InstanceLoc);
ConditionalExpansionMapIter I = ConditionalExpansions.find(InstanceKey);
@@ -1012,8 +1002,7 @@ public:
getSourceLocationString(PP, InstanceLoc) + ":\n" +
getSourceLine(PP, InstanceLoc) + "\n";
ConditionalExpansions[InstanceKey] =
- ConditionalTracker(DirectiveKind, ConditionValue,
- ConditionUnexpandedHandle,
+ ConditionalTracker(DirectiveKind, ConditionValue, ConditionUnexpandedHandle,
InclusionPathHandle);
} else {
// We've seen the conditional before. Get its tracker.
@@ -1168,7 +1157,6 @@ private:
InclusionPathHandle CurrentInclusionPathHandle;
MacroExpansionMap MacroExpansions;
ConditionalExpansionMap ConditionalExpansions;
- bool InNestedHeader;
};
// PreprocessorTracker functions.
@@ -1192,12 +1180,10 @@ void PreprocessorCallbacks::FileChanged(
PPTracker.handleHeaderEntry(PP, getSourceLocationFile(PP, Loc));
break;
case ExitFile:
- {
- const clang::FileEntry *F =
- PP.getSourceManager().getFileEntryForID(PrevFID);
- if (F != NULL)
- PPTracker.handleHeaderExit(F->getName());
- }
+ if (PrevFID.isInvalid())
+ PPTracker.handleHeaderExit(RootHeaderFile);
+ else
+ PPTracker.handleHeaderExit(getSourceLocationFile(PP, Loc));
break;
case SystemHeaderPragma:
case RenameFile:
OpenPOWER on IntegriCloud