clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
static inline ClassDefId getEmptyKey() {
- return ClassDefId(
- clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-1)),
- "EMPTY");
+ return ClassDefId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
+ "EMPTY");
}
static inline ClassDefId getTombstoneKey() {
- return ClassDefId(
- clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-2)),
- "TOMBSTONE");
+ return ClassDefId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
+ "TOMBSTONE");
}
static unsigned getHashValue(ClassDefId Val) {
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
std::hash<ClassDefId::second_type> SecondHash;
- return Val.first.getRawEncoding() + SecondHash(Val.second);
+ return Val.first.getHashValue() + SecondHash(Val.second);
}
static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) {
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
static inline NamingCheckId getEmptyKey() {
- return NamingCheckId(
- clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-1)),
- "EMPTY");
+ return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
+ "EMPTY");
}
static inline NamingCheckId getTombstoneKey() {
- return NamingCheckId(
- clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-2)),
- "TOMBSTONE");
+ return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
+ "TOMBSTONE");
}
static unsigned getHashValue(NamingCheckId Val) {
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
std::hash<NamingCheckId::second_type> SecondHash;
- return Val.first.getRawEncoding() + SecondHash(Val.second);
+ return DenseMapInfo<clang::SourceLocation>::getHashValue(Val.first) +
+ SecondHash(Val.second);
}
static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
// 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())
//
// 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);
}
}
}
ShouldFixStatus FixStatus = ShouldFixStatus::ShouldFix;
- /// A set of all the identifier usages starting SourceLocation, in
- /// their encoded form.
- llvm::DenseSet<unsigned> RawUsageLocs;
+ /// A set of all the identifier usages starting SourceLocation.
+ llvm::DenseSet<SourceLocation> RawUsageLocs;
NamingCheckFailure() = default;
};
}
bool VisitTypeLoc(TypeLoc TTL) {
- if (TypeLocsToSkip.count(TTL.getBeginLoc().getRawEncoding()))
+ if (TypeLocsToSkip.count(TTL.getBeginLoc()))
return true;
visitNode(DynTypedNode::create(TTL));
return true;
// 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);
}
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);
}
llvm::function_ref<void(ReferenceLoc)> Out;
/// TypeLocs starting at these locations must be skipped, see
/// TraverseElaboratedTypeSpecifierLoc for details.
- llvm::DenseSet</*SourceLocation*/ unsigned> TypeLocsToSkip;
+ llvm::DenseSet<SourceLocation> TypeLocsToSkip;
};
} // namespace
}
};
- llvm::DenseMap<unsigned, SmallVector<MacroArgUse, 2>> ExpansionToArgMap;
+ llvm::DenseMap<SourceLocation, SmallVector<MacroArgUse, 2>> ExpansionToArgMap;
SmallVector<std::pair<SourceLocation, MacroArgUse>, 2>
CurrCommitMacroArgExps;
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,
/// 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</*SourceLocation*/ int, SourceLocation>;
+ using PPExpansions = llvm::DenseMap<SourceLocation, SourceLocation>;
class Builder;
class CollectPPExpansions;
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;
else
return false;
- MigrateCtx.AttrSet.insert(RawLoc);
+ MigrateCtx.AttrSet.insert(OrigLoc);
MigrateCtx.GCAttrs.push_back(MigrationContext::GCAttrOccurrence());
MigrationContext::GCAttrOccurrence &Attr = MigrateCtx.GCAttrs.back();
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,
if (GCAttrsCollector::hasObjCImpl(
cast<Decl>(IndProps.front()->getDeclContext()))) {
if (hasWeak)
- MigrateCtx.AtPropsWeak.insert(AtLoc.getRawEncoding());
+ MigrateCtx.AtPropsWeak.insert(AtLoc);
} else {
StringRef toAttr = "strong";
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<ObjCPropertyDecl *> &AllProps) {
typedef llvm::TinyPtrVector<ObjCPropertyDecl *> IndivPropsTy;
- llvm::DenseMap<unsigned, IndivPropsTy> AtProps;
+ llvm::DenseMap<SourceLocation, IndivPropsTy> AtProps;
for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
ObjCPropertyDecl *PD = AllProps[i];
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<unsigned, IndivPropsTy>::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);
}
return false;
if (props.empty())
return false;
- return MigrateCtx.AtPropsWeak.count(atLoc.getRawEncoding());
+ return MigrateCtx.AtPropsWeak.count(atLoc);
}
bool isUserDeclared(ObjCIvarDecl *ivarD) const {
bool FullyMigratable;
};
std::vector<GCAttrOccurrence> GCAttrs;
- llvm::DenseSet<unsigned> AttrSet;
- llvm::DenseSet<unsigned> RemovedAttrSet;
+ llvm::DenseSet<SourceLocation> AttrSet;
+ llvm::DenseSet<SourceLocation> RemovedAttrSet;
/// Set of raw '@' locations for 'assign' properties group that contain
/// GC __weak.
- llvm::DenseSet<unsigned> AtPropsWeak;
+ llvm::DenseSet<SourceLocation> AtPropsWeak;
explicit MigrationContext(MigrationPass &pass) : Pass(pass) {}
~MigrationContext();
private:
/// Map for SourceLocation and OpenMP runtime library debug locations.
- typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
+ typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
OpenMPDebugLocMapTy OpenMPDebugLocMap;
/// The type for a microtask which gets passed to __kmpc_fork_call().
/// Original representation is:
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);
}
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 &&
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(); }
syntax::Arena &Arena;
/// To quickly find tokens by their start location.
- llvm::DenseMap</*SourceLocation*/ unsigned, const syntax::Token *>
- LocationToToken;
+ llvm::DenseMap<SourceLocation, const syntax::Token *> LocationToToken;
Forest Pending;
llvm::DenseSet<Decl *> DeclsWithoutSemicolons;
ASTToSyntaxMapping Mapping;
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;
}
// 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.
// 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() &&
// 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...