diff --git a/clang/test/AST/attr-print-emit.cpp b/clang/test/AST/attr-print-emit.cpp index cc7413baf10e8..8c48eb92daba5 100644 --- a/clang/test/AST/attr-print-emit.cpp +++ b/clang/test/AST/attr-print-emit.cpp @@ -2,6 +2,12 @@ // RUN: %clang -emit-ast -o %t.ast %s // RUN: %clang_cc1 %t.ast -ast-print | FileCheck %s +// CHECK: void *aa() __attribute__((assume_aligned(64))); +void *aa() __attribute__((assume_aligned(64))); + +// CHECK: void *aa2() __attribute__((assume_aligned(64, 8))); +void *aa2() __attribute__((assume_aligned(64, 8))); + // CHECK: void xla(int a) __attribute__((xray_log_args(1))); void xla(int a) __attribute__((xray_log_args(1))); diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp index a015ec36a30dc..adaee8cc92c15 100644 --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -320,12 +320,19 @@ namespace { } std::string getIsOmitted() const override { - if (type == "IdentifierInfo *") + auto IsOneOf = [](StringRef subject, auto... list) { + return ((subject == list) || ...); + }; + + if (IsOneOf(type, "IdentifierInfo *", "Expr *")) return "!get" + getUpperName().str() + "()"; - if (type == "TypeSourceInfo *") + if (IsOneOf(type, "TypeSourceInfo *")) return "!get" + getUpperName().str() + "Loc()"; - if (type == "ParamIdx") + if (IsOneOf(type, "ParamIdx")) return "!get" + getUpperName().str() + "().isValid()"; + + assert(IsOneOf(type, "unsigned", "int", "bool", "FunctionDecl *", + "VarDecl *")); return "false"; }