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; Index: clang/lib/Analysis/PathDiagnostic.cpp =================================================================== --- clang/lib/Analysis/PathDiagnostic.cpp +++ clang/lib/Analysis/PathDiagnostic.cpp @@ -1067,9 +1067,9 @@ //===----------------------------------------------------------------------===// void PathDiagnosticLocation::Profile(llvm::FoldingSetNodeID &ID) const { - ID.AddInteger(Range.getBegin().getRawEncoding()); - ID.AddInteger(Range.getEnd().getRawEncoding()); - ID.AddInteger(Loc.getRawEncoding()); + ID.Add(Range.getBegin()); + ID.Add(Range.getEnd()); + ID.Add(Loc); } void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID &ID) const { @@ -1079,8 +1079,8 @@ ID.AddInteger((unsigned) getDisplayHint()); ArrayRef Ranges = getRanges(); for (const auto &I : Ranges) { - ID.AddInteger(I.getBegin().getRawEncoding()); - ID.AddInteger(I.getEnd().getRawEncoding()); + ID.Add(I.getBegin()); + ID.Add(I.getEnd()); } } 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,6 +75,10 @@ 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'; Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp =================================================================== --- clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2144,8 +2144,8 @@ for (SourceRange range : Ranges) { if (!range.isValid()) continue; - hash.AddInteger(range.getBegin().getRawEncoding()); - hash.AddInteger(range.getEnd().getRawEncoding()); + hash.Add(range.getBegin()); + hash.Add(range.getEnd()); } } @@ -2167,8 +2167,8 @@ for (SourceRange range : Ranges) { if (!range.isValid()) continue; - hash.AddInteger(range.getBegin().getRawEncoding()); - hash.AddInteger(range.getEnd().getRawEncoding()); + hash.Add(range.getBegin()); + hash.Add(range.getEnd()); } }