summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2019-11-18 10:22:14 -0500
committerJoel E. Denny <jdenny.ornl@gmail.com>2019-11-18 11:55:25 -0500
commitc85fa79d3663ecb3117e178b2a79ffa721d18e32 (patch)
treedfb02d49e530d64e4d0e4e3e9e9c370c2e4ed03a
parent015b2e699f0c7205564e51dd73a0d619571640bf (diff)
downloadbcm5719-llvm-c85fa79d3663ecb3117e178b2a79ffa721d18e32.tar.gz
bcm5719-llvm-c85fa79d3663ecb3117e178b2a79ffa721d18e32.zip
[Attr] Fix `-ast-print` for `asm` attribute
Without this fix, the tests introduced here produce the following assert fail: ``` clang: /home/jdenny/llvm/clang/include/clang/Basic/AttributeCommonInfo.h:163: unsigned int clang::AttributeCommonInfo::getAttributeSpellingListIndex() const: Assertion `(isAttributeSpellingListCalculated() || AttrName) && "Spelling cannot be found"' failed. ``` The bug was introduced by D67368, which caused `AsmLabelAttr`'s spelling index to be set to `SpellingNotCalculated`. Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D70349
-rw-r--r--clang/lib/Sema/SemaDecl.cpp11
-rw-r--r--clang/test/AST/ast-print-attr.c5
2 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b469217108c..6d857e832c4 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -7019,8 +7019,9 @@ NamedDecl *Sema::ActOnVariableDeclarator(
}
}
- NewVD->addAttr(::new (Context) AsmLabelAttr(
- Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
+ NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
+ /*IsLiteralLabel=*/true,
+ SE->getStrTokenLoc(0)));
} else if (!ExtnameUndeclaredIdentifiers.empty()) {
llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8923,9 +8924,9 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
if (Expr *E = (Expr*) D.getAsmLabel()) {
// The parser guarantees this is a string.
StringLiteral *SE = cast<StringLiteral>(E);
- NewFD->addAttr(::new (Context)
- AsmLabelAttr(Context, SE->getStrTokenLoc(0),
- SE->getString(), /*IsLiteralLabel=*/true));
+ NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
+ /*IsLiteralLabel=*/true,
+ SE->getStrTokenLoc(0)));
} else if (!ExtnameUndeclaredIdentifiers.empty()) {
llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());
diff --git a/clang/test/AST/ast-print-attr.c b/clang/test/AST/ast-print-attr.c
index 223e27b3979..6448437c5ea 100644
--- a/clang/test/AST/ast-print-attr.c
+++ b/clang/test/AST/ast-print-attr.c
@@ -10,3 +10,8 @@ using B = int ** __ptr32 *[3];
// FIXME: Too many parens here!
// CHECK: using C = int ((*))() __attribute__((cdecl));
using C = int (*)() [[gnu::cdecl]];
+
+// CHECK: int fun_asm() asm("");
+int fun_asm() asm("");
+// CHECK: int var_asm asm("");
+int var_asm asm("");
OpenPOWER on IntegriCloud