r190561 - Fix the end-location of a CXXTemporaryObjectExpr when it is created with a initializer_list.
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Sep 11 16:23:28 PDT 2013
Author: akirtzidis
Date: Wed Sep 11 18:23:27 2013
New Revision: 190561
URL: http://llvm.org/viewvc/llvm-project?rev=190561&view=rev
Log:
Fix the end-location of a CXXTemporaryObjectExpr when it is created with a initializer_list.
rdar://14887351
Modified:
cfe/trunk/lib/AST/ExprCXX.cpp
cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
Modified: cfe/trunk/lib/AST/ExprCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCXX.cpp?rev=190561&r1=190560&r2=190561&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprCXX.cpp (original)
+++ cfe/trunk/lib/AST/ExprCXX.cpp Wed Sep 11 18:23:27 2013
@@ -823,7 +823,10 @@ SourceLocation CXXTemporaryObjectExpr::g
}
SourceLocation CXXTemporaryObjectExpr::getLocEnd() const {
- return getParenOrBraceRange().getEnd();
+ SourceLocation Loc = getParenOrBraceRange().getEnd();
+ if (Loc.isInvalid() && getNumArgs())
+ Loc = getArg(getNumArgs()-1)->getLocEnd();
+ return Loc;
}
CXXConstructExpr *CXXConstructExpr::Create(const ASTContext &C, QualType T,
Modified: cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp?rev=190561&r1=190560&r2=190561&view=diff
==============================================================================
--- cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp (original)
+++ cfe/trunk/test/Index/annotate-tokens-cxx0x.cpp Wed Sep 11 18:23:27 2013
@@ -23,6 +23,47 @@ class S : public B {
virtual void foo(Int) override;
};
+// Need std::initializer_list
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ // libc++'s implementation
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ initializer_list(const _E* __b, size_t __s)
+ : __begin_(__b),
+ __size_(__s)
+ {}
+
+ public:
+ typedef _E value_type;
+ typedef const _E& reference;
+ typedef const _E& const_reference;
+ typedef size_t size_type;
+
+ typedef const _E* iterator;
+ typedef const _E* const_iterator;
+
+ initializer_list() : __begin_(nullptr), __size_(0) {}
+
+ size_t size() const {return __size_;}
+ const _E* begin() const {return __begin_;}
+ const _E* end() const {return __begin_ + __size_;}
+ };
+}
+
+struct Foo {
+ Foo(std::initializer_list<int> il);
+};
+
+void test2() {
+ Foo{10};
+}
+
// RUN: c-index-test -test-annotate-tokens=%s:1:1:5:1 -fno-delayed-template-parsing -std=c++11 %s | FileCheck %s
// CHECK: Identifier: "args" [3:20 - 3:24] SizeOfPackExpr=args:2:15
@@ -52,3 +93,6 @@ class S : public B {
// CHECK-WITH-OVERRIDE: Punctuation: ")" [23:23 - 23:24] ParmDecl=:23:23 (Definition)
// CHECK-WITH-OVERRIDE: Keyword: "override" [23:25 - 23:33] attribute(override)=
// CHECK-WITH-OVERRIDE: Punctuation: ";" [23:33 - 23:34] ClassDecl=S:22:7 (Definition)
+
+// RUN: c-index-test -test-annotate-tokens=%s:64:1:65:1 -std=c++11 %s | FileCheck -check-prefix=CHECK-INITLIST %s
+// CHECK-INITLIST: Identifier: "Foo" [64:3 - 64:6] TypeRef=struct Foo:59:8
More information about the cfe-commits
mailing list