Index: clang/include/clang/Basic/SourceLocation.h =================================================================== --- clang/include/clang/Basic/SourceLocation.h +++ clang/include/clang/Basic/SourceLocation.h @@ -26,6 +26,8 @@ template struct DenseMapInfo; +class FoldingSetNodeID; + } // namespace llvm namespace clang { @@ -179,6 +181,9 @@ return ID * 37U; } + /// Write this source location to a FoldingSetNodeID + void Profile(llvm::FoldingSetNodeID &Node) const; + void print(raw_ostream &OS, const SourceManager &SM) const; std::string printToString(const SourceManager &SM) const; void dump(const SourceManager &SM) const; @@ -239,6 +244,9 @@ return B <= other.B && E >= other.E; } + /// Write this source range to a FoldingSetNodeID + void Profile(llvm::FoldingSetNodeID &Node) const; + void print(raw_ostream &OS, const SourceManager &SM) const; std::string printToString(const SourceManager &SM) const; void dump(const SourceManager &SM) const; Index: clang/lib/Analysis/PathDiagnostic.cpp =================================================================== --- clang/lib/Analysis/PathDiagnostic.cpp +++ clang/lib/Analysis/PathDiagnostic.cpp @@ -1067,9 +1067,8 @@ //===----------------------------------------------------------------------===// void PathDiagnosticLocation::Profile(llvm::FoldingSetNodeID &ID) const { - ID.AddInteger(Range.getBegin().getRawEncoding()); - ID.AddInteger(Range.getEnd().getRawEncoding()); - ID.AddInteger(Loc.getRawEncoding()); + ID.Add(Range); + ID.Add(Loc); } void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID &ID) const { @@ -1078,10 +1077,8 @@ // FIXME: Add profiling support for code hints. ID.AddInteger((unsigned) getDisplayHint()); ArrayRef Ranges = getRanges(); - for (const auto &I : Ranges) { - ID.AddInteger(I.getBegin().getRawEncoding()); - ID.AddInteger(I.getEnd().getRawEncoding()); - } + for (const auto &I : Ranges) + ID.Add(I); } void PathDiagnosticCallPiece::Profile(llvm::FoldingSetNodeID &ID) const { Index: clang/lib/Basic/SourceLocation.cpp =================================================================== --- clang/lib/Basic/SourceLocation.cpp +++ clang/lib/Basic/SourceLocation.cpp @@ -14,6 +14,7 @@ #include "clang/Basic/LLVM.h" #include "clang/Basic/PrettyStackTrace.h" #include "clang/Basic/SourceManager.h" +#include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/MemoryBuffer.h" @@ -74,11 +75,20 @@ return OS.str(); } +void SourceLocation::Profile(llvm::FoldingSetNodeID &Node) const { + Node.AddInteger(ID); +} + LLVM_DUMP_METHOD void SourceLocation::dump(const SourceManager &SM) const { print(llvm::errs(), SM); llvm::errs() << '\n'; } +void SourceRange::Profile(llvm::FoldingSetNodeID &Node) const { + B.Profile(Node); + E.Profile(Node); +} + LLVM_DUMP_METHOD void SourceRange::dump(const SourceManager &SM) const { print(llvm::errs(), SM); llvm::errs() << '\n'; Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2144,8 +2144,7 @@ for (SourceRange range : Ranges) { if (!range.isValid()) continue; - hash.AddInteger(range.getBegin().getRawEncoding()); - hash.AddInteger(range.getEnd().getRawEncoding()); + hash.Add(range); } } @@ -2167,8 +2166,7 @@ for (SourceRange range : Ranges) { if (!range.isValid()) continue; - hash.AddInteger(range.getBegin().getRawEncoding()); - hash.AddInteger(range.getEnd().getRawEncoding()); + hash.Add(range); } }