diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-08 00:09:53 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-04-08 00:09:53 +0000 |
| commit | 466a15ef7fa51bf7a4c4f870e88443f9bc895e4d (patch) | |
| tree | 234b6b3b466ba706d647fb0f087054ed1b97b2fc /clang/lib/Frontend | |
| parent | e0a7ffa6cb4ccb95a22918ea395e7591fe26daf2 (diff) | |
| download | bcm5719-llvm-466a15ef7fa51bf7a4c4f870e88443f9bc895e4d.tar.gz bcm5719-llvm-466a15ef7fa51bf7a4c4f870e88443f9bc895e4d.zip | |
[modules] Don't write @import in -E output if the current language mode doesn't
support @import; use the form as written instead.
llvm-svn: 265756
Diffstat (limited to 'clang/lib/Frontend')
| -rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 14 | ||||
| -rw-r--r-- | clang/lib/Frontend/Rewrite/InclusionRewriter.cpp | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 5dd7980d81b..9524b58e3a2 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -326,8 +326,18 @@ void PrintPPOutputPPCallbacks::InclusionDirective(SourceLocation HashLoc, if (Imported) { startNewLineIfNeeded(); MoveToLine(HashLoc); - OS << "@import " << Imported->getFullModuleName() << ";" - << " /* clang -E: implicit import for \"" << File->getName() << "\" */"; + if (PP.getLangOpts().ObjC2) { + OS << "@import " << Imported->getFullModuleName() << ";" + << " /* clang -E: implicit import for \"" << File->getName() + << "\" */"; + } else { + // FIXME: Preseve whether this was a + // #include/#include_next/#include_macros/#import. + OS << "#include " + << (IsAngled ? '<' : '"') + << FileName + << (IsAngled ? '>' : '"'); + } // Since we want a newline after the @import, but not a #<line>, start a new // line immediately. EmittedTokensOnThisLine = true; diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp index ca8226251fd..b761c34fcbd 100644 --- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -450,7 +450,9 @@ bool InclusionRewriter::Process(FileID FileId, WriteLineInfo(FileName, Line - 1, FileType, ""); StringRef LineInfoExtra; SourceLocation Loc = HashToken.getLocation(); - if (const Module *Mod = FindModuleAtLocation(Loc)) + if (const Module *Mod = PP.getLangOpts().ObjC2 + ? FindModuleAtLocation(Loc) + : nullptr) WriteImplicitModuleImport(Mod); else if (const IncludedFile *Inc = FindIncludeAtLocation(Loc)) { // include and recursively process the file |

