[cfe-commits] r160424 - in /cfe/trunk: lib/Analysis/CFG.cpp test/Analysis/cxx-for-range-cfg.cpp
Ted Kremenek
kremenek at apple.com
Tue Jul 17 21:57:58 PDT 2012
Author: kremenek
Date: Tue Jul 17 23:57:57 2012
New Revision: 160424
URL: http://llvm.org/viewvc/llvm-project?rev=160424&view=rev
Log:
Teach CFG construction about destructors resulting from references to array types. Fixes crash in <rdar://problem/11671507>.
Added:
cfe/trunk/test/Analysis/cxx-for-range-cfg.cpp
Modified:
cfe/trunk/lib/Analysis/CFG.cpp
Modified: cfe/trunk/lib/Analysis/CFG.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=160424&r1=160423&r2=160424&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFG.cpp (original)
+++ cfe/trunk/lib/Analysis/CFG.cpp Tue Jul 17 23:57:57 2012
@@ -776,13 +776,12 @@
// 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();
Added: cfe/trunk/test/Analysis/cxx-for-range-cfg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-for-range-cfg.cpp?rev=160424&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/cxx-for-range-cfg.cpp (added)
+++ cfe/trunk/test/Analysis/cxx-for-range-cfg.cpp Tue Jul 17 23:57:57 2012
@@ -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}}
+}
More information about the cfe-commits
mailing list