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 *
CreateAArch64ABIBuiltinVaListDecl(const ASTContext *Context) {
// struct __va_list
RecordDecl *VaListTagDecl = Context->buildImplicitRecord("__va_list");
// namespace std { struct __va_list {
// Note that we create the namespace even in C. This is intentional so that
// the type is consistent between C and C++, which is important in cases where
// the types need to match between translation units (e.g. with
// -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.
auto *NS = NamespaceDecl::Create(
const_cast<ASTContext &>(*Context), Context->getTranslationUnitDecl(),
/*Inline*/ false, SourceLocation(), SourceLocation(),
&Context->Idents.get("std"),
/*PrevDecl*/ nullptr);
NS->setImplicit();
VaListTagDecl->setDeclContext(NS);
if (Context->getLangOpts().CPlusPlus) {
// namespace std { struct __va_list {
NamespaceDecl *NS;
NS = NamespaceDecl::Create(const_cast<ASTContext &>(*Context),
Context->getTranslationUnitDecl(),
/*Inline*/ false, SourceLocation(),
SourceLocation(), &Context->Idents.get("std"),
/*PrevDecl*/ nullptr);
NS->setImplicit();
VaListTagDecl->setDeclContext(NS);
}
VaListTagDecl->startDefinition();