summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/HeaderSearch.cpp
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-03-13 16:46:36 +0000
committerBen Langmuir <blangmuir@apple.com>2014-03-13 16:46:36 +0000
commitd285c503903909a64eeb3846e9586f55789b5bc4 (patch)
treebca879dc755aa8bb135f9543a038da869b16d020 /clang/lib/Lex/HeaderSearch.cpp
parent2b124d1a5d4c6df95783232a7d8955629453905a (diff)
downloadbcm5719-llvm-d285c503903909a64eeb3846e9586f55789b5bc4.tar.gz
bcm5719-llvm-d285c503903909a64eeb3846e9586f55789b5bc4.zip
Prevent outputting HeaderFileInfos for files not used as headers
When building an AST file, we don't want to output HeaderFileInfo structures for files that are not actually used as headers in the current context. This can lead to assuming that unrelated files have include counts of 0, defeating multiple-include prevention. This is accomplished by adding an IsValid bit to the HFI. llvm-svn: 203813
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 97bff4f2773..46d4d41b9af 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -988,9 +988,21 @@ HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) {
HeaderFileInfo &HFI = FileInfo[FE->getUID()];
if (ExternalSource && !HFI.Resolved)
mergeHeaderFileInfo(HFI, ExternalSource->GetHeaderFileInfo(FE));
+ HFI.IsValid = 1;
return HFI;
}
+bool HeaderSearch::tryGetFileInfo(const FileEntry *FE, HeaderFileInfo &Result) const {
+ if (FE->getUID() >= FileInfo.size())
+ return false;
+ const HeaderFileInfo &HFI = FileInfo[FE->getUID()];
+ if (HFI.IsValid) {
+ Result = HFI;
+ return true;
+ }
+ return false;
+}
+
bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) {
// Check if we've ever seen this file as a header.
if (File->getUID() >= FileInfo.size())
OpenPOWER on IntegriCloud