[cfe-commits] r133801 - in /cfe/trunk: lib/Parse/ParseExpr.cpp test/FixIt/fixit.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Jun 24 10:28:29 PDT 2011
Author: akirtzidis
Date: Fri Jun 24 12:28:29 2011
New Revision: 133801
URL: http://llvm.org/viewvc/llvm-project?rev=133801&view=rev
Log:
Allow the fixit for missing ':' in the ?: ternary operator if it is pointing
at the start of a macro instantiation.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/FixIt/fixit.c
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=133801&r1=133800&r2=133801&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Fri Jun 24 12:28:29 2011
@@ -309,8 +309,9 @@
// suggest inserting the colon in between them, otherwise insert ": ".
SourceLocation FILoc = Tok.getLocation();
const char *FIText = ": ";
- if (FILoc.isFileID()) {
- const SourceManager &SM = PP.getSourceManager();
+ const SourceManager &SM = PP.getSourceManager();
+ if (FILoc.isFileID() || SM.isAtStartOfMacroInstantiation(FILoc)) {
+ FILoc = SM.getInstantiationLoc(FILoc);
bool IsInvalid = false;
const char *SourcePtr =
SM.getCharacterData(FILoc.getFileLocWithOffset(-1), &IsInvalid);
Modified: cfe/trunk/test/FixIt/fixit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/FixIt/fixit.c?rev=133801&r1=133800&r2=133801&view=diff
==============================================================================
--- cfe/trunk/test/FixIt/fixit.c (original)
+++ cfe/trunk/test/FixIt/fixit.c Fri Jun 24 12:28:29 2011
@@ -33,9 +33,14 @@
int i0 = { 17 };
+#define ONE 1
+#define TWO 2
+
int test_cond(int y, int fooBar) {
// CHECK: int x = y ? 1 : 4+fooBar;
int x = y ? 1 4+foobar;
+// CHECK: x = y ? ONE : TWO;
+ x = y ? ONE TWO;
return x;
}
More information about the cfe-commits
mailing list