diff options
-rw-r--r-- | lib/AST/Expr.cpp | 4 | ||||
-rw-r--r-- | lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp | 7 | ||||
-rw-r--r-- | test/PCH/format-strings.c | 18 |
3 files changed, 24 insertions, 5 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index afc7410a81..ba2cc8eb34 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -708,8 +708,8 @@ getLocationOfByte(unsigned ByteNo, const SourceManager &SM, LangOpts.Trigraphs = true; // Create a lexer starting at the beginning of this token. - Lexer TheLexer(StrTokSpellingLoc, Features, Buffer.begin(), StrData, - Buffer.end()); + Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), Features, + Buffer.begin(), StrData, Buffer.end()); Token TheTok; TheLexer.LexFromRawLexer(TheTok); diff --git a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp index 629f1eab43..f1ce8786a1 100644 --- a/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp @@ -441,9 +441,10 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID, FullSourceLoc L = MP->getLocation().asLocation().getExpansionLoc(); assert(L.isFileID()); StringRef BufferInfo = L.getBufferData(); - const char* MacroName = L.getDecomposedLoc().second + BufferInfo.data(); - Lexer rawLexer(L, PP.getLangOpts(), BufferInfo.begin(), - MacroName, BufferInfo.end()); + std::pair<FileID, unsigned> LocInfo = L.getDecomposedLoc(); + const char* MacroName = LocInfo.second + BufferInfo.data(); + Lexer rawLexer(SM.getLocForStartOfFile(LocInfo.first), PP.getLangOpts(), + BufferInfo.begin(), MacroName, BufferInfo.end()); Token TheTok; rawLexer.LexFromRawLexer(TheTok); diff --git a/test/PCH/format-strings.c b/test/PCH/format-strings.c new file mode 100644 index 0000000000..7198c4d3a2 --- /dev/null +++ b/test/PCH/format-strings.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -D FOOBAR="\"\"" %s -emit-pch -o %t.pch +// RUN: %clang_cc1 -D FOOBAR="\"\"" %s -include-pch %t.pch + +// rdar://11418366 + +#ifndef HEADER +#define HEADER + +extern int printf(const char *restrict, ...); +#define LOG printf(FOOBAR "%f", __LINE__) + +#else + +void foo() { + LOG; +} + +#endif |