[PATCH] D86775: [clang-format] Parse __ptr32/__ptr64 as a pointer qualifier
Alexander Richardson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 04:36:28 PDT 2020
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.
Before:
x = (foo *__ptr32) * v;
MACRO(A * __ptr32 a);
x = (foo *__ptr64) * v;
MACRO(A * __ptr64 a);
After:
x = (foo *__ptr32)*v;
MACRO(A *__ptr32 a);
x = (foo *__ptr64)*v;
MACRO(A *__ptr64 a);
Depends on D86721 <https://reviews.llvm.org/D86721> (to apply cleanly)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D86775
Files:
clang/lib/Format/FormatToken.h
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8028,6 +8028,8 @@
verifyFormat("vector<a *_Nonnull> v;");
verifyFormat("vector<a *_Nullable> v;");
verifyFormat("vector<a *_Null_unspecified> v;");
+ verifyFormat("vector<a *__ptr32> v;");
+ verifyFormat("vector<a *__ptr64> v;");
verifyFormat("vector<a * _NotAQualifier> v;");
verifyFormat("vector<a * b> v;");
verifyFormat("foo<b && false>();");
@@ -8069,6 +8071,8 @@
verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
verifyIndependentOfContext("MACRO(A *[[clang::attr]] a);");
+ verifyIndependentOfContext("MACRO(A *__ptr32 a);");
+ verifyIndependentOfContext("MACRO(A *__ptr64 a);");
verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
verifyFormat("void f() { f(float{1}, a * a); }");
// FIXME: Is there a way to make this work?
@@ -8139,6 +8143,8 @@
verifyFormat("x = (foo *_Null_unspecified)*v;");
verifyFormat("x = (foo *_Nonnull)*v;");
verifyFormat("x = (foo *[[clang::attr]])*v;");
+ verifyFormat("x = (foo *__ptr32)*v;");
+ verifyFormat("x = (foo *__ptr64)*v;");
// Check that we handle multiple trailing qualifiers and skip them all to
// determine that the expression is a cast to a pointer type.
Index: clang/lib/Format/FormatToken.h
===================================================================
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -442,7 +442,7 @@
bool canBePointerOrReferenceQualifier() const {
return isOneOf(tok::kw_const, tok::kw_restrict, tok::kw_volatile,
tok::kw___attribute, tok::kw__Nonnull, tok::kw__Nullable,
- tok::kw__Null_unspecified);
+ tok::kw__Null_unspecified, tok::kw___ptr32, tok::kw___ptr64);
}
/// Determine whether the token is a simple-type-specifier.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86775.288580.patch
Type: text/x-patch
Size: 2051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200828/9f8336c5/attachment.bin>
More information about the cfe-commits
mailing list