[PATCH] D69844: [clang][Basic] Integrate SourceLocation with FoldingSet, NFCI
Mikhail Maltsev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 26 06:57:12 PDT 2020
miyuki added inline comments.
================
Comment at: clang/lib/Analysis/PathDiagnostic.cpp:1088
+ ID.Add(Range.getEnd());
+ ID.Add(static_cast<const SourceLocation &>(Loc));
}
----------------
dexonsmith wrote:
> I'm surprised you need this `static_cast`, can you explain why it was necessary?
`Loc` is an object of type `FullSourceLoc`, a class derived from `SourceLocation`. When the `FoldingSetNodeID::Add` template method is called with `Loc` it tries to instantiate `FoldingSetTrait<FullSourceLoc>` and fails (because there is no explicit specialization for `FullSourceLoc` and the default one relies on the method `FullSourceLoc::Profile` which does not exist). `FullSourceLoc` does not contain any additional information about the location itself (it just holds a pointer to the associated `SourceManager`), so there is no need to specialize `FoldingSetTrait` for it, and casting to `SourceLocation` will make `FoldingSetNodeID::Add` use the correct `FoldingSetTrait` specialization.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69844/new/
https://reviews.llvm.org/D69844
More information about the cfe-commits
mailing list