本文整理汇总了C++中llvm::StringMap::lookup方法的典型用法代码示例。如果您正苦于以下问题:C++ StringMap::lookup方法的具体用法?C++ StringMap::lookup怎么用?C++ StringMap::lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringMap
的用法示例。
在下文中一共展示了StringMap::lookup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void DeprecatedIosBaseAliasesCheck::check(
const MatchFinder::MatchResult &Result) {
SourceManager &SM = *Result.SourceManager;
const auto *Typedef = Result.Nodes.getNodeAs<TypedefDecl>("TypeDecl");
StringRef TypeName = Typedef->getName();
bool HasReplacement = ReplacementTypes.count(TypeName);
const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("TypeLoc");
SourceLocation IoStateLoc = TL->getBeginLoc();
// Do not generate fixits for matches depending on template arguments and
// macro expansions.
bool Fix = HasReplacement && !TL->getType()->isDependentType();
if (IoStateLoc.isMacroID()) {
IoStateLoc = SM.getSpellingLoc(IoStateLoc);
Fix = false;
}
SourceLocation EndLoc = IoStateLoc.getLocWithOffset(TypeName.size() - 1);
if (HasReplacement) {
auto FixName = ReplacementTypes.lookup(TypeName);
auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
"'std::ios_base::%1' instead")
<< TypeName << FixName;
if (Fix)
Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc),
FixName);
} else
diag(IoStateLoc, "'std::ios_base::%0' is deprecated") << TypeName;
}
示例2: findKnownClass
static FoundationClass findKnownClass(const ObjCInterfaceDecl *ID) {
static llvm::StringMap<FoundationClass> Classes;
if (Classes.empty()) {
Classes["NSArray"] = FC_NSArray;
Classes["NSDictionary"] = FC_NSDictionary;
Classes["NSEnumerator"] = FC_NSEnumerator;
Classes["NSOrderedSet"] = FC_NSOrderedSet;
Classes["NSSet"] = FC_NSSet;
Classes["NSString"] = FC_NSString;
}
// FIXME: Should we cache this at all?
FoundationClass result = Classes.lookup(ID->getIdentifier()->getName());
if (result == FC_None)
if (const ObjCInterfaceDecl *Super = ID->getSuperClass())
return findKnownClass(Super);
return result;
}