Source location information for ? and : in a ConditionalOperator, from Enea Zaffanella

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80097 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/PCHReaderStmt.cpp b/lib/Frontend/PCHReaderStmt.cpp
index fdefec7..dfcc794 100644
--- a/lib/Frontend/PCHReaderStmt.cpp
+++ b/lib/Frontend/PCHReaderStmt.cpp
@@ -491,6 +491,8 @@
   E->setCond(cast<Expr>(StmtStack[StmtStack.size() - 3]));
   E->setLHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 2]));
   E->setRHS(cast_or_null<Expr>(StmtStack[StmtStack.size() - 1]));
+  E->setQuestionLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
+  E->setColonLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
   return 3;
 }
 
diff --git a/lib/Frontend/PCHWriterStmt.cpp b/lib/Frontend/PCHWriterStmt.cpp
index ffde528..c0ebc7e 100644
--- a/lib/Frontend/PCHWriterStmt.cpp
+++ b/lib/Frontend/PCHWriterStmt.cpp
@@ -453,6 +453,8 @@
   Writer.WriteSubStmt(E->getCond());
   Writer.WriteSubStmt(E->getLHS());
   Writer.WriteSubStmt(E->getRHS());
+  Writer.AddSourceLocation(E->getQuestionLoc(), Record);
+  Writer.AddSourceLocation(E->getColonLoc(), Record);
   Code = pch::EXPR_CONDITIONAL_OPERATOR;
 }
 
diff --git a/lib/Frontend/RewriteObjC.cpp b/lib/Frontend/RewriteObjC.cpp
index 4d7bb31..8d5f499 100644
--- a/lib/Frontend/RewriteObjC.cpp
+++ b/lib/Frontend/RewriteObjC.cpp
@@ -2591,7 +2591,9 @@
                                                       SourceLocation());
     // (sizeof(returnType) <= 8 ? objc_msgSend(...) : objc_msgSend_stret(...))
     ConditionalOperator *CondExpr = 
-      new (Context) ConditionalOperator(lessThanExpr, CE, STCE, returnType);
+      new (Context) ConditionalOperator(lessThanExpr,
+                                        SourceLocation(), CE,
+                                        SourceLocation(), STCE, returnType);
     ReplacingStmt = new (Context) ParenExpr(SourceLocation(), SourceLocation(), CondExpr);
   }
   // delete Exp; leak for now, see RewritePropertySetter() usage for more info. 
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index b670cf7..a04f2fa 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3387,9 +3387,9 @@
   Cond.release();
   LHS.release();
   RHS.release();
-  return Owned(new (Context) ConditionalOperator(CondExpr,
+  return Owned(new (Context) ConditionalOperator(CondExpr, QuestionLoc,
                                                  isLHSNull ? 0 : LHSExpr,
-                                                 RHSExpr, result));
+                                                 ColonLoc, RHSExpr, result));
 }
 
 // CheckPointerTypesForAssignment - This is a very tricky routine (despite
diff --git a/lib/Sema/TreeTransform.h b/lib/Sema/TreeTransform.h
index 5d34e07..77d5220 100644
--- a/lib/Sema/TreeTransform.h
+++ b/lib/Sema/TreeTransform.h
@@ -3023,13 +3023,10 @@
       RHS.get() == E->getRHS())
     return SemaRef.Owned(E->Retain());
   
-  // FIXM: ? and : locations are broken.
-  SourceLocation FakeQuestionLoc = E->getCond()->getLocEnd();
-  SourceLocation FakeColonLoc = E->getFalseExpr()->getLocStart();
   return getDerived().RebuildConditionalOperator(move(Cond), 
-                                                 FakeQuestionLoc,
+                                                 E->getQuestionLoc(),
                                                  move(LHS), 
-                                                 FakeColonLoc,
+                                                 E->getColonLoc(),
                                                  move(RHS));
 }