aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceLocation.cpp
diff options
context:
space:
mode:
authorMikhail Maltsev <mikhail.maltsev@arm.com>2020-10-27 10:43:39 +0000
committerMikhail Maltsev <mikhail.maltsev@arm.com>2020-10-27 10:43:39 +0000
commit443ab4d2e01246bf93cd410db945dc9ab6adf1b3 (patch)
tree9766664b618f1103807f289fecdfc6b3e8b313f0 /clang/lib/Basic/SourceLocation.cpp
parentf855a553339aa78225a309a6f9b5fcae767de8da (diff)
downloadllvm-443ab4d2e01246bf93cd410db945dc9ab6adf1b3.zip
llvm-443ab4d2e01246bf93cd410db945dc9ab6adf1b3.tar.gz
llvm-443ab4d2e01246bf93cd410db945dc9ab6adf1b3.tar.bz2
[clang][Basic] Integrate SourceLocation with FoldingSet, NFCI
This patch removes the necessity to access the SourceLocation internal representation in several places that use FoldingSet objects. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D69844
Diffstat (limited to 'clang/lib/Basic/SourceLocation.cpp')
-rw-r--r--clang/lib/Basic/SourceLocation.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp
index 2ff1797..fde1399 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/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 @@ unsigned SourceLocation::getHashValue() const {
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>";