File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -2633,12 +2633,20 @@ class AnnotatingParser {
26332633 PreviousNotConst->MatchingParen ->Previous ->isNot (tok::kw_template);
26342634 }
26352635
2636- if ((PreviousNotConst->is (tok::r_paren) &&
2637- PreviousNotConst->is (TT_TypeDeclarationParen)) ||
2638- PreviousNotConst->is (TT_AttributeRParen)) {
2636+ if (PreviousNotConst->is (tok::r_paren) &&
2637+ PreviousNotConst->is (TT_TypeDeclarationParen)) {
26392638 return true ;
26402639 }
26412640
2641+ auto InTypeDecl = [&]() {
2642+ for (auto Next = Tok.Next ; Next; Next = Next->Next )
2643+ if (Next->isOneOf (TT_ClassLBrace, TT_StructLBrace))
2644+ return true ;
2645+ return false ;
2646+ };
2647+ if (PreviousNotConst->is (TT_AttributeRParen) && (!IsCpp || !InTypeDecl ()))
2648+ return true ;
2649+
26422650 // If is a preprocess keyword like #define.
26432651 if (IsPPKeyword)
26442652 return false ;
Original file line number Diff line number Diff line change @@ -12415,6 +12415,18 @@ TEST_F(FormatTest, UnderstandsAttributes) {
1241512415 verifyFormat("SomeType s __unused{InitValue};", CustomAttrs);
1241612416 verifyFormat("SomeType *__capability s(InitValue);", CustomAttrs);
1241712417 verifyFormat("SomeType *__capability s{InitValue};", CustomAttrs);
12418+
12419+ FormatStyle Style = getLLVMStyle(FormatStyle::LK_Cpp);
12420+ verifyFormat(
12421+ "template <>\n"
12422+ "struct __declspec(uuid(\"3895C200-8F26-4F5A-B29D-2B5D72E68F99\"))\n"
12423+ "IAsyncOperation<IUnknown *> : IAsyncOperation_impl<IUnknown *> {};",
12424+ Style);
12425+ verifyFormat(
12426+ "template <>\n"
12427+ "class __declspec(uuid(\"3895C200-8F26-4F5A-B29D-2B5D72E68F99\"))\n"
12428+ "IAsyncOperation<IUnknown *> : IAsyncOperation_impl<IUnknown *> {};",
12429+ Style);
1241812430}
1241912431
1242012432TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {
You can’t perform that action at this time.
0 commit comments