summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/test/Sema/ast-print.c3
-rw-r--r--clang/utils/TableGen/ClangAttrEmitter.cpp12
2 files changed, 12 insertions, 3 deletions
diff --git a/clang/test/Sema/ast-print.c b/clang/test/Sema/ast-print.c
index 382f0d38962..8ac4960b119 100644
--- a/clang/test/Sema/ast-print.c
+++ b/clang/test/Sema/ast-print.c
@@ -39,3 +39,6 @@ int rvarr(int n, int a[restrict static n]) {
return a[2];
}
+typedef struct {
+ int f;
+} T __attribute__ ((__aligned__));
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 0f0f89e55c6..45e9e02508a 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -486,9 +486,10 @@ namespace {
}
void writeValue(raw_ostream &OS) const override {
OS << "\";\n";
- OS << " assert(is" << getLowerName() << "Expr && " << getLowerName()
- << "Expr != nullptr);\n";
- OS << " " << getLowerName() << "Expr->printPretty(OS, 0, Policy);\n";
+ // The aligned attribute argument expression is optional.
+ OS << " if (is" << getLowerName() << "Expr && "
+ << getLowerName() << "Expr)\n";
+ OS << " " << getLowerName() << "Expr->printPretty(OS, 0, Policy);\n";
OS << " OS << \"";
}
void writeDump(raw_ostream &OS) const override {
@@ -1120,6 +1121,11 @@ writePrettyPrintFunction(Record &R,
continue;
}
+ // FIXME: always printing the parenthesis isn't the correct behavior for
+ // attributes which have optional arguments that were not provided. For
+ // instance: __attribute__((aligned)) will be pretty printed as
+ // __attribute__((aligned())). The logic should check whether there is only
+ // a single argument, and if it is optional, whether it has been provided.
if (!Args.empty())
OS << "(";
if (Spelling == "availability") {
OpenPOWER on IntegriCloud