Allow the fixit for missing ':' in the ?: ternary operator if it is pointing

at the start of a macro instantiation.

llvm-svn: 133801
This commit is contained in:
Argyrios Kyrtzidis 2011-06-24 17:28:29 +00:00
parent f096a6e754
commit 3ea4adb841
2 changed files with 8 additions and 2 deletions

View File

@ -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);

View File

@ -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;
}