summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-05-29 07:32:14 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-05-29 07:32:14 +0000
commita923fb2b3b009ff7a6c516f54c401c5fb533bc0c (patch)
tree353b8be41758b1713cb1abd5556c06118abf901c
parentb025724b46650db199da9d1c6bd6ff1ba536c54b (diff)
downloadbcm5719-llvm-a923fb2b3b009ff7a6c516f54c401c5fb533bc0c.tar.gz
bcm5719-llvm-a923fb2b3b009ff7a6c516f54c401c5fb533bc0c.zip
Fix a regression in the source locations for unary trait expressions.
I tried to use an assert to prove that I could remove each of the arguments I did, but ended up writing my assert with inverted logic. Doh! Reported by Xi Wang on cfe-dev. I have manually verified the source locations and ranges for these using -ast-dump. I tried writing a test case that would catch these, but these expressions aren't exposed in the c-index-test's token annotation utility. llvm-svn: 132284
-rw-r--r--clang/include/clang/Sema/Sema.h2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp15
-rw-r--r--clang/lib/Sema/TreeTransform.h2
3 files changed, 7 insertions, 12 deletions
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index ae6d9973276..76c627ee881 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2215,7 +2215,7 @@ public:
SourceLocation OpLoc,
UnaryExprOrTypeTrait ExprKind,
SourceRange R);
- ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E,
+ ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
UnaryExprOrTypeTrait ExprKind);
ExprResult
ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 9f964fab9cd..0a74daa008d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3262,7 +3262,8 @@ Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
/// \brief Build a sizeof or alignof expression given an expression
/// operand.
ExprResult
-Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, UnaryExprOrTypeTrait ExprKind) {
+Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc,
+ UnaryExprOrTypeTrait ExprKind) {
// Verify that the operand is valid.
bool isInvalid = false;
if (E->isTypeDependent()) {
@@ -3277,7 +3278,7 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, UnaryExprOrTypeTrait ExprKind) {
} else if (E->getType()->isPlaceholderType()) {
ExprResult PE = CheckPlaceholderExpr(E);
if (PE.isInvalid()) return ExprError();
- return CreateUnaryExprOrTypeTraitExpr(PE.take(), ExprKind);
+ return CreateUnaryExprOrTypeTraitExpr(PE.take(), OpLoc, ExprKind);
} else {
isInvalid = CheckUnaryExprOrTypeTraitOperand(E, UETT_SizeOf);
}
@@ -3287,7 +3288,7 @@ Sema::CreateUnaryExprOrTypeTraitExpr(Expr *E, UnaryExprOrTypeTrait ExprKind) {
// C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
return Owned(new (Context) UnaryExprOrTypeTraitExpr(
- ExprKind, E, Context.getSizeType(), E->getExprLoc(),
+ ExprKind, E, Context.getSizeType(), OpLoc,
E->getSourceRange().getEnd()));
}
@@ -3308,13 +3309,7 @@ Sema::ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc,
}
Expr *ArgEx = (Expr *)TyOrEx;
-
- // Make sure the location is accurately represented in the Expr node.
- // FIXME: Is this really needed?
- assert(ArgEx->getExprLoc() != OpLoc && "Mismatched locations");
-
- ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, ExprKind);
-
+ ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
return move(Result);
}
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 2bf3c228c49..1473ae5ac2b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -1378,7 +1378,7 @@ public:
UnaryExprOrTypeTrait ExprKind,
SourceRange R) {
ExprResult Result
- = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, ExprKind);
+ = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
if (Result.isInvalid())
return ExprError();
OpenPOWER on IntegriCloud