diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-03-13 16:46:36 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-03-13 16:46:36 +0000 |
commit | d285c503903909a64eeb3846e9586f55789b5bc4 (patch) | |
tree | bca879dc755aa8bb135f9543a038da869b16d020 /clang/lib/Lex/HeaderSearch.cpp | |
parent | 2b124d1a5d4c6df95783232a7d8955629453905a (diff) | |
download | bcm5719-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.cpp | 12 |
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()) |