[PATCH] D86782: [clang-format] Allow configuring list of macros that map to attributes
Alexander Richardson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 06:07:49 PDT 2020
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, curdeius, jrtc27.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.
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 <https://reviews.llvm.org/D86775> (to apply cleanly)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86782
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/FormatTokenLexer.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86782.288591.patch
Type: text/x-patch
Size: 13720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200828/ff197c35/attachment.bin>
More information about the cfe-commits
mailing list