Patched our local Clang to fix a crash when parsing

classes/structs that have variable-length arrays at
the end.

llvm-svn: 156026
This commit is contained in:
Sean Callanan 2012-05-02 21:54:54 +00:00
parent c0b976c42a
commit e38e69f204
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
Index: lib/Sema/SemaChecking.cpp
===================================================================
--- lib/Sema/SemaChecking.cpp (revision 152265)
+++ lib/Sema/SemaChecking.cpp (working copy)
@@ -4416,12 +4416,16 @@
// Don't consider sizes resulting from macro expansions or template argument
// substitution to form C89 tail-padded arrays.
- ConstantArrayTypeLoc TL =
- cast<ConstantArrayTypeLoc>(FD->getTypeSourceInfo()->getTypeLoc());
- const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
- if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
- return false;
+ TypeSourceInfo *TInfo = FD->getTypeSourceInfo();
+ if (TInfo) {
+ ConstantArrayTypeLoc TL =
+ cast<ConstantArrayTypeLoc>(TInfo->getTypeLoc());
+ const Expr *SizeExpr = dyn_cast<IntegerLiteral>(TL.getSizeExpr());
+ if (!SizeExpr || SizeExpr->getExprLoc().isMacroID())
+ return false;
+ }
+
const RecordDecl *RD = dyn_cast<RecordDecl>(FD->getDeclContext());
if (!RD) return false;
if (RD->isUnion()) return false;