diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-09-20 18:13:03 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-09-20 18:13:03 +0000 |
| commit | 75644d572955f201eaaef9f89e855d9f7c4cf40a (patch) | |
| tree | ab9c3d788cace330ffc68e83837acbb7e5be7497 | |
| parent | e4e20f43e45bf9e428ebdd81c2ff7b3826cd6c4e (diff) | |
| download | bcm5719-llvm-75644d572955f201eaaef9f89e855d9f7c4cf40a.tar.gz bcm5719-llvm-75644d572955f201eaaef9f89e855d9f7c4cf40a.zip | |
Introduce an egregious hack for modules to cope with headers that come
from unfriendly (== not at all modularized) directories. This is
temporary, and it only affects module construction until I'll figured
out how to deal with system headers.
llvm-svn: 140159
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 4e4f80bd0bc..a169dd270e7 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -34,6 +34,7 @@ #include "clang/AST/ExprCXX.h" #include "clang/AST/StmtCXX.h" #include "clang/Lex/Preprocessor.h" +#include "clang/Basic/FileManager.h" #include "clang/Basic/PartialDiagnostic.h" #include "clang/Basic/TargetInfo.h" using namespace clang; @@ -458,6 +459,34 @@ void Sema::ActOnEndOfTranslationUnit() { } if (TUKind == TU_Module) { + // Mark any macros from system headers (in /usr/include) as exported, along + // with our own Clang headers. + // FIXME: This is a gross hack to deal with the fact that system headers + // are #include'd in many places within module headers, but are not + // themselves modularized. This doesn't actually work, but it lets us + // focus on other issues for the moment. + for (Preprocessor::macro_iterator M = PP.macro_begin(false), + MEnd = PP.macro_end(false); + M != MEnd; ++M) { + if (M->second && + !M->second->isExported() && + !M->second->isBuiltinMacro()) { + SourceLocation Loc = M->second->getDefinitionLoc(); + if (SourceMgr.isInSystemHeader(Loc)) { + const FileEntry *File + = SourceMgr.getFileEntryForID(SourceMgr.getFileID(Loc)); + if (File && + ((StringRef(File->getName()).find("lib/clang") + != StringRef::npos) || + (StringRef(File->getName()).find("usr/include") + != StringRef::npos) || + (StringRef(File->getName()).find("usr/local/include") + != StringRef::npos))) + M->second->setExportLocation(Loc); + } + } + } + // Modules don't need any of the checking below. TUScope = 0; return; |

