summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Analysis/CFG.cpp9
-rw-r--r--clang/test/Analysis/cxx-for-range-cfg.cpp16
2 files changed, 20 insertions, 5 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index e3cd74b1e4c..e141ed9a447 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -776,13 +776,12 @@ void CFGBuilder::addAutomaticObjDtors(LocalScope::const_iterator B,
// If this destructor is marked as a no-return destructor, we need to
// create a new block for the destructor which does not have as a successor
// anything built thus far: control won't flow out of this block.
- QualType Ty;
- if ((*I)->getType()->isReferenceType()) {
+ QualType Ty = (*I)->getType();
+ if (Ty->isReferenceType()) {
Ty = getReferenceInitTemporaryType(*Context, (*I)->getInit());
- } else {
- Ty = Context->getBaseElementType((*I)->getType());
}
-
+ Ty = Context->getBaseElementType(Ty);
+
const CXXDestructorDecl *Dtor = Ty->getAsCXXRecordDecl()->getDestructor();
if (cast<FunctionType>(Dtor->getType())->getNoReturnAttr())
Block = createNoReturnBlock();
diff --git a/clang/test/Analysis/cxx-for-range-cfg.cpp b/clang/test/Analysis/cxx-for-range-cfg.cpp
new file mode 100644
index 00000000000..e258c7a1e20
--- /dev/null
+++ b/clang/test/Analysis/cxx-for-range-cfg.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -Wall -fsyntax-only %s -std=c++11 -verify
+
+// The rdar11671507_vector<int *>[]> would previously crash CFG construction
+// because of the temporary array of vectors.
+template <typename T>
+class rdar11671507_vector {
+public:
+ rdar11671507_vector();
+ ~rdar11671507_vector();
+ T *Base;
+ T *End;
+};
+
+void rdar11671507(rdar11671507_vector<int*> v, rdar11671507_vector<int*> w) {
+ for (auto &vec : (rdar11671507_vector<int *>[]){ v, w }) {} // expected-warning {{unused}}
+}
OpenPOWER on IntegriCloud