aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-09-05 00:50:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-09-05 00:50:19 +0000
commitdebbaefb76230baf7e1181eaeac7ac44aeaccd17 (patch)
treeb16b500c9336daf07fea61ba45b8438214e6e9e0 /clang/lib/AST/DeclBase.cpp
parent8d7c8c79609b932473f2a8fe1d367e5bcacea249 (diff)
downloadllvm-debbaefb76230baf7e1181eaeac7ac44aeaccd17.zip
llvm-debbaefb76230baf7e1181eaeac7ac44aeaccd17.tar.gz
llvm-debbaefb76230baf7e1181eaeac7ac44aeaccd17.tar.bz2
Always allocate room for a ModuleDecl on the TranslationUnitDecl.
Sometimes we create the ASTContext and thus the TranslationUnitDecl before we know the LangOptions. This should fix the asan buildbot failures after r312467. llvm-svn: 312506
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index cd2c83a..abe17b5 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -74,8 +74,9 @@ void *Decl::operator new(std::size_t Size, const ASTContext &Ctx,
DeclContext *Parent, std::size_t Extra) {
assert(!Parent || &Parent->getParentASTContext() == &Ctx);
// With local visibility enabled, we track the owning module even for local
- // declarations.
- if (Ctx.getLangOpts().trackLocalOwningModule()) {
+ // declarations. We create the TU decl early and may not yet know what the
+ // LangOpts are, so conservatively allocate the storage.
+ if (Ctx.getLangOpts().trackLocalOwningModule() || !Parent) {
// Ensure required alignment of the resulting object by adding extra
// padding at the start if required.
size_t ExtraAlign =