File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -615,11 +615,25 @@ SourceRange getDeclSourceRangeWithAnnotations(
615
615
SR = VD->DeclaratorDecl ::getSourceRange ();
616
616
else
617
617
SR = D->getSourceRange ();
618
- SourceLocation OldEnd = SR.getEnd ();
618
+ if (!SR.isValid ())
619
+ return SR;
620
+ SourceLocation DeclEnd = SR.getEnd ();
621
+
622
+ // Partial workaround for a compiler bug where if D has certain checked
623
+ // pointer types such as `_Ptr<int *(void)>` (seen in the partial_checked.c
624
+ // regression test), D->getSourceRange() returns only the _Ptr token (TODO:
625
+ // file an issue). Always extend the range at least through the name (given by
626
+ // D->getLocation()). That fixes the `_Ptr<int *(void)> x` case but not cases
627
+ // with additional syntax after the name, such as `_Ptr<int *(void)> x[10]`.
628
+ SourceLocation DeclLoc = D->getLocation ();
629
+ if (SM.isBeforeInTranslationUnit (DeclEnd, DeclLoc))
630
+ DeclEnd = DeclLoc;
631
+
619
632
SourceLocation AnnotationsEnd = getCheckedCAnnotationsEnd (D);
620
633
if (AnnotationsEnd.isValid () &&
621
- (!OldEnd.isValid () ||
622
- SM.isBeforeInTranslationUnit (OldEnd, AnnotationsEnd)))
623
- SR.setEnd (AnnotationsEnd);
634
+ SM.isBeforeInTranslationUnit (DeclEnd, AnnotationsEnd))
635
+ DeclEnd = AnnotationsEnd;
636
+
637
+ SR.setEnd (DeclEnd);
624
638
return SR;
625
639
}
You can’t perform that action at this time.
0 commit comments