[clang] cef56d5 - [clang] Change set type used for SourceLocation.
Simon Tatham via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 19 05:36:51 PDT 2021
Author: Simon Tatham
Date: 2021-07-19T13:36:36+01:00
New Revision: cef56d58dbbb3bc993531c14af5e3edd2841029d
URL: https://github.com/llvm/llvm-project/commit/cef56d58dbbb3bc993531c14af5e3edd2841029d
DIFF: https://github.com/llvm/llvm-project/commit/cef56d58dbbb3bc993531c14af5e3edd2841029d.diff
LOG: [clang] Change set type used for SourceLocation.
This is part of a patch series working towards the ability to make
SourceLocation into a 64-bit type to handle larger translation units.
If clang is built for a 32-bit platform and SourceLocation is 64 bits
wide, then a SourceLocation will be larger than a pointer, so it won't
be possible to keep them in a SmallPtrSet any more. Switch to
SmallDenseSet instead.
Patch originally by Mikhail Maltsev.
Differential Revision: https://reviews.llvm.org/D105493
Added:
Modified:
clang/include/clang/Basic/SourceLocation.h
clang/include/clang/Lex/Preprocessor.h
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h
index fc722b1d563db..0ba0f9bd3ddf2 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -16,7 +16,6 @@
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/PointerLikeTypeTraits.h"
#include <cassert>
#include <cstdint>
#include <string>
@@ -510,20 +509,6 @@ namespace llvm {
static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID);
};
- // Teach SmallPtrSet how to handle SourceLocation.
- template<>
- struct PointerLikeTypeTraits<clang::SourceLocation> {
- static constexpr int NumLowBitsAvailable = 0;
-
- static void *getAsVoidPointer(clang::SourceLocation L) {
- return L.getPtrEncoding();
- }
-
- static clang::SourceLocation getFromVoidPointer(void *P) {
- return clang::SourceLocation::getFromRawEncoding((unsigned)(uintptr_t)P);
- }
- };
-
} // namespace llvm
#endif // LLVM_CLANG_BASIC_SOURCELOCATION_H
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index be345d4f5b4ea..7ab13640ce2c0 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -783,8 +783,7 @@ class Preprocessor {
/// deserializing from PCH, we don't need to deserialize identifier & macros
/// just so that we can report that they are unused, we just warn using
/// the SourceLocations of this set (that will be filled by the ASTReader).
- /// We are using SmallPtrSet instead of a vector for faster removal.
- using WarnUnusedMacroLocsTy = llvm::SmallPtrSet<SourceLocation, 32>;
+ using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>;
WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
/// A "freelist" of MacroArg objects that can be
More information about the cfe-commits
mailing list