[cfe-commits] r156647 - in /cfe/trunk: lib/AST/Expr.cpp lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp test/PCH/format-strings.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri May 11 14:39:18 PDT 2012
Author: akirtzidis
Date: Fri May 11 16:39:18 2012
New Revision: 156647
URL: http://llvm.org/viewvc/llvm-project?rev=156647&view=rev
Log:
The Lexer constructor expects a source location at the start of the
file buffer, not at the start of lexing.
Fixes assertion hit in format diagnostics. rdar://11418366
Added:
cfe/trunk/test/PCH/format-strings.c
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=156647&r1=156646&r2=156647&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Fri May 11 16:39:18 2012
@@ -708,8 +708,8 @@
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);
Modified: cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp?rev=156647&r1=156646&r2=156647&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp Fri May 11 16:39:18 2012
@@ -441,9 +441,10 @@
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);
Added: cfe/trunk/test/PCH/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/format-strings.c?rev=156647&view=auto
==============================================================================
--- cfe/trunk/test/PCH/format-strings.c (added)
+++ cfe/trunk/test/PCH/format-strings.c Fri May 11 16:39:18 2012
@@ -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
More information about the cfe-commits
mailing list