[clang] [analyzer][NFC] Take BugReport descriptions as Twine instead of StringRef (PR #205527)
Benedek Kaibas via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 24 04:20:57 PDT 2026
benedekaibas wrote:
This is great, thank you! I am also wondering if we want to add `getString()` method to `SVal`. If we would done that then analyzers using `SVal` could make a use of `Twine` by allowing a variable that has an `SVal` type to be printed by using `Twine`.
As an example:
```cpp
llvm::SmallString<128> Str;
llvm::raw_svector_ostream OS(Str);
OS << " Origin " << ArgSVal << " bound to " << Region;
auto BR = std::make_unique<PathSensitiveBugReport>(BugMsg, OS.str(), N);
C.emitReport(std::move(BR));
```
Could be simply written as:
```cpp
auto BR = std::make_unique<PathSensitiveBugReport>(BugMsg, llvm::Twine(" Origin ") + ArgSVal.getString() + " bound to " +
Region->getString(), N);
```
AFAIK this change would require to add `getString()` method to `SVal` similar to how `MemRegion::getString()` works. If you agree, I'd love to work on this feature.
https://github.com/llvm/llvm-project/pull/205527
More information about the cfe-commits
mailing list