[clang] [analyzer] Fix truncation of ranges wider than 64 bits (PR #239147)

via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 7 06:40:37 PST 2026


relaxcn wrote:

> > > I suppose this patch was motivated by a real-world use case, so I wonder if we should add that to the LIT tests?
> > 
> > 
> > Yes. We have a lit test in downstream but the feature which triggers the bug doesn't exist in the upstream.
> > We implemented the `VisitSymbolCast` method in downstream:
> > ```c++
> > RangeSet VisitSymbolCast(const SymbolCast *Sym) {
> >   return RangeFactory.castTo(infer(Sym->getOperand()),
> >                              ValueFactory.getAPSIntType(Sym->getType()));
> > }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > Considering the `unsigned __int128 -> unsigned long`, it triggers this bug.
> > So for this patch, there is no lit test which could really trigger this bug. The only behavior of the usage in the current code is casting to the wider of the two operand types and never truncates so this bug would never occur. - just like I said in the desc of the PR.
> 
> Oh, so you have downstream Core patches. That's interesting. Do you have any plans for upstreaming those? Usually downstream folks don't really want to diverge much with Core patches because those can have a broad impact and source of divergence.

We have made many changes and modifications between the upstream including the core engine, checker framework, model summarization instead of model injector(many bugs and lacking maintenance) and so on.

But you are right. It changes too much that it's hard to be accepted by upstream. So currently we don't have a plan to post a RFC or a big patch. Bug I think we could fix some existing bugs during our developments downstream. :)

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


More information about the cfe-commits mailing list