summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/AST/ExprCXX.cpp5
-rw-r--r--clang/test/Index/annotate-tokens-cxx0x.cpp44
2 files changed, 48 insertions, 1 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 3da38f794f3..55589e6d21f 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -823,7 +823,10 @@ SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
}
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,
diff --git a/clang/test/Index/annotate-tokens-cxx0x.cpp b/clang/test/Index/annotate-tokens-cxx0x.cpp
index 49f7efb285a..4e6d156dfa9 100644
--- a/clang/test/Index/annotate-tokens-cxx0x.cpp
+++ b/clang/test/Index/annotate-tokens-cxx0x.cpp
@@ -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
OpenPOWER on IntegriCloud