forked from OSchip/llvm-project
[clang-format] Parse restrict as a pointer qualifier
Before: void f() { MACRO(A * restrict a); } After: void f() { MACRO(A *restrict a); } Also check that the __restrict and __restrict__ aliases are handled. Reviewed By: JakeMerdichAMD Differential Revision: https://reviews.llvm.org/D86710
This commit is contained in:
parent
1908da2658
commit
4f10369564
|
@ -2739,6 +2739,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) {
|
|||
LangOpts.ObjC = 1;
|
||||
LangOpts.MicrosoftExt = 1; // To get kw___try, kw___finally.
|
||||
LangOpts.DeclSpecKeyword = 1; // To get __declspec.
|
||||
LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict.
|
||||
return LangOpts;
|
||||
}
|
||||
|
||||
|
|
|
@ -1891,7 +1891,8 @@ private:
|
|||
const FormatToken *NextToken = Tok.getNextNonComment();
|
||||
if (!NextToken ||
|
||||
NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
|
||||
tok::kw_volatile, tok::kw_noexcept) ||
|
||||
tok::kw_restrict, tok::kw_volatile,
|
||||
tok::kw_noexcept) ||
|
||||
(NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
|
||||
return TT_PointerOrReference;
|
||||
|
||||
|
|
|
@ -8053,6 +8053,9 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
|
|||
verifyIndependentOfContext("MACRO(auto *a);");
|
||||
verifyIndependentOfContext("MACRO(const A *a);");
|
||||
verifyIndependentOfContext("MACRO(A *const a);");
|
||||
verifyIndependentOfContext("MACRO(A *restrict a);");
|
||||
verifyIndependentOfContext("MACRO(A *__restrict__ a);");
|
||||
verifyIndependentOfContext("MACRO(A *__restrict a);");
|
||||
verifyIndependentOfContext("MACRO(A *volatile a);");
|
||||
verifyIndependentOfContext("MACRO(A *__volatile a);");
|
||||
verifyIndependentOfContext("MACRO(A *__volatile__ a);");
|
||||
|
|
Loading…
Reference in New Issue