aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp b/contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp
index c1fa406909fe..6f6412028d77 100644
--- a/contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,8 @@
#include "clang/Basic/LLVM.h"
#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"
@@ -40,6 +42,23 @@ void PrettyStackTraceLoc::print(raw_ostream &OS) const {
// SourceLocation
//===----------------------------------------------------------------------===//
+static_assert(std::is_trivially_destructible<SourceLocation>::value,
+ "SourceLocation must be trivially destructible because it is "
+ "used in unions");
+
+static_assert(std::is_trivially_destructible<SourceRange>::value,
+ "SourceRange must be trivially destructible because it is "
+ "used in unions");
+
+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>";
@@ -245,7 +264,7 @@ const char *FullSourceLoc::getCharacterData(bool *Invalid) const {
StringRef FullSourceLoc::getBufferData(bool *Invalid) const {
assert(isValid());
- return SrcMgr->getBuffer(SrcMgr->getFileID(*this), Invalid)->getBuffer();
+ return SrcMgr->getBufferData(SrcMgr->getFileID(*this), Invalid);
}
std::pair<FileID, unsigned> FullSourceLoc::getDecomposedLoc() const {