diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 13 | ||||
-rw-r--r-- | clang/lib/Frontend/PCHReader.cpp | 10 |
2 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index ad70727c05e..462e065e8c1 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -61,9 +61,7 @@ static void UndefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) { Buf.push_back('\n'); } -/// Add the quoted name of an implicit include file. -static void AddQuotedIncludePath(std::vector<char> &Buf, - const std::string &File) { +std::string clang::NormalizeDashIncludePath(llvm::StringRef File) { // Implicit include paths should be resolved relative to the current // working directory first, and then use the regular header search // mechanism. The proper way to handle this is to have the @@ -76,9 +74,16 @@ static void AddQuotedIncludePath(std::vector<char> &Buf, if (!Path.exists()) Path = File; + return Lexer::Stringify(Path.str()); +} + +/// Add the quoted name of an implicit include file. +static void AddQuotedIncludePath(std::vector<char> &Buf, + const std::string &File) { + // Escape double quotes etc. Buf.push_back('"'); - std::string EscapedFile = Lexer::Stringify(Path.str()); + std::string EscapedFile = NormalizeDashIncludePath(File); Buf.insert(Buf.end(), EscapedFile.begin(), EscapedFile.end()); Buf.push_back('"'); } diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp index 936382482c9..780890de2ab 100644 --- a/clang/lib/Frontend/PCHReader.cpp +++ b/clang/lib/Frontend/PCHReader.cpp @@ -13,6 +13,7 @@ #include "clang/Frontend/PCHReader.h" #include "clang/Frontend/FrontendDiagnostic.h" +#include "clang/Frontend/Utils.h" #include "../Sema/Sema.h" // FIXME: move Sema headers elsewhere #include "clang/AST/ASTConsumer.h" #include "clang/AST/ASTContext.h" @@ -158,12 +159,13 @@ bool PCHValidator::ReadPredefinesBuffer(llvm::StringRef PCHPredef, FileID PCHBufferID, llvm::StringRef OriginalFileName, std::string &SuggestedPredefines) { - // We are in the context of an implicit include, so the predefines buffer - // will have a #include entry for the PCH file itself. Find it and skip over - // it in the checking below. + // We are in the context of an implicit include, so the predefines buffer will + // have a #include entry for the PCH file itself (as normalized by the + // preprocessor initialization). Find it and skip over it in the checking + // below. llvm::SmallString<256> PCHInclude; PCHInclude += "#include \""; - PCHInclude += OriginalFileName; + PCHInclude += NormalizeDashIncludePath(OriginalFileName); PCHInclude += "\"\n"; std::pair<llvm::StringRef,llvm::StringRef> Split = llvm::StringRef(PP.getPredefines()).split(PCHInclude.str()); |