diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-06-24 17:28:29 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-06-24 17:28:29 +0000 |
commit | b5303aa20e4eb26d53edde710f4a042650bea24d (patch) | |
tree | 2283fb94981626e52917ee8493b24631be74732f | |
parent | ed37ab82c7790569bcd39f4ba421b17433ef530a (diff) |
Allow the fixit for missing ':' in the ?: ternary operator if it is pointing
at the start of a macro instantiation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133801 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Parse/ParseExpr.cpp | 5 | ||||
-rw-r--r-- | test/FixIt/fixit.c | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp index 154d8fd809..218e18f3ad 100644 --- a/lib/Parse/ParseExpr.cpp +++ b/lib/Parse/ParseExpr.cpp @@ -309,8 +309,9 @@ Parser::ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec) { // 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); diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 1a6ef63557..ba45cf28e6 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -33,9 +33,14 @@ void f1(x, y) 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; } |