[cfe-commits] r66679 - in /cfe/trunk: lib/AST/StmtIterator.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Wed Mar 11 11:17:17 PDT 2009
Author: kremenek
Date: Wed Mar 11 13:17:16 2009
New Revision: 66679
URL: http://llvm.org/viewvc/llvm-project?rev=66679&view=rev
Log:
Fix StmtIterator bug reported in PR 3780 where a VLA within a DeclGroup would
not be consulted for its size expression when operator* was called in the
StmtIterator (this resulted in an assertion failure).
Modified:
cfe/trunk/lib/AST/StmtIterator.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/AST/StmtIterator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtIterator.cpp?rev=66679&r1=66678&r2=66679&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtIterator.cpp (original)
+++ cfe/trunk/lib/AST/StmtIterator.cpp Wed Mar 11 13:17:16 2009
@@ -132,17 +132,17 @@
Stmt*& StmtIteratorBase::GetDeclExpr() const {
- if (inDeclGroup()) {
- VarDecl* VD = cast<VarDecl>(*DGI);
- return VD->Init;
- }
-
- assert (inDecl() || inSizeOfTypeVA());
-
if (VariableArrayType* VAPtr = getVAPtr()) {
assert (VAPtr->SizeExpr);
return VAPtr->SizeExpr;
}
+
+ assert (inDecl() || inDeclGroup());
+
+ if (inDeclGroup()) {
+ VarDecl* VD = cast<VarDecl>(*DGI);
+ return VD->Init;
+ }
assert (inDecl());
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=66679&r1=66678&r2=66679&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Mar 11 13:17:16 2009
@@ -178,13 +178,13 @@
return 'a';
}
-// PR 3780
+// PR 3772
// - We just want to test that this doesn't crash the analyzer.
typedef struct st ST;
struct st { char *name; };
extern ST *Cur_Pu;
-void pr3780(void)
+void pr3772(void)
{
static ST *last_Cur_Pu;
if (last_Cur_Pu == Cur_Pu) {
@@ -192,4 +192,6 @@
}
}
+// PR 3780 - This tests that StmtIterator isn't broken for VLAs in DeclGroups.
+void pr3780(int sz) { typedef double MAT[sz][sz]; }
More information about the cfe-commits
mailing list