mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 07:16:05 +00:00

Original commit message: " Commit https://github.com/llvm/llvm-project/commit/46f3ade introduced a notion of printing the attributes on the left to improve the printing of attributes attached to variable declarations. The intent was to produce more GCC compatible code because clang tends to print the attributes on the right hand side which is not accepted by gcc. This approach has increased the complexity in tablegen and the attrubutes themselves as now the are supposed to know where they could appear. That lead to mishandling of the `override` keyword which is modelled as an attribute in clang. This patch takes an inspiration from the existing approach and tries to keep the position of the attributes as they were written. To do so we use simpler heuristic which checks if the source locations of the attribute precedes the declaration. If so, it is considered to be printed before the declaration. Fixes https://github.com/llvm/llvm-project/issues/87151 " The reason for the bot breakage is that attributes coming from ApiNotes are not marked implicit even though they do not have source locations. This caused an assert to trigger. This patch forces attributes with no source location information to be printed on the left. That change is consistent to the overall intent of the change to increase the chances for attributes to compile across toolchains and at the same time the produced code to be as close as possible to the one written by the user.
8 lines
344 B
C++
8 lines
344 B
C++
// RUN: %clang_cc1 -std=c++11 -ast-print %s -o - | FileCheck %s
|
|
|
|
void should_not_crash_1() __attribute__((no_sanitize_memory));
|
|
[[clang::no_sanitize_memory]] void should_not_crash_2();
|
|
|
|
// CHECK: void should_not_crash_1() __attribute__((no_sanitize("memory")));
|
|
// CHECK: {{\[\[}}clang::no_sanitize("memory"){{\]\]}} void should_not_crash_2();
|