summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-07-15 16:25:15 +0000
committerDouglas Gregor <dgregor@apple.com>2011-07-15 16:25:15 +0000
commite9d62935d3c42cb73c39fc4d0dc46bc35dc213ec (patch)
tree036b86922700ec62b02752888abd69f8ab3f1993 /clang/lib
parent397745e5406b0b6aefeddc43c71c1cc8e937bf5d (diff)
downloadbcm5719-llvm-e9d62935d3c42cb73c39fc4d0dc46bc35dc213ec.tar.gz
bcm5719-llvm-e9d62935d3c42cb73c39fc4d0dc46bc35dc213ec.zip
Store bracket locations for array subscript expressions, from Erik Verbruggen!
llvm-svn: 135275
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp11
-rw-r--r--clang/lib/Sema/TreeTransform.h23
2 files changed, 26 insertions, 8 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index b95b886efbe..437b2b5c6d4 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -38,8 +38,10 @@ using namespace sema;
/// function.
static ExprResult
CreateFunctionRefExpr(Sema &S, FunctionDecl *Fn,
- SourceLocation Loc = SourceLocation()) {
- ExprResult E = S.Owned(new (S.Context) DeclRefExpr(Fn, Fn->getType(), VK_LValue, Loc));
+ SourceLocation Loc = SourceLocation(),
+ const DeclarationNameLoc &LocInfo = DeclarationNameLoc()){
+ ExprResult E = S.Owned(new (S.Context) DeclRefExpr(Fn, Fn->getType(),
+ VK_LValue, Loc, LocInfo));
E = S.DefaultFunctionArrayConversion(E.take());
if (E.isInvalid())
return ExprError();
@@ -8878,7 +8880,10 @@ Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
ResultTy = ResultTy.getNonLValueExprType(Context);
// Build the actual expression node.
- ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, LLoc);
+ DeclarationNameLoc LocInfo;
+ LocInfo.CXXOperatorName.BeginOpNameLoc = LLoc.getRawEncoding();
+ LocInfo.CXXOperatorName.EndOpNameLoc = RLoc.getRawEncoding();
+ ExprResult FnExpr = CreateFunctionRefExpr(*this, FnDecl, LLoc, LocInfo);
if (FnExpr.isInvalid())
return ExprError();
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0530b5a1725..fa87217821a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -8357,11 +8357,24 @@ TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First);
}
- if (Op == OO_Subscript)
- return SemaRef.CreateOverloadedArraySubscriptExpr(Callee->getLocStart(),
- OpLoc,
- First,
- Second);
+ if (Op == OO_Subscript) {
+ SourceLocation LBrace;
+ SourceLocation RBrace;
+
+ if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
+ DeclarationNameLoc &NameLoc = DRE->getNameInfo().getInfo();
+ LBrace = SourceLocation::getFromRawEncoding(
+ NameLoc.CXXOperatorName.BeginOpNameLoc);
+ RBrace = SourceLocation::getFromRawEncoding(
+ NameLoc.CXXOperatorName.EndOpNameLoc);
+ } else {
+ LBrace = Callee->getLocStart();
+ RBrace = OpLoc;
+ }
+
+ return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
+ First, Second);
+ }
// Create the overloaded operator invocation for binary operators.
BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
OpenPOWER on IntegriCloud