[PATCH] D86950: [clang-format] Check that */& after typename macros are pointers/references
Alexander Richardson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 7 02:09:59 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd01eec14bc0: [clang-format] Check that */& after typename macros are pointers/references (authored by arichardson).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86950/new/
https://reviews.llvm.org/D86950
Files:
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8041,6 +8041,14 @@
verifyFormat("vector<a *__ptr32> v;");
verifyFormat("vector<a *__ptr64> v;");
verifyFormat("vector<a *__capability> v;");
+ FormatStyle TypeMacros = getLLVMStyle();
+ TypeMacros.TypenameMacros = {"LIST"};
+ verifyFormat("vector<LIST(uint64_t)> v;", TypeMacros);
+ verifyFormat("vector<LIST(uint64_t) *> v;", TypeMacros);
+ verifyFormat("vector<LIST(uint64_t) **> v;", TypeMacros);
+ verifyFormat("vector<LIST(uint64_t) *attr> v;", TypeMacros);
+ verifyFormat("vector<A(uint64_t) * attr> v;", TypeMacros); // multiplication
+
FormatStyle CustomQualifier = getLLVMStyle();
// Add indentifers that should not be parsed as a qualifier by default.
CustomQualifier.AttributeMacros.push_back("__my_qualifier");
@@ -8105,6 +8113,9 @@
// a type declaration:
verifyFormat("MACRO(A *__my_qualifier);", CustomQualifier);
verifyFormat("void f() { MACRO(A *__my_qualifier); }", CustomQualifier);
+ // Also check that TypenameMacros prevents parsing it as multiplication:
+ verifyIndependentOfContext("MACRO(LIST(uint64_t) * a);"); // multiplication
+ verifyIndependentOfContext("MACRO(LIST(uint64_t) *a);", TypeMacros); // type
verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
verifyFormat("void f() { f(float{1}, a * a); }");
@@ -16553,12 +16564,15 @@
verifyFormat("STACK_OF(LIST(int)) a, b;", Macros);
verifyFormat("for (LIST(int) *a = NULL; a;) {\n}", Macros);
verifyFormat("STACK_OF(int) f(LIST(int) *arg);", Macros);
+ verifyFormat("vector<LIST(uint64_t) *attr> x;", Macros);
+ verifyFormat("vector<LIST(uint64_t) *const> f(LIST(uint64_t) *arg);", Macros);
Macros.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("STACK_OF(int)* a;", Macros);
verifyFormat("STACK_OF(int*)* a;", Macros);
verifyFormat("x = (STACK_OF(uint64_t))*a;", Macros);
verifyFormat("x = (STACK_OF(uint64_t))&a;", Macros);
+ verifyFormat("vector<STACK_OF(uint64_t)* attr> x;", Macros);
}
TEST_F(FormatTest, AmbersandInLamda) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86950.290210.patch
Type: text/x-patch
Size: 2203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200907/442f0b8a/attachment.bin>
More information about the cfe-commits
mailing list