[all-commits] [llvm/llvm-project] 9391ff: Reland "Rework the printing of attributes (#87281)"
Vassil Vassilev via All-commits
all-commits at lists.llvm.org
Tue Apr 9 00:28:35 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9391ff8c86007562d40c240ea082b7c0cbf35947
https://github.com/llvm/llvm-project/commit/9391ff8c86007562d40c240ea082b7c0cbf35947
Author: Vassil Vassilev <v.g.vassilev at gmail.com>
Date: 2024-04-09 (Tue, 09 Apr 2024)
Changed paths:
M clang/include/clang/Basic/Attr.td
M clang/include/clang/Basic/CMakeLists.txt
M clang/lib/AST/DeclPrinter.cpp
M clang/lib/AST/StmtPrinter.cpp
M clang/test/APINotes/retain-count-convention.m
M clang/test/APINotes/versioned.m
M clang/test/AST/ast-print-method-decl.cpp
M clang/test/AST/ast-print-no-sanitize.cpp
M clang/test/AST/attr-print-emit.cpp
M clang/test/Analysis/scopes-cfg-output.cpp
M clang/test/OpenMP/assumes_codegen.cpp
M clang/test/OpenMP/assumes_print.cpp
M clang/test/OpenMP/assumes_template_print.cpp
M clang/test/OpenMP/declare_simd_ast_print.cpp
M clang/test/SemaCXX/attr-no-sanitize.cpp
M clang/test/SemaCXX/cxx11-attr-print.cpp
M clang/utils/TableGen/ClangAttrEmitter.cpp
M clang/utils/TableGen/TableGen.cpp
M clang/utils/TableGen/TableGenBackends.h
Log Message:
-----------
Reland "Rework the printing of attributes (#87281)"
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.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list