aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/SourceLocation.cpp
diff options
context:
space:
mode:
authorMikhail Maltsev <mikhail.maltsev@arm.com>2021-01-22 13:01:41 +0000
committerMikhail Maltsev <mikhail.maltsev@arm.com>2021-01-22 13:01:41 +0000
commita0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2 (patch)
tree00b6533879c488ee930e8529da7a52ccede17f72 /clang/lib/Basic/SourceLocation.cpp
parente16959c9b8553a60ec5e9aa55d101154d5805292 (diff)
downloadllvm-a0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2.zip
llvm-a0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2.tar.gz
llvm-a0e30914f8c8bb60795a008ce2d9e3c0a4f9b7a2.tar.bz2
[clang][Tooling] Get rid of a hack in SymbolOccurrences, NFCI
The class `SymbolOccurrences` can store either a single `SourceRange` in-place or multiple `SourceRanges` on the heap. In the latter case the number of source ranges is stored in the internal representation of the beginning `SourceLocation` of the in-place `SourceRange` object. This change gets rid of such hack by placing `SourceRange` in a union which holds either a valid `SourceRange` or an `unsigned int` (a number of ranges). The change also adds `static_assert`s that check that `SourceRange` and `SourceLocation` are trivially destructible (this is required for the current patch and for D94237 which has already been committed). Reviewed By: MarkMurrayARM, simon_tatham Differential Revision: https://reviews.llvm.org/D94599
Diffstat (limited to 'clang/lib/Basic/SourceLocation.cpp')
-rw-r--r--clang/lib/Basic/SourceLocation.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/Basic/SourceLocation.cpp b/clang/lib/Basic/SourceLocation.cpp
index fde1399..6f64120 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/lib/Basic/SourceLocation.cpp
@@ -42,6 +42,14 @@ 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);
}