]> granicus.if.org Git - clang/commitdiff
Fix crash when querying the CFG reported when using the thread safety analysis
authorTed Kremenek <kremenek@apple.com>
Mon, 19 Mar 2012 23:48:41 +0000 (23:48 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 19 Mar 2012 23:48:41 +0000 (23:48 +0000)
on code using multi-dimensional arrays.  Fix by DeLesley Hutchins, and reported in
PR 12271.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153067 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFG.cpp
test/SemaCXX/warn-everthing.cpp [new file with mode: 0644]

index 0a844a03767eaae969fe48a572a47682902dd67b..24ca95882710c04c76c87694dfc8935454222393 100644 (file)
@@ -3087,7 +3087,7 @@ CFGImplicitDtor::getDestructorDecl(ASTContext &astContext) const {
       const VarDecl *var = cast<CFGAutomaticObjDtor>(this)->getVarDecl();
       QualType ty = var->getType();
       ty = ty.getNonReferenceType();
-      if (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
+      while (const ArrayType *arrayType = astContext.getAsArrayType(ty)) {
         ty = arrayType->getElementType();
       }
       const RecordType *recordType = ty->getAs<RecordType>();
diff --git a/test/SemaCXX/warn-everthing.cpp b/test/SemaCXX/warn-everthing.cpp
new file mode 100644 (file)
index 0000000..144a8f9
--- /dev/null
@@ -0,0 +1,13 @@
+// RUN: %clang -Weverything -fsyntax-only %s -verify
+
+// This previously crashed due to a bug in the CFG.  Exercising all
+// warnings helps check CFG construction.
+class PR12271 {
+public:
+  PR12271();
+  ~PR12271();
+};
+
+void testPR12271() {
+  PR12271 a[1][1];
+}
\ No newline at end of file