[clang] [SSAF] Let UnsafeBufferUsageExtractor & PointerFlowExtractor ignore templates (PR #198927)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Fri May 29 16:59:51 PDT 2026


ziqingluo-90 wrote:

> It would be nice if we just skipped dependent expressions rather than disregarding the entire thing, and I'd also like to include a test to ensure that we don't skip diagnostics when a function in a dependent context is not actually dependent, 
> and the other tests being added should also verify instantiation produces diagnostics.

@ojhunt As background, these `Extractor` classes are not for a specific diagnostic or analysis. Their duty is to collect facts about specific aspects of the source code. Those facts may be used by various clients, e.g., analyzers or source-code editing tools. In addition, this is a part of the SSAF framework, which analyzes the entire project(s) as its "whole world".

Under this assumption, my opinion is that we do not reason about properties of the template itself but of all of its instantiations. A rough analogy is reasoning about `Forall T. P(T)` vs. `Forall T in {a, b, ...}. P(T)`, where `{a, b, ...}` is the finite set of concrete types with which `T` is instantiated.  Since the instantiations are collected from the "whole world", the latter is sufficient and simple to reason about.

WDYT?




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


More information about the cfe-commits mailing list