From cef56d58dbbb3bc993531c14af5e3edd2841029d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 19 Jul 2021 11:45:46 +0100 Subject: [PATCH] [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 --- clang/include/clang/Basic/SourceLocation.h | 15 --------------- clang/include/clang/Lex/Preprocessor.h | 3 +-- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/clang/include/clang/Basic/SourceLocation.h b/clang/include/clang/Basic/SourceLocation.h index fc722b1d563d..0ba0f9bd3ddf 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 #include #include @@ -510,20 +509,6 @@ namespace llvm { static void Profile(const clang::SourceLocation &X, FoldingSetNodeID &ID); }; - // Teach SmallPtrSet how to handle SourceLocation. - template<> - struct PointerLikeTypeTraits { - 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 be345d4f5b4e..7ab13640ce2c 100644 --- a/clang/include/clang/Lex/Preprocessor.h +++ b/clang/include/clang/Lex/Preprocessor.h @@ -783,8 +783,7 @@ private: /// 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; + using WarnUnusedMacroLocsTy = llvm::SmallDenseSet; WarnUnusedMacroLocsTy WarnUnusedMacroLocs; /// A "freelist" of MacroArg objects that can be