diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-17 15:32:29 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-17 15:32:29 +0000 |
commit | aa93a875605536d72a10359a0098396192b7d4ec (patch) | |
tree | e4f0f3e94714c6fe029f52e9e96f7e779ba26b30 /lib/Lex/PPLexerChange.cpp | |
parent | 05edf668f0984bfa2994ddc8bb7b78d9fb24cf11 (diff) | |
download | clang-aa93a875605536d72a10359a0098396192b7d4ec.tar.gz clang-aa93a875605536d72a10359a0098396192b7d4ec.tar.bz2 clang-aa93a875605536d72a10359a0098396192b7d4ec.tar.xz |
For modules, all macros that aren't include guards are implicitly
public. Add a __private_macro__ directive to hide a macro, similar to
the __module_private__ declaration specifier.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142188 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 25a98ae47b..da6c8aa589 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -16,6 +16,7 @@ #include "clang/Lex/HeaderSearch.h" #include "clang/Lex/MacroInfo.h" #include "clang/Lex/LexDiagnostic.h" +#include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "llvm/Support/MemoryBuffer.h" using namespace clang; @@ -211,8 +212,28 @@ bool Preprocessor::HandleEndOfFile(Token &Result, bool isEndOfMacro) { CurPPLexer->MIOpt.GetControllingMacroAtEndOfFile()) { // Okay, this has a controlling macro, remember in HeaderFileInfo. if (const FileEntry *FE = - SourceMgr.getFileEntryForID(CurPPLexer->getFileID())) + SourceMgr.getFileEntryForID(CurPPLexer->getFileID())) { HeaderInfo.SetFileControllingMacro(FE, ControllingMacro); + + // Controlling macros are implicitly private. + if (MacroInfo *MI = getMacroInfo( + const_cast<IdentifierInfo *>(ControllingMacro))) { + if (MI->getVisibilityLocation().isInvalid()) { + // FIXME: HACK! Mark controlling macros from system headers as + // exported, along with our own Clang headers. This is a gross + // hack to deal with the fact that system headers are included in + // many places within module headers, but are not themselves + // modularized. + if ((StringRef(FE->getName()).find("lib/clang") + == StringRef::npos) && + (StringRef(FE->getName()).find("usr/include") + == StringRef::npos) && + (StringRef(FE->getName()).find("usr/local/include") + == StringRef::npos)) + MI->setVisibility(false, SourceLocation()); + } + } + } } } |