[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
This commit is contained in:
Simon Tatham 2021-07-19 11:45:46 +01:00
parent 58ddeba3e0
commit cef56d58db
2 changed files with 1 additions and 17 deletions

View File

@ -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

View File

@ -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<SourceLocation, 32>;
using WarnUnusedMacroLocsTy = llvm::SmallDenseSet<SourceLocation, 32>;
WarnUnusedMacroLocsTy WarnUnusedMacroLocs;
/// A "freelist" of MacroArg objects that can be