This allows us to create other types of tags that carry useful
bits of information alongside.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | ||
---|---|---|
777 | It sounds like NoteTag isn't<DataTag> despite inheriting from it. |
P.S. I like this design!
I'm trying to remember why we needed a factory in the first place. I think a lot of tags work just fine as static variables. In case of D104136 IIUC IdentityCall could always be discovered as the current program point and its Source is its only argument so all we need is a marker that says "we did indeed model this code as identity" so it could potentially be allocated statically. But when the tag really needs to carry more data then there's probably no way around the factory.
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | ||
---|---|---|
777 | Wait nvm, DataTag doesn't provide a classof at all. This means we can't write isa<DataTag> at all, right? |
Who's gonna carry your callbacks for ya, huh?
I think a lot of tags work just fine as static variables.
Sure, but if you have data, let's say it's something that doesn't need to be stored somewhere to prolong its lifetime, you still need to have static variable for each possible value of that piece of data. Not really feasible in the vast majority of cases. Because you might need to refer to the same tag with different possible values.
In case of D104136 IIUC IdentityCall could always be discovered as the current program point...
That's true, I put this one as "just in case".
...and its Source is its only argument...
Not really, there is also case when the call is IdentityThis, so its Source is not its only argument.
...so all we need is a marker that says "we did indeed model this code as identity" so it could potentially be allocated statically. But when the tag really needs to carry more data then there's probably no way around the factory.
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | ||
---|---|---|
777 | Yes, it's purely abstract. ProgramPointTag also doesn't have classof |
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | ||
---|---|---|
777 | Something being purely abstract isn't a problem on its own; there are a lot of abstract classes that implement classof(), such as Expr. It's more of an artifact of the current implementation strategy. Ok np though, this doesn't seem to be a real problem. |
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h | ||
---|---|---|
777 | That's true. And considering that we want different checkers to implement this on their own, we probably don't want to have one central enum listing all possible subtypes so that we can isa non-leaf types. |
clang-format: please reformat the code