Don't emit -Wpadded warnings without a valid SourceLocation. This can happen when RecordLayoutBuilder is used by Codegen, not Sema.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139162 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/RecordLayoutBuilder.cpp b/lib/AST/RecordLayoutBuilder.cpp
index eff1dae..b33c8d7 100644
--- a/lib/AST/RecordLayoutBuilder.cpp
+++ b/lib/AST/RecordLayoutBuilder.cpp
@@ -1751,6 +1751,11 @@
if (isa<ObjCIvarDecl>(D))
return;
+ // Don't warn about structs created without a SourceLocation. This can
+ // be done by clients of the AST, such as codegen.
+ if (D->getLocation().isInvalid())
+ return;
+
unsigned CharBitNum = Context.getTargetInfo().getCharWidth();
// Warn if padding was introduced to the struct/class.