Revert clang change that breaks CTF on aarch64

Revert commit e655e74a318e from llvm git (by Peter Collingbourne):

  AST: Create __va_list in the std namespace even in C.

  This ensures that the mangled type names match between C and C++,
  which is significant when using -fsanitize=cfi-icall. Ideally we
  wouldn't have created this namespace at all, but it's now part of
  the ABI (e.g. in mangled names), so we can't change it.

  Differential Revision: https://reviews.llvm.org/D104830

As reported by Jessica in https://reviews.llvm.org/D104830#3129527, this
upstream change is implemented in such a way that it breaks DTrace's
CTF. Since a proper fix has not yet been forthcoming, and we are
unaffected by the (CFI-related) problem upstream was trying to address,
revert the change for now.

Requested by:	jrtc27
MFC after:	3 days
This commit is contained in:
Dimitry Andric 2021-12-12 21:11:40 +01:00
parent 73b357be92
commit da2012af42

View File

@ -8002,21 +8002,19 @@ static TypedefDecl *CreateVoidPtrBuiltinVaListDecl(const ASTContext *Context) {
static TypedefDecl * static TypedefDecl *
CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) { CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) {
// struct __va_list
RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list"); RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list");
// namespace std { struct __va_list { if (Context->getLangOpts().CPlusPlus) {
// Note that we create the namespace even in C. This is intentional so that // namespace std { struct __va_list {
// the type is consistent between C and C++, which is important in cases where NamespaceDecl *NS;
// the types need to match between translation units (e.g. with NS = NamespaceDecl::Create(const_cast<ASTContext &>(*Context),
// -fsanitize=cfi-icall). Ideally we wouldn't have created this namespace at Context->getTranslationUnitDecl(),
// all, but it's now part of the ABI (e.g. in mangled names), so we can't /*Inline*/ false, SourceLocation(),
// change it. SourceLocation(), &Context->Idents.get("std"),
auto *NS = NamespaceDecl::Create( /*PrevDecl*/ nullptr);
const_cast<ASTContext &>(*Context), Context->getTranslationUnitDecl(), NS->setImplicit();
/*Inline*/ false, SourceLocation(), SourceLocation(), VaListTagDecl->setDeclContext(NS);
&Context->Idents.get("std"), }
/*PrevDecl*/ nullptr);
NS->setImplicit();
VaListTagDecl->setDeclContext(NS);
VaListTagDecl->startDefinition(); VaListTagDecl->startDefinition();