Index: clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h =================================================================== --- clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h +++ clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.h @@ -11,7 +11,7 @@ #include "../ClangTidy.h" -#include +#include "llvm/ADT/DenseSet.h" namespace clang { namespace tidy { @@ -32,7 +32,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - std::unordered_set MatchedTemplateLocations; + llvm::DenseSet MatchedTemplateLocations; }; } // namespace abseil Index: clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp +++ clang-tools-extra/clang-tidy/abseil/UpgradeDurationConversionsCheck.cpp @@ -123,7 +123,7 @@ if (!match(isInTemplateInstantiation(), *OuterExpr, *Result.Context) .empty()) { - if (MatchedTemplateLocations.count(Loc.getRawEncoding()) == 0) { + if (MatchedTemplateLocations.count(Loc) == 0) { // For each location matched in a template instantiation, we check if the // location can also be found in `MatchedTemplateLocations`. If it is not // found, that means the expression did not create a match without the @@ -139,7 +139,7 @@ internal::Matcher IsInsideTemplate = hasAncestor(decl(anyOf(classTemplateDecl(), functionTemplateDecl()))); if (!match(IsInsideTemplate, *ArgExpr, *Result.Context).empty()) - MatchedTemplateLocations.insert(Loc.getRawEncoding()); + MatchedTemplateLocations.insert(Loc); DiagnosticBuilder Diag = diag(Loc, Message); CharSourceRange SourceRange = Lexer::makeFileCharRange( Index: clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h +++ clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h @@ -74,15 +74,13 @@ clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId; static inline ClassDefId getEmptyKey() { - return ClassDefId( - clang::SourceLocation::getFromRawEncoding(static_cast(-1)), - "EMPTY"); + return ClassDefId(DenseMapInfo::getEmptyKey(), + "EMPTY"); } static inline ClassDefId getTombstoneKey() { - return ClassDefId( - clang::SourceLocation::getFromRawEncoding(static_cast(-2)), - "TOMBSTONE"); + return ClassDefId(DenseMapInfo::getTombstoneKey(), + "TOMBSTONE"); } static unsigned getHashValue(ClassDefId Val) { @@ -90,7 +88,7 @@ assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!"); std::hash SecondHash; - return Val.first.getRawEncoding() + SecondHash(Val.second); + return Val.first.getHashValue() + SecondHash(Val.second); } static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) { Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h =================================================================== --- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h +++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h @@ -33,7 +33,7 @@ void check(const ast_matchers::MatchFinder::MatchResult &Result) override; private: - llvm::DenseSet MatchedTemplateLocations; + llvm::DenseSet MatchedTemplateLocations; }; } // namespace google Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp +++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp @@ -296,8 +296,7 @@ } if (IsInInstantiation) { - if (MatchedTemplateLocations.count( - ReplacementRange.getBegin().getRawEncoding()) == 0) { + if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) { // For each location matched in a template instantiation, we check if // the location can also be found in `MatchedTemplateLocations`. If it // is not found, that means the expression did not create a match @@ -311,8 +310,7 @@ if (IsInTemplate) { // We gather source locations from template matches not in template // instantiations for future matches. - MatchedTemplateLocations.insert( - ReplacementRange.getBegin().getRawEncoding()); + MatchedTemplateLocations.insert(ReplacementRange.getBegin()); } if (!AddFix) { Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h =================================================================== --- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h +++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h @@ -89,9 +89,8 @@ ShouldFixStatus FixStatus = ShouldFixStatus::ShouldFix; - /// A set of all the identifier usages starting SourceLocation, in - /// their encoded form. - llvm::DenseSet RawUsageLocs; + /// A set of all the identifier usages starting SourceLocation. + llvm::DenseSet RawUsageLocs; NamingCheckFailure() = default; }; Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -30,13 +30,13 @@ static inline NamingCheckId getEmptyKey() { return NamingCheckId( - clang::SourceLocation::getFromRawEncoding(static_cast(-1)), + DenseMapInfo::getEmptyKey(), "EMPTY"); } static inline NamingCheckId getTombstoneKey() { return NamingCheckId( - clang::SourceLocation::getFromRawEncoding(static_cast(-2)), + DenseMapInfo::getTombstoneKey(), "TOMBSTONE"); } @@ -45,7 +45,8 @@ assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!"); std::hash SecondHash; - return Val.first.getRawEncoding() + SecondHash(Val.second); + return DenseMapInfo::getHashValue(Val.first) + + SecondHash(Val.second); } static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) { @@ -149,7 +150,7 @@ // Try to insert the identifier location in the Usages map, and bail out if it // is already in there RenamerClangTidyCheck::NamingCheckFailure &Failure = Failures[Decl]; - if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second) + if (!Failure.RawUsageLocs.insert(FixLocation).second) return; if (!Failure.ShouldFix()) @@ -408,7 +409,7 @@ // Other multi-token identifiers, such as operators are not checked at // all. Diag << FixItHint::CreateReplacement( - SourceRange(SourceLocation::getFromRawEncoding(Loc)), + SourceRange(Loc), Failure.Info.Fixup); } } Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -792,7 +792,7 @@ } bool VisitTypeLoc(TypeLoc TTL) { - if (TypeLocsToSkip.count(TTL.getBeginLoc().getRawEncoding())) + if (TypeLocsToSkip.count(TTL.getBeginLoc())) return true; visitNode(DynTypedNode::create(TTL)); return true; @@ -802,7 +802,7 @@ // ElaboratedTypeLoc will reports information for its inner type loc. // Otherwise we loose information about inner types loc's qualifier. TypeLoc Inner = L.getNamedTypeLoc().getUnqualifiedLoc(); - TypeLocsToSkip.insert(Inner.getBeginLoc().getRawEncoding()); + TypeLocsToSkip.insert(Inner.getBeginLoc()); return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L); } @@ -866,7 +866,7 @@ visitNode(DynTypedNode::create(L)); // Inner type is missing information about its qualifier, skip it. if (auto TL = L.getTypeLoc()) - TypeLocsToSkip.insert(TL.getBeginLoc().getRawEncoding()); + TypeLocsToSkip.insert(TL.getBeginLoc()); return RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(L); } @@ -939,7 +939,7 @@ llvm::function_ref Out; /// TypeLocs starting at these locations must be skipped, see /// TraverseElaboratedTypeSpecifierLoc for details. - llvm::DenseSet TypeLocsToSkip; + llvm::DenseSet TypeLocsToSkip; }; } // namespace Index: clang/include/clang/Basic/SourceLocation.h =================================================================== --- clang/include/clang/Basic/SourceLocation.h +++ clang/include/clang/Basic/SourceLocation.h @@ -175,6 +175,10 @@ End.isFileID(); } + unsigned getHashValue() const { + return ID * 37U; + } + void print(raw_ostream &OS, const SourceManager &SM) const; std::string printToString(const SourceManager &SM) const; void dump(const SourceManager &SM) const; @@ -479,6 +483,28 @@ } }; + /// Define DenseMapInfo so that SourceLocation's can be used as keys in + /// DenseMap and DenseSet. This trait class is eqivalent to + /// DenseMapInfo which uses SourceLocation::ID is used as a key. + template <> + struct DenseMapInfo { + static clang::SourceLocation getEmptyKey() { + return clang::SourceLocation::getFromRawEncoding(~0U); + } + + static clang::SourceLocation getTombstoneKey() { + return clang::SourceLocation::getFromRawEncoding(~0U - 1); + } + + static unsigned getHashValue(clang::SourceLocation Loc) { + return Loc.getHashValue(); + } + + static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS) { + return LHS == RHS; + } + }; + // Teach SmallPtrSet how to handle SourceLocation. template<> struct PointerLikeTypeTraits { Index: clang/include/clang/Edit/EditedSource.h =================================================================== --- clang/include/clang/Edit/EditedSource.h +++ clang/include/clang/Edit/EditedSource.h @@ -62,7 +62,7 @@ } }; - llvm::DenseMap> ExpansionToArgMap; + llvm::DenseMap> ExpansionToArgMap; SmallVector, 2> CurrCommitMacroArgExps; Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -12201,7 +12201,7 @@ static unsigned getHashValue(const FunctionDeclAndLoc &FDL) { return hash_combine(FDBaseInfo::getHashValue(FDL.FD), - FDL.Loc.getRawEncoding()); + FDL.Loc.getHashValue()); } static bool isEqual(const FunctionDeclAndLoc &LHS, Index: clang/include/clang/Tooling/Syntax/Tokens.h =================================================================== --- clang/include/clang/Tooling/Syntax/Tokens.h +++ clang/include/clang/Tooling/Syntax/Tokens.h @@ -383,7 +383,7 @@ /// the stack) and not when they end (when we pop a macro from the stack). /// To workaround this limitation, we rely on source location information /// stored in this map. - using PPExpansions = llvm::DenseMap; + using PPExpansions = llvm::DenseMap; class Builder; class CollectPPExpansions; Index: clang/lib/ARCMigrate/TransGCAttrs.cpp =================================================================== --- clang/lib/ARCMigrate/TransGCAttrs.cpp +++ clang/lib/ARCMigrate/TransGCAttrs.cpp @@ -88,8 +88,8 @@ return false; SourceLocation Loc = OwnershipAttr->getLocation(); - unsigned RawLoc = Loc.getRawEncoding(); - if (MigrateCtx.AttrSet.count(RawLoc)) + SourceLocation OrigLoc = Loc; + if (MigrateCtx.AttrSet.count(OrigLoc)) return true; ASTContext &Ctx = MigrateCtx.Pass.Ctx; @@ -105,7 +105,7 @@ else return false; - MigrateCtx.AttrSet.insert(RawLoc); + MigrateCtx.AttrSet.insert(OrigLoc); MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence()); MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back(); @@ -204,7 +204,7 @@ if (!canApplyWeak(MigrateCtx.Pass.Ctx, Attr.ModifiedType, /*AllowOnUnknownClass=*/true)) { Transaction Trans(TA); - if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc.getRawEncoding())) + if (!MigrateCtx.RemovedAttrSet.count(Attr.Loc)) TA.replaceText(Attr.Loc, "__weak", "__unsafe_unretained"); TA.clearDiagnostic(diag::err_arc_weak_no_runtime, diag::err_arc_unsupported_weak_class, @@ -263,7 +263,7 @@ if (GCAttrsCollector::hasObjCImpl( cast(IndProps.front()->getDeclContext()))) { if (hasWeak) - MigrateCtx.AtPropsWeak.insert(AtLoc.getRawEncoding()); + MigrateCtx.AtPropsWeak.insert(AtLoc); } else { StringRef toAttr = "strong"; @@ -290,14 +290,14 @@ TA.clearDiagnostic(diag::err_objc_property_attr_mutually_exclusive, AtLoc); TA.clearDiagnostic(diag::err_arc_inconsistent_property_ownership, ATLs[i].second->getLocation()); - MigrateCtx.RemovedAttrSet.insert(Loc.getRawEncoding()); + MigrateCtx.RemovedAttrSet.insert(Loc); } } static void checkAllProps(MigrationContext &MigrateCtx, std::vector &AllProps) { typedef llvm::TinyPtrVector IndivPropsTy; - llvm::DenseMap AtProps; + llvm::DenseMap AtProps; for (unsigned i = 0, e = AllProps.size(); i != e; ++i) { ObjCPropertyDecl *PD = AllProps[i]; @@ -307,14 +307,12 @@ SourceLocation AtLoc = PD->getAtLoc(); if (AtLoc.isInvalid()) continue; - unsigned RawAt = AtLoc.getRawEncoding(); - AtProps[RawAt].push_back(PD); + AtProps[AtLoc].push_back(PD); } } - for (llvm::DenseMap::iterator - I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { - SourceLocation AtLoc = SourceLocation::getFromRawEncoding(I->first); + for (auto I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { + SourceLocation AtLoc = I->first; IndivPropsTy &IndProps = I->second; checkAllAtProps(MigrateCtx, AtLoc, IndProps); } Index: clang/lib/ARCMigrate/TransProperties.cpp =================================================================== --- clang/lib/ARCMigrate/TransProperties.cpp +++ clang/lib/ARCMigrate/TransProperties.cpp @@ -65,7 +65,7 @@ }; typedef SmallVector PropsTy; - typedef std::map AtPropDeclsTy; + typedef std::map AtPropDeclsTy; AtPropDeclsTy AtProps; llvm::DenseMap ActionOnProp; @@ -76,13 +76,13 @@ static void collectProperties(ObjCContainerDecl *D, AtPropDeclsTy &AtProps, AtPropDeclsTy *PrevAtProps = nullptr) { for (auto *Prop : D->instance_properties()) { - if (Prop->getAtLoc().isInvalid()) + SourceLocation Loc = Prop->getAtLoc(); + if (Loc.isInvalid()) continue; - unsigned RawLoc = Prop->getAtLoc().getRawEncoding(); if (PrevAtProps) - if (PrevAtProps->find(RawLoc) != PrevAtProps->end()) + if (PrevAtProps->find(Loc) != PrevAtProps->end()) continue; - PropsTy &props = AtProps[RawLoc]; + PropsTy &props = AtProps[Loc]; props.push_back(Prop); } } @@ -113,8 +113,7 @@ ObjCIvarDecl *ivarD = implD->getPropertyIvarDecl(); if (!ivarD || ivarD->isInvalidDecl()) continue; - unsigned rawAtLoc = propD->getAtLoc().getRawEncoding(); - AtPropDeclsTy::iterator findAtLoc = AtProps.find(rawAtLoc); + AtPropDeclsTy::iterator findAtLoc = AtProps.find(propD->getAtLoc()); if (findAtLoc == AtProps.end()) continue; @@ -130,7 +129,7 @@ for (AtPropDeclsTy::iterator I = AtProps.begin(), E = AtProps.end(); I != E; ++I) { - SourceLocation atLoc = SourceLocation::getFromRawEncoding(I->first); + SourceLocation atLoc = I->first; PropsTy &props = I->second; if (!getPropertyType(props)->isObjCRetainableType()) continue; @@ -335,7 +334,7 @@ return false; if (props.empty()) return false; - return MigrateCtx.AtPropsWeak.count(atLoc.getRawEncoding()); + return MigrateCtx.AtPropsWeak.count(atLoc); } bool isUserDeclared(ObjCIvarDecl *ivarD) const { Index: clang/lib/ARCMigrate/Transforms.h =================================================================== --- clang/lib/ARCMigrate/Transforms.h +++ clang/lib/ARCMigrate/Transforms.h @@ -93,12 +93,12 @@ bool FullyMigratable; }; std::vector GCAttrs; - llvm::DenseSet AttrSet; - llvm::DenseSet RemovedAttrSet; + llvm::DenseSet AttrSet; + llvm::DenseSet RemovedAttrSet; /// Set of raw '@' locations for 'assign' properties group that contain /// GC __weak. - llvm::DenseSet AtPropsWeak; + llvm::DenseSet AtPropsWeak; explicit MigrationContext(MigrationPass &pass) : Pass(pass) {} ~MigrationContext(); Index: clang/lib/CodeGen/CGOpenMPRuntime.h =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.h +++ clang/lib/CodeGen/CGOpenMPRuntime.h @@ -371,7 +371,7 @@ QualType IdentQTy; llvm::StructType *IdentTy = nullptr; /// Map for SourceLocation and OpenMP runtime library debug locations. - typedef llvm::DenseMap OpenMPDebugLocMapTy; + typedef llvm::DenseMap OpenMPDebugLocMapTy; OpenMPDebugLocMapTy OpenMPDebugLocMap; /// The type for a microtask which gets passed to __kmpc_fork_call(). /// Original representation is: Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp =================================================================== --- clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -1728,7 +1728,7 @@ LValue PSource = CGF.EmitLValueForField(Base, *std::next(Fields, IdentField_PSource)); - llvm::Value *OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding()); + llvm::Value *OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc); if (OMPDebugLoc == nullptr) { SmallString<128> Buffer2; llvm::raw_svector_ostream OS2(Buffer2); @@ -1739,7 +1739,7 @@ OS2 << FD->getQualifiedNameAsString(); OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;"; OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str()); - OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc; + OpenMPDebugLocMap[Loc] = OMPDebugLoc; } // *psource = ";;;;;;"; CGF.EmitStoreOfScalar(OMPDebugLoc, PSource); Index: clang/lib/Edit/EditedSource.cpp =================================================================== --- clang/lib/Edit/EditedSource.cpp +++ clang/lib/Edit/EditedSource.cpp @@ -59,7 +59,7 @@ SourceLocation ExpLoc; MacroArgUse ArgUse; std::tie(ExpLoc, ArgUse) = ExpArg; - auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()]; + auto &ArgUses = ExpansionToArgMap[ExpLoc]; if (llvm::find(ArgUses, ArgUse) == ArgUses.end()) ArgUses.push_back(ArgUse); } @@ -82,7 +82,7 @@ SourceLocation ExpLoc; MacroArgUse ArgUse; deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse); - auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding()); + auto I = ExpansionToArgMap.find(ExpLoc); if (I != ExpansionToArgMap.end() && find_if(I->second, [&](const MacroArgUse &U) { return ArgUse.Identifier == U.Identifier && Index: clang/lib/Frontend/Rewrite/InclusionRewriter.cpp =================================================================== --- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -44,13 +44,13 @@ bool ShowLineMarkers; ///< Show #line markers. bool UseLineDirectives; ///< Use of line directives or line markers. /// Tracks where inclusions that change the file are found. - std::map FileIncludes; + std::map FileIncludes; /// Tracks where inclusions that import modules are found. - std::map ModuleIncludes; + std::map ModuleIncludes; /// Tracks where inclusions that enter modules (in a module build) are found. - std::map ModuleEntryIncludes; + std::map ModuleEntryIncludes; /// Tracks where #if and #elif directives get evaluated and whether to true. - std::map IfConditions; + std::map IfConditions; /// Used transitively for building up the FileIncludes mapping over the /// various \c PPCallbacks callbacks. SourceLocation LastInclusionLocation; @@ -65,7 +65,7 @@ void detectMainFileEOL(); void handleModuleBegin(Token &Tok) { assert(Tok.getKind() == tok::annot_module_begin); - ModuleEntryIncludes.insert({Tok.getLocation().getRawEncoding(), + ModuleEntryIncludes.insert({Tok.getLocation(), (Module *)Tok.getAnnotationValue()}); } private: @@ -164,7 +164,7 @@ return; FileID Id = FullSourceLoc(Loc, SM).getFileID(); auto P = FileIncludes.insert( - std::make_pair(LastInclusionLocation.getRawEncoding(), + std::make_pair(LastInclusionLocation, IncludedFile(Id, NewFileType, PP.GetCurDirLookup()))); (void)P; assert(P.second && "Unexpected revisitation of the same include directive"); @@ -199,8 +199,7 @@ const Module *Imported, SrcMgr::CharacteristicKind FileType){ if (Imported) { - auto P = ModuleIncludes.insert( - std::make_pair(HashLoc.getRawEncoding(), Imported)); + auto P = ModuleIncludes.insert(std::make_pair(HashLoc, Imported)); (void)P; assert(P.second && "Unexpected revisitation of the same include directive"); } else @@ -209,8 +208,7 @@ void InclusionRewriter::If(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue) { - auto P = IfConditions.insert( - std::make_pair(Loc.getRawEncoding(), ConditionValue == CVK_True)); + auto P = IfConditions.insert(std::make_pair(Loc, ConditionValue == CVK_True)); (void)P; assert(P.second && "Unexpected revisitation of the same if directive"); } @@ -218,8 +216,7 @@ void InclusionRewriter::Elif(SourceLocation Loc, SourceRange ConditionRange, ConditionValueKind ConditionValue, SourceLocation IfLoc) { - auto P = IfConditions.insert( - std::make_pair(Loc.getRawEncoding(), ConditionValue == CVK_True)); + auto P = IfConditions.insert(std::make_pair(Loc, ConditionValue == CVK_True)); (void)P; assert(P.second && "Unexpected revisitation of the same elif directive"); } @@ -228,7 +225,7 @@ /// an inclusion directive) in the map of inclusion information, FileChanges. const InclusionRewriter::IncludedFile * InclusionRewriter::FindIncludeAtLocation(SourceLocation Loc) const { - const auto I = FileIncludes.find(Loc.getRawEncoding()); + const auto I = FileIncludes.find(Loc); if (I != FileIncludes.end()) return &I->second; return nullptr; @@ -238,7 +235,7 @@ /// an inclusion directive) in the map of module inclusion information. const Module * InclusionRewriter::FindModuleAtLocation(SourceLocation Loc) const { - const auto I = ModuleIncludes.find(Loc.getRawEncoding()); + const auto I = ModuleIncludes.find(Loc); if (I != ModuleIncludes.end()) return I->second; return nullptr; @@ -248,14 +245,14 @@ /// an inclusion directive) in the map of module entry information. const Module * InclusionRewriter::FindEnteredModule(SourceLocation Loc) const { - const auto I = ModuleEntryIncludes.find(Loc.getRawEncoding()); + const auto I = ModuleEntryIncludes.find(Loc); if (I != ModuleEntryIncludes.end()) return I->second; return nullptr; } bool InclusionRewriter::IsIfAtLocationTrue(SourceLocation Loc) const { - const auto I = IfConditions.find(Loc.getRawEncoding()); + const auto I = IfConditions.find(Loc); if (I != IfConditions.end()) return I->second; return false; Index: clang/lib/Tooling/Syntax/BuildTree.cpp =================================================================== --- clang/lib/Tooling/Syntax/BuildTree.cpp +++ clang/lib/Tooling/Syntax/BuildTree.cpp @@ -53,7 +53,7 @@ public: TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) { for (const auto &T : Arena.tokenBuffer().expandedTokens()) - LocationToToken.insert({T.location().getRawEncoding(), &T}); + LocationToToken.insert({T.location(), &T}); } llvm::BumpPtrAllocator &allocator() { return Arena.allocator(); } @@ -310,8 +310,7 @@ syntax::Arena &Arena; /// To quickly find tokens by their start location. - llvm::DenseMap - LocationToToken; + llvm::DenseMap LocationToToken; Forest Pending; llvm::DenseSet DeclsWithoutSemicolons; }; @@ -653,7 +652,7 @@ } const syntax::Token *syntax::TreeBuilder::findToken(SourceLocation L) const { - auto It = LocationToToken.find(L.getRawEncoding()); + auto It = LocationToToken.find(L); assert(It != LocationToToken.end()); return It->second; } Index: clang/lib/Tooling/Syntax/Tokens.cpp =================================================================== --- clang/lib/Tooling/Syntax/Tokens.cpp +++ clang/lib/Tooling/Syntax/Tokens.cpp @@ -379,7 +379,7 @@ Collector->PP.getSourceManager().isBeforeInTranslationUnit( Range.getBegin(), LastExpansionEnd))) return; - Collector->Expansions[Range.getBegin().getRawEncoding()] = Range.getEnd(); + Collector->Expansions[Range.getBegin()] = Range.getEnd(); LastExpansionEnd = Range.getEnd(); } // FIXME: handle directives like #pragma, #include, etc. @@ -606,7 +606,7 @@ auto L = File.SpelledTokens[NextSpelled].location(); if (Offset <= SM.getFileOffset(L)) return llvm::None; // reached the offset we are looking for. - auto Mapping = CollectedExpansions.find(L.getRawEncoding()); + auto Mapping = CollectedExpansions.find(L); if (Mapping != CollectedExpansions.end()) return Mapping->second; // found a mapping before the offset. }