[clang] [clang-format] Remove obsolete code (PR #220080)

Björn Schäpers via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 23 12:46:34 PDT 2026


HazardyKnusperkeks wrote:

> > I would do this instead:
> > ```diff
> > --- a/clang/lib/Format/TokenAnnotator.cpp
> > +++ b/clang/lib/Format/TokenAnnotator.cpp
> > @@ -2336,7 +2336,7 @@ private:
> >        for (FormatToken *Previous = Current.Previous;
> >             Previous && Previous->isOneOf(tok::star, tok::amp);
> >             Previous = Previous->Previous) {
> > -        Previous->setType(TT_PointerOrReference);
> > +        Previous->setFinalizedType(TT_PointerOrReference);
> >        }
> >        if (Line.MustBeDeclaration &&
> >            Contexts.front().ContextType != Context::CtorInitializer) {
> > ```
> > 
> >   
> > IMO, this is more conservative and serves a catch-all for uncovered edge cases.
> 
> Also, it would obsolete #212856, which caused the regression in #222132.

I don't like the idea of code which is not used/necessary for any of our tests to pass. And while there are still some cases not covered, I think we have a good base for annotating those tokens.

This code was useful at some point, but I think it became obsolete and no one registered it. In this case we have invalid/incomplete code, but there's no real chance that these already annotated tokens would be pointers, so overwriting that seems like a bad idea to me.

https://github.com/llvm/llvm-project/pull/220080


More information about the cfe-commits mailing list