miyuki updated this revision to Diff 300214.
miyuki added a comment.
Fixed linter errors.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69844/new/
https://reviews.llvm.org/D69844
Files:
clang/include/clang/Basic/SourceLocation.h
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/Basic/SourceLocation.cpp
clang/lib/StaticAnalyzer/Core/BugReporter.cpp
Index: clang/lib/StaticAnalyzer/Core/BugReporter.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2193,8 +2193,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());
}
}
@@ -2216,8 +2216,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());
}
}
Index: clang/lib/Basic/SourceLocation.cpp
===================================================================
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -15,6 +15,7 @@
#include "clang/Basic/PrettyStackTrace.h"
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/FoldingSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -45,6 +46,11 @@
return llvm::DenseMapInfo<unsigned>::getHashValue(ID);
}
+void llvm::FoldingSetTrait<SourceLocation>::Profile(
+ const SourceLocation &X, llvm::FoldingSetNodeID &ID) {
+ ID.AddInteger(X.ID);
+}
+
void SourceLocation::print(raw_ostream &OS, const SourceManager &SM)const{
if (!isValid()) {
OS << "<invalid loc>";
Index: clang/lib/Analysis/PathDiagnostic.cpp
===================================================================
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -1083,9 +1083,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(static_cast<const SourceLocation &>(Loc));
}
void PathDiagnosticPiece::Profile(llvm::FoldingSetNodeID &ID) const {
@@ -1095,8 +1095,8 @@
ID.AddInteger((unsigned) getDisplayHint());
ArrayRef<SourceRange> 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/include/clang/Basic/SourceLocation.h
===================================================================
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -26,6 +26,9 @@
template <typename T> struct DenseMapInfo;
+class FoldingSetNodeID;
+template <typename T> struct FoldingSetTrait;
+
} // namespace llvm
namespace clang {
@@ -87,6 +90,7 @@
friend class ASTReader;
friend class ASTWriter;
friend class SourceManager;
+ friend struct llvm::FoldingSetTrait<SourceLocation>;
unsigned ID = 0;
@@ -501,6 +505,11 @@
}
};
+ // Allow calling FoldingSetNodeID::Add with SourceLocation object as parameter
+ template <> struct FoldingSetTrait<clang::SourceLocation> {
+ static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
+ };
+
// Teach SmallPtrSet how to handle SourceLocation.
template<>
struct PointerLikeTypeTraits<clang::SourceLocation> {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits