[all-commits] [llvm/llvm-project] e7bd05: [clang-format] Allow configuring list of macros th...
Alexander Richardson via All-commits
all-commits at lists.llvm.org
Mon Sep 7 02:09:45 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: e7bd058c7e2cb2c675a4b78ec770ea725bff8c64
https://github.com/llvm/llvm-project/commit/e7bd058c7e2cb2c675a4b78ec770ea725bff8c64
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/docs/ClangFormatStyleOptions.rst
M clang/include/clang/Format/Format.h
M clang/lib/Format/Format.cpp
M clang/lib/Format/FormatToken.h
M clang/lib/Format/FormatTokenLexer.cpp
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Allow configuring list of macros that map to attributes
This adds a `AttributeMacros` configuration option that causes certain
identifiers to be parsed like a __attribute__((foo)) annotation.
This is motivated by our CHERI C/C++ fork which adds a __capability
qualifier for pointer/reference. Without this change clang-format parses
many type declarations as multiplications/bitwise-and instead.
I initially considered adding "__capability" as a new clang-format keyword,
but having a list of macros that should be treated as attributes is more
flexible since it can be used e.g. for static analyzer annotations or other language
extensions.
Example: std::vector<foo * __capability> -> std::vector<foo *__capability>
Depends on D86775 (to apply cleanly)
Reviewed By: MyDeveloperDay, jrtc27
Differential Revision: https://reviews.llvm.org/D86782
Commit: 8aa3b8da5db2ae73bf536b630915eb9f0ddc15cb
https://github.com/llvm/llvm-project/commit/8aa3b8da5db2ae73bf536b630915eb9f0ddc15cb
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/lib/Format/FormatToken.h
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Handle typename macros inside cast expressions
Before: x = (STACK_OF(uint64_t)) & a;
After: x = (STACK_OF(uint64_t))&a;
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86930
Commit: cd01eec14bc045a8616604cadf94dba025090ba5
https://github.com/llvm/llvm-project/commit/cd01eec14bc045a8616604cadf94dba025090ba5
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Check that */& after typename macros are pointers/references
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86950
Commit: 56fa7d1dc6a8d23111ff84171036f333cf9cddf2
https://github.com/llvm/llvm-project/commit/56fa7d1dc6a8d23111ff84171036f333cf9cddf2
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/lib/Format/FormatToken.cpp
M clang/lib/Format/FormatToken.h
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Fix formatting of _Atomic() qualifier
Before: _Atomic(uint64_t) * a;
After: _Atomic(uint64_t) *a;
This treats _Atomic the same as the the TypenameMacros and decltype. It
also allows some cleanup by removing checks whether the token before a
paren is kw_decltype and instead checking for TT_TypeDeclarationParen.
While touching this code also extend the decltype test cases to also check
for typeof() and _Atomic(T).
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86959
Commit: 9a22eba15091ea849fa78c09ac4c9f7260071790
https://github.com/llvm/llvm-project/commit/9a22eba15091ea849fa78c09ac4c9f7260071790
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/lib/Format/FormatToken.h
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Parse __underlying_type(T) as a type
Before: MACRO(__underlying_type(A) * a);
After: MACRO(__underlying_type(A) *a);
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D86960
Commit: 05147d33091720e2df929d6fea3b0fd2a657ac61
https://github.com/llvm/llvm-project/commit/05147d33091720e2df929d6fea3b0fd2a657ac61
Author: Alex Richardson <Alexander.Richardson at cl.cam.ac.uk>
Date: 2020-09-07 (Mon, 07 Sep 2020)
Changed paths:
M clang/lib/Format/TokenAnnotator.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format] Correctly parse function declarations with TypenameMacros
When using the always break after return type setting:
Before:
SomeType funcdecl(LIST(uint64_t));
After:
SomeType
funcdecl(LIST(uint64_t));"
Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D87007
Compare: https://github.com/llvm/llvm-project/compare/65f78e73ad57...05147d330917
More information about the All-commits
mailing list