Author: rsmith Date: Mon Sep 4 17:50:19 2017 New Revision: 312506 URL: http://llvm.org/viewvc/llvm-project?rev=312506&view=rev Log: 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. Modified: cfe/trunk/lib/AST/DeclBase.cpp Modified: cfe/trunk/lib/AST/DeclBase.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=312506&r1=312505&r2=312506&view=diff ============================================================================== --- cfe/trunk/lib/AST/DeclBase.cpp (original) +++ cfe/trunk/lib/AST/DeclBase.cpp Mon Sep 4 17:50:19 2017 @@ -74,8 +74,9 @@ void *Decl::operator new(std::size_t Siz 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 = _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits