diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h @@ -85,15 +85,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) { @@ -101,7 +99,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) { diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h @@ -94,9 +94,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; }; diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -28,15 +28,13 @@ using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId; static inline NamingCheckId getEmptyKey() { - return NamingCheckId( - clang::SourceLocation::getFromRawEncoding(static_cast(-1)), - "EMPTY"); + return NamingCheckId(DenseMapInfo::getEmptyKey(), + "EMPTY"); } static inline NamingCheckId getTombstoneKey() { - return NamingCheckId( - clang::SourceLocation::getFromRawEncoding(static_cast(-2)), - "TOMBSTONE"); + return NamingCheckId(DenseMapInfo::getTombstoneKey(), + "TOMBSTONE"); } static unsigned getHashValue(NamingCheckId Val) { @@ -44,7 +42,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) { @@ -173,8 +172,7 @@ // is already in there RenamerClangTidyCheck::NamingCheckFailure &Failure = NamingCheckFailures[Decl]; - - if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second) + if (!Failure.RawUsageLocs.insert(FixLocation).second) return; if (!Failure.ShouldFix()) @@ -550,9 +548,8 @@ // // Other multi-token identifiers, such as operators are not checked at // all. - Diag << FixItHint::CreateReplacement( - SourceRange(SourceLocation::getFromRawEncoding(Loc)), - Failure.Info.Fixup); + Diag << FixItHint::CreateReplacement(SourceRange(Loc), + Failure.Info.Fixup); } } } diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -1014,7 +1014,7 @@ } bool VisitTypeLoc(TypeLoc TTL) { - if (TypeLocsToSkip.count(TTL.getBeginLoc().getRawEncoding())) + if (TypeLocsToSkip.count(TTL.getBeginLoc())) return true; visitNode(DynTypedNode::create(TTL)); return true; @@ -1024,7 +1024,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); } @@ -1090,7 +1090,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); } @@ -1163,7 +1163,7 @@ llvm::function_ref Out; /// TypeLocs starting at these locations must be skipped, see /// TraverseElaboratedTypeSpecifierLoc for details. - llvm::DenseSet TypeLocsToSkip; + llvm::DenseSet TypeLocsToSkip; }; } // namespace diff --git a/clang/include/clang/Edit/EditedSource.h b/clang/include/clang/Edit/EditedSource.h --- a/clang/include/clang/Edit/EditedSource.h +++ b/clang/include/clang/Edit/EditedSource.h @@ -62,7 +62,7 @@ } }; - llvm::DenseMap> ExpansionToArgMap; + llvm::DenseMap> ExpansionToArgMap; SmallVector, 2> CurrCommitMacroArgExps; diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -12768,7 +12768,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, diff --git a/clang/include/clang/Tooling/Syntax/Tokens.h b/clang/include/clang/Tooling/Syntax/Tokens.h --- a/clang/include/clang/Tooling/Syntax/Tokens.h +++ b/clang/include/clang/Tooling/Syntax/Tokens.h @@ -438,7 +438,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; diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp --- a/clang/lib/ARCMigrate/TransGCAttrs.cpp +++ b/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, @@ -262,7 +262,7 @@ if (GCAttrsCollector::hasObjCImpl( cast(IndProps.front()->getDeclContext()))) { if (hasWeak) - MigrateCtx.AtPropsWeak.insert(AtLoc.getRawEncoding()); + MigrateCtx.AtPropsWeak.insert(AtLoc); } else { StringRef toAttr = "strong"; @@ -289,14 +289,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]; @@ -306,14 +306,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); } diff --git a/clang/lib/ARCMigrate/TransProperties.cpp b/clang/lib/ARCMigrate/TransProperties.cpp --- a/clang/lib/ARCMigrate/TransProperties.cpp +++ b/clang/lib/ARCMigrate/TransProperties.cpp @@ -337,7 +337,7 @@ return false; if (props.empty()) return false; - return MigrateCtx.AtPropsWeak.count(atLoc.getRawEncoding()); + return MigrateCtx.AtPropsWeak.count(atLoc); } bool isUserDeclared(ObjCIvarDecl *ivarD) const { diff --git a/clang/lib/ARCMigrate/Transforms.h b/clang/lib/ARCMigrate/Transforms.h --- a/clang/lib/ARCMigrate/Transforms.h +++ b/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(); diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h --- a/clang/lib/CodeGen/CGOpenMPRuntime.h +++ b/clang/lib/CodeGen/CGOpenMPRuntime.h @@ -391,7 +391,7 @@ private: /// 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: diff --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp --- a/clang/lib/Edit/EditedSource.cpp +++ b/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 && diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp --- a/clang/lib/Tooling/Syntax/BuildTree.cpp +++ b/clang/lib/Tooling/Syntax/BuildTree.cpp @@ -367,7 +367,7 @@ public: TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) { for (const auto &T : Arena.getTokenBuffer().expandedTokens()) - LocationToToken.insert({T.location().getRawEncoding(), &T}); + LocationToToken.insert({T.location(), &T}); } llvm::BumpPtrAllocator &allocator() { return Arena.getAllocator(); } @@ -689,8 +689,7 @@ syntax::Arena &Arena; /// To quickly find tokens by their start location. - llvm::DenseMap - LocationToToken; + llvm::DenseMap LocationToToken; Forest Pending; llvm::DenseSet DeclsWithoutSemicolons; ASTToSyntaxMapping Mapping; @@ -1708,7 +1707,7 @@ const syntax::Token *syntax::TreeBuilder::findToken(SourceLocation L) const { if (L.isInvalid()) return nullptr; - auto It = LocationToToken.find(L.getRawEncoding()); + auto It = LocationToToken.find(L); assert(It != LocationToToken.end()); return It->second; } diff --git a/clang/lib/Tooling/Syntax/Tokens.cpp b/clang/lib/Tooling/Syntax/Tokens.cpp --- a/clang/lib/Tooling/Syntax/Tokens.cpp +++ b/clang/lib/Tooling/Syntax/Tokens.cpp @@ -575,11 +575,11 @@ // A's startpoint. if (!Range.getBegin().isFileID()) { Range.setBegin(SM.getExpansionLoc(Range.getBegin())); - assert(Collector->Expansions.count(Range.getBegin().getRawEncoding()) && + assert(Collector->Expansions.count(Range.getBegin()) && "Overlapping macros should have same expansion location"); } - Collector->Expansions[Range.getBegin().getRawEncoding()] = Range.getEnd(); + Collector->Expansions[Range.getBegin()] = Range.getEnd(); LastExpansionEnd = Range.getEnd(); } // FIXME: handle directives like #pragma, #include, etc. @@ -711,8 +711,8 @@ // If we know mapping bounds at [NextSpelled, KnownEnd] (macro expansion) // then we want to partition our (empty) mapping. // [Start, NextSpelled) [NextSpelled, KnownEnd] (KnownEnd, Target) - SourceLocation KnownEnd = CollectedExpansions.lookup( - SpelledTokens[NextSpelled].location().getRawEncoding()); + SourceLocation KnownEnd = + CollectedExpansions.lookup(SpelledTokens[NextSpelled].location()); if (KnownEnd.isValid()) { FlushMapping(); // Emits [Start, NextSpelled) while (NextSpelled < SpelledTokens.size() && @@ -749,7 +749,7 @@ // We need no mapping for file tokens copied to the expanded stream. } else { // We found a new macro expansion. We should have its spelling bounds. - auto End = CollectedExpansions.lookup(Expansion.getRawEncoding()); + auto End = CollectedExpansions.lookup(Expansion); assert(End.isValid() && "Macro expansion wasn't captured?"); // Mapping starts here...