summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PrintPreprocessedOutput.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-10 01:53:46 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-10 01:53:46 +0000
commita6444b1ce1449f424626c492eb11cc9094d12b3a (patch)
tree10395a528e666e2a69db3ea0e70f186770f54fbb /clang/lib/Frontend/PrintPreprocessedOutput.cpp
parent953ef33f593707872b1d710ea4e24dca73f60b0b (diff)
downloadbcm5719-llvm-a6444b1ce1449f424626c492eb11cc9094d12b3a.tar.gz
bcm5719-llvm-a6444b1ce1449f424626c492eb11cc9094d12b3a.zip
[frontend] When preprocessing, turn implicit module imports into @imports.
part of rdar://13610250 llvm-svn: 179144
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r--clang/lib/Frontend/PrintPreprocessedOutput.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index f70bd7c93e5..432428bb969 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -127,6 +127,15 @@ public:
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
SrcMgr::CharacteristicKind FileType,
FileID PrevFID);
+ virtual void InclusionDirective(SourceLocation HashLoc,
+ const Token &IncludeTok,
+ StringRef FileName,
+ bool IsAngled,
+ CharSourceRange FilenameRange,
+ const FileEntry *File,
+ StringRef SearchPath,
+ StringRef RelativePath,
+ const Module *Imported);
virtual void Ident(SourceLocation Loc, const std::string &str);
virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
const std::string &Str);
@@ -305,6 +314,26 @@ void PrintPPOutputPPCallbacks::FileChanged(SourceLocation Loc,
}
}
+void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc,
+ const Token &IncludeTok,
+ StringRef FileName,
+ bool IsAngled,
+ CharSourceRange FilenameRange,
+ const FileEntry *File,
+ StringRef SearchPath,
+ StringRef RelativePath,
+ const Module *Imported) {
+ // When preprocessing, turn implicit imports into @imports.
+ // FIXME: This is a stop-gap until a more comprehensive "preprocessing with
+ // modules" solution is introduced.
+ if (Imported) {
+ startNewLineIfNeeded();
+ MoveToLine(HashLoc);
+ OS << "@import " << Imported->getFullModuleName() << ";"
+ << " /* clang -E: implicit import for \"" << File->getName() << "\" */";
+ }
+}
+
/// Ident - Handle #ident directives when read by the preprocessor.
///
void PrintPPOutputPPCallbacks::Ident(SourceLocation Loc, const std::string &S) {
OpenPOWER on IntegriCloud