Author: Timm Bäder Date: 2021-03-23T15:26:25+01:00 New Revision: bc6b139392f638a69e85a474eb0eb59e13d9791a
URL: https://github.com/llvm/llvm-project/commit/bc6b139392f638a69e85a474eb0eb59e13d9791a DIFF: https://github.com/llvm/llvm-project/commit/bc6b139392f638a69e85a474eb0eb59e13d9791a.diff LOG: [clang][parser] Don't prohibit attributes on objc @try/@throw This line has a TODO comment, but the answer to it seems to be "no" given that clang itself uses attributes on @try statements in its tests. This ProhibitAttributes() statement is also dead code since ProhibitAttributs() does not handle GNU attributes at the moment but those are the only attributes valid in objc. Differential Revision: https://reviews.llvm.org/D97371 Added: clang/test/CodeGenObjC/attr-nomerge.m Modified: clang/lib/Parse/ParseStmt.cpp Removed: ################################################################################ diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 798b8d0d7eb1..bcda3560ce63 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -172,7 +172,6 @@ StmtResult Parser::ParseStatementOrDeclarationAfterAttributes( switch (Kind) { case tok::at: // May be a @try or @throw statement { - ProhibitAttributes(Attrs); // TODO: is it correct? AtLoc = ConsumeToken(); // consume @ return ParseObjCAtStatement(AtLoc, StmtCtx); } diff --git a/clang/test/CodeGenObjC/attr-nomerge.m b/clang/test/CodeGenObjC/attr-nomerge.m new file mode 100644 index 000000000000..7d053d0b1d69 --- /dev/null +++ b/clang/test/CodeGenObjC/attr-nomerge.m @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -triple x86_64-unknown-linux -o - %s | FileCheck %s + +// Test that the nomerge attribute is applied to function calls +// in @try, @catch and @finally +void opaque(void); +void opaque2(void); +void opaque3(void); + +int main(int argc, const char * argv[]) { + __attribute__((nomerge)) @try { + opaque(); + } @catch(...) { + opaque2(); + } @finally { + opaque3(); + } + + return 0; +} + +// CHECK: call void @opaque() #[[ATTR0:[0-9]+]] +// CHECK-DAG: call void @opaque2() #[[ATTR0]] +// CHECK-DAG: call void @opaque3() #[[ATTR0]] +// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits