本文整理汇总了C++中llvm::StringRef::endswith方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::endswith方法的具体用法?C++ StringRef::endswith怎么用?C++ StringRef::endswith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::endswith方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getThunkTarget
std::string Context::getThunkTarget(llvm::StringRef MangledName) {
if (!isThunkSymbol(MangledName))
return std::string();
if (isMangledName(MangledName)) {
// The targets of those thunks not derivable from the mangling.
if (MangledName.endswith("TR") ||
MangledName.endswith("Tr") ||
MangledName.endswith("TW") )
return std::string();
if (MangledName.endswith("fC")) {
std::string target = MangledName.str();
target[target.size() - 1] = 'c';
return target;
}
return MangledName.substr(0, MangledName.size() - 2).str();
}
// Old mangling.
assert(MangledName.startswith("_T"));
StringRef Remaining = MangledName.substr(2);
if (Remaining.startswith("PA_"))
return Remaining.substr(3).str();
if (Remaining.startswith("PAo_"))
return Remaining.substr(4).str();
assert(Remaining.startswith("To") || Remaining.startswith("TO"));
return std::string("_T") + Remaining.substr(2).str();
}
示例2: FileNotFound
bool MocPPCallbacks::FileNotFound(llvm::StringRef FileName, llvm::SmallVectorImpl< char >& RecoveryPath) {
if (FileName.endswith(".moc") || FileName.endswith("_moc.cpp") || FileName.startswith("moc_")) {
if (!PP.GetSuppressIncludeNotFoundError()) {
PP.SetSuppressIncludeNotFoundError(true);
IncludeNotFoundSupressed = true;
}
} else {
if (IncludeNotFoundSupressed) {
PP.SetSuppressIncludeNotFoundError(false);
IncludeNotFoundSupressed = false;
} else {
ShouldWarnHeaderNotFound = true;
}
}
return false;
}
示例3: isThunkSymbol
bool Context::isThunkSymbol(llvm::StringRef MangledName) {
if (isMangledName(MangledName)) {
// First do a quick check
if (MangledName.endswith("TA") || // partial application forwarder
MangledName.endswith("Ta") || // ObjC partial application forwarder
MangledName.endswith("To") || // swift-as-ObjC thunk
MangledName.endswith("TO") || // ObjC-as-swift thunk
MangledName.endswith("TR") || // reabstraction thunk helper function
MangledName.endswith("Tr") || // reabstraction thunk
MangledName.endswith("TW") || // protocol witness thunk
MangledName.endswith("fC")) { // allocating constructor
// To avoid false positives, we need to fully demangle the symbol.
NodePointer Nd = D->demangleSymbol(MangledName);
if (!Nd || Nd->getKind() != Node::Kind::Global ||
Nd->getNumChildren() == 0)
return false;
switch (Nd->getFirstChild()->getKind()) {
case Node::Kind::ObjCAttribute:
case Node::Kind::NonObjCAttribute:
case Node::Kind::PartialApplyObjCForwarder:
case Node::Kind::PartialApplyForwarder:
case Node::Kind::ReabstractionThunkHelper:
case Node::Kind::ReabstractionThunk:
case Node::Kind::ProtocolWitness:
case Node::Kind::Allocator:
return true;
default:
break;
}
}
return false;
}
if (MangledName.startswith("_T")) {
// Old mangling.
StringRef Remaining = MangledName.substr(2);
if (Remaining.startswith("To") || // swift-as-ObjC thunk
Remaining.startswith("TO") || // ObjC-as-swift thunk
Remaining.startswith("PA_") || // partial application forwarder
Remaining.startswith("PAo_")) { // ObjC partial application forwarder
return true;
}
}
return false;
}
示例4: EnterMainFile
void MocPPCallbacks::EnterMainFile(llvm::StringRef Name)
{
if (Name.endswith("global/qnamespace.h")) {
// qnamsepace.h is a bit special because it contains all the Qt namespace enums
// but all the Q_ENUMS are within a Q_MOC_RUN scope, which also do all sort of things.
clang::MacroInfo *MI = PP.AllocateMacroInfo({});
MI->setIsBuiltinMacro();
#if CLANG_VERSION_MAJOR != 3 || CLANG_VERSION_MINOR > 2
PP.appendDefMacroDirective(PP.getIdentifierInfo("Q_MOC_RUN"), MI);
#else
PP.setMacroInfo(PP.getIdentifierInfo("Q_MOC_RUN"), MI);
#endif
InjectQObjectDefs({});
}
}
示例5: SplitPaths
bool SplitPaths(llvm::StringRef PathStr,
llvm::SmallVectorImpl<llvm::StringRef>& Paths,
SplitMode Mode, llvm::StringRef Delim, bool Verbose) {
assert(Delim.size() && "Splitting without a delimiter");
#if defined(LLVM_ON_WIN32)
// Support using a ':' delimiter on Windows.
const bool WindowsColon = Delim.equals(":");
#endif
bool AllExisted = true;
for (std::pair<llvm::StringRef, llvm::StringRef> Split = PathStr.split(Delim);
!Split.second.empty(); Split = PathStr.split(Delim)) {
if (!Split.first.empty()) {
bool Exists = llvm::sys::fs::is_directory(Split.first);
#if defined(LLVM_ON_WIN32)
// Because drive letters will have a colon we have to make sure the split
// occurs at a colon not followed by a path separator.
if (!Exists && WindowsColon && Split.first.size()==1) {
// Both clang and cl.exe support '\' and '/' path separators.
if (Split.second.front() == '\\' || Split.second.front() == '/') {
const std::pair<llvm::StringRef, llvm::StringRef> Tmp =
Split.second.split(Delim);
// Split.first = 'C', but we want 'C:', so Tmp.first.size()+2
Split.first =
llvm::StringRef(Split.first.data(), Tmp.first.size() + 2);
Split.second = Tmp.second;
Exists = llvm::sys::fs::is_directory(Split.first);
}
}
#endif
AllExisted = AllExisted && Exists;
if (!Exists) {
if (Mode == kFailNonExistant) {
if (Verbose) {
// Exiting early, but still log all non-existant paths that we have
LogNonExistantDirectory(Split.first);
while (!Split.second.empty()) {
Split = PathStr.split(Delim);
if (llvm::sys::fs::is_directory(Split.first)) {
llvm::errs() << " ignoring directory that exists \""
<< Split.first << "\"\n";
} else
LogNonExistantDirectory(Split.first);
Split = Split.second.split(Delim);
}
if (!llvm::sys::fs::is_directory(Split.first))
LogNonExistantDirectory(Split.first);
}
return false;
} else if (Mode == kAllowNonExistant)
Paths.push_back(Split.first);
else if (Verbose)
LogNonExistantDirectory(Split.first);
} else
Paths.push_back(Split.first);
}
PathStr = Split.second;
}
// Trim trailing sep in case of A:B:C:D:
if (!PathStr.empty() && PathStr.endswith(Delim))
PathStr = PathStr.substr(0, PathStr.size()-Delim.size());
if (!PathStr.empty()) {
if (!llvm::sys::fs::is_directory(PathStr)) {
AllExisted = false;
if (Mode == kAllowNonExistant)
Paths.push_back(PathStr);
else if (Verbose)
LogNonExistantDirectory(PathStr);
} else
Paths.push_back(PathStr);
}
return AllExisted;
}