summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-03-19 23:48:41 +0000
committerTed Kremenek <kremenek@apple.com>2012-03-19 23:48:41 +0000
commite7d78882b4ca08b9e24f140dbb97875310f67ec7 (patch)
treed6b4cc7071d8c79a50986da762cc9955e8e46fba
parent0a2ac9052505566db08e466bd21072f0962f09d3 (diff)
downloadbcm5719-llvm-e7d78882b4ca08b9e24f140dbb97875310f67ec7.tar.gz
bcm5719-llvm-e7d78882b4ca08b9e24f140dbb97875310f67ec7.zip
Fix crash when querying the CFG reported when using the thread safety analysis
on code using multi-dimensional arrays. Fix by DeLesley Hutchins, and reported in PR 12271. llvm-svn: 153067
-rw-r--r--clang/lib/Analysis/CFG.cpp2
-rw-r--r--clang/test/SemaCXX/warn-everthing.cpp13
2 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 0a844a03767..24ca9588271 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -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/clang/test/SemaCXX/warn-everthing.cpp b/clang/test/SemaCXX/warn-everthing.cpp
new file mode 100644
index 00000000000..144a8f90df2
--- /dev/null
+++ b/clang/test/SemaCXX/warn-everthing.cpp
@@ -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
OpenPOWER on IntegriCloud