Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Bug Fixes to Compiler Builtins

Bug Fixes to Attribute Support
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed crash when a parameter to the ``clang::annotate`` attribute evaluates to ``void``. See #GH119125

Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Sema/SemaAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ bool Sema::ConstantFoldAttrArgs(const AttributeCommonInfo &CI,
Diag(Note.first, Note.second);
return false;
}
assert(Eval.Val.hasValue());
E = ConstantExpr::Create(Context, E, Eval.Val);
}

Expand Down
10 changes: 10 additions & 0 deletions clang/test/CodeGenCXX/attr-annotate2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@
// CHECK: @[[STR:.*]] = private unnamed_addr constant [45 x i8] c"_Generic selection expression should be fine\00", section "llvm.metadata"
// CHECK-NEXT: @[[FILENAME:.*]] = private unnamed_addr constant {{.*}}, section "llvm.metadata"
// CHECK-NEXT: @[[ARGS:.*]] = private unnamed_addr constant { i32 } zeroinitializer, section "llvm.metadata"
// CHECK-NEXT: @[[STR2:.*]] = private unnamed_addr constant [14 x i8] c"void is undef\00", section "llvm.metadata"
// CHECK-NEXT: @[[ARGS3:.*]] = private unnamed_addr constant { i8, i8, i32 } { i8 undef, i8 undef, i32 7 }, section "llvm.metadata"



// CHECK-LABEL: @_Z1fv(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[N:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[J:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[K:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i32 10, ptr [[N]], align 4
// CHECK-NEXT: call void @llvm.var.annotation.p0.p0(ptr [[J]], ptr @[[STR]], ptr @[[FILENAME]], i32 {{.*}}, ptr @[[ARGS]])
// CHECK-NEXT: store i32 0, ptr [[J]], align 4
// CHECK-NEXT: call void @llvm.var.annotation.p0.p0(ptr [[K]], ptr @[[STR2]], ptr @[[FILENAME]], i32 {{.*}}, ptr @[[ARGS3]])
// CHECK-NEXT: store i32 0, ptr [[K]], align 4
// CHECK-NEXT: ret void
//
void f() {
int n = 10;
[[clang::annotate("_Generic selection expression should be fine", _Generic(n, int : 0, default : 1))]]
int j = 0; // second arg should resolve to 0 fine

[[clang::annotate("void is undef", (void)2, (void)4, 7)]]
int k = 0;
}
4 changes: 4 additions & 0 deletions clang/test/SemaCXX/attr-annotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ constexpr int foldable_but_invalid() {
template <typename T> [[clang::annotate()]] void f2() {}
// expected-error@-1 {{'annotate' attribute takes at least 1 argument}}
}

namespace test5 {
void bir [[clang::annotate("B", (void)1)]] ();
}
Loading