llvm-project/lldb/scripts/clang.tail-padded-arrays.diff

27 lines
1.0 KiB
Diff

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;