diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-04 00:14:37 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-04 00:14:37 +0000 |
commit | 37aa4938c8b59db704d4b9c9fed7d6e5e6583bbe (patch) | |
tree | 049bbfe1caf644c67612a71316c981c09a96d85b /clang/lib/Lex/HeaderSearch.cpp | |
parent | 24f3490467371e2ec713becf49ac9fc586a6a718 (diff) | |
download | bcm5719-llvm-37aa4938c8b59db704d4b9c9fed7d6e5e6583bbe.tar.gz bcm5719-llvm-37aa4938c8b59db704d4b9c9fed7d6e5e6583bbe.zip |
Introduce a new libclang API, clang_isFileMultipleIncludeGuarded(),
which determines whether a particular file is actually a header that
is intended to be guarded from multiple inclusions within the same
translation unit.
llvm-svn: 130808
Diffstat (limited to 'clang/lib/Lex/HeaderSearch.cpp')
-rw-r--r-- | clang/lib/Lex/HeaderSearch.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp index 372078c60d2..b3301164bd2 100644 --- a/clang/lib/Lex/HeaderSearch.cpp +++ b/clang/lib/Lex/HeaderSearch.cpp @@ -482,6 +482,21 @@ HeaderFileInfo &HeaderSearch::getFileInfo(const FileEntry *FE) { return HFI; } +bool HeaderSearch::isFileMultipleIncludeGuarded(const FileEntry *File) { + // Check if we've ever seen this file as a header. + if (File->getUID() >= FileInfo.size()) + return false; + + // Resolve header file info from the external source, if needed. + HeaderFileInfo &HFI = FileInfo[File->getUID()]; + if (ExternalSource && !HFI.Resolved) { + HFI = ExternalSource->GetHeaderFileInfo(File); + HFI.Resolved = true; + } + + return HFI.isPragmaOnce || HFI.ControllingMacro || HFI.ControllingMacroID; +} + void HeaderSearch::setHeaderFileInfoForUID(HeaderFileInfo HFI, unsigned UID) { if (UID >= FileInfo.size()) FileInfo.resize(UID+1); |