本文整理汇总了C++中ValueDecl::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ValueDecl::getName方法的具体用法?C++ ValueDecl::getName怎么用?C++ ValueDecl::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ValueDecl
的用法示例。
在下文中一共展示了ValueDecl::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SpecializedEmitter
Optional<SpecializedEmitter>
SpecializedEmitter::forDecl(SILGenModule &SGM, SILDeclRef function) {
// Only consider standalone declarations in the Builtin module.
if (function.kind != SILDeclRef::Kind::Func)
return None;
if (!function.hasDecl())
return None;
ValueDecl *decl = function.getDecl();
if (!isa<BuiltinUnit>(decl->getDeclContext()))
return None;
const BuiltinInfo &builtin = SGM.M.getBuiltinInfo(decl->getName());
switch (builtin.ID) {
// All the non-SIL, non-type-trait builtins should use the
// named-builtin logic, which just emits the builtin as a call to a
// builtin function. This includes builtins that aren't even declared
// in Builtins.def, i.e. all of the LLVM intrinsics.
//
// We do this in a separate pass over Builtins.def to avoid creating
// a bunch of identical cases.
#define BUILTIN(Id, Name, Attrs) \
case BuiltinValueKind::Id:
#define BUILTIN_SIL_OPERATION(Id, Name, Overload)
#define BUILTIN_TYPE_TRAIT_OPERATION(Id, Name)
#include "swift/AST/Builtins.def"
case BuiltinValueKind::None:
return SpecializedEmitter(decl->getName());
// Do a second pass over Builtins.def, ignoring all the cases for
// which we emitted something above.
#define BUILTIN(Id, Name, Attrs)
// Use specialized emitters for SIL builtins.
#define BUILTIN_SIL_OPERATION(Id, Name, Overload) \
case BuiltinValueKind::Id: \
return SpecializedEmitter(&emitBuiltin##Id);
// Lower away type trait builtins when they're trivially solvable.
#define BUILTIN_TYPE_TRAIT_OPERATION(Id, Name) \
case BuiltinValueKind::Id: \
return SpecializedEmitter(&emitBuiltinTypeTrait<&TypeBase::Name, \
BuiltinValueKind::Id>);
#include "swift/AST/Builtins.def"
}
llvm_unreachable("bad builtin kind");
}
示例2: handlePrimaryAST
void handlePrimaryAST(ASTUnitRef AstUnit) override {
auto &CompInst = AstUnit->getCompilerInstance();
auto &SrcFile = AstUnit->getPrimarySourceFile();
trace::TracedOperation TracedOp;
SmallVector<std::pair<unsigned, unsigned>, 8> Ranges;
auto Action = [&]() {
if (trace::enabled()) {
trace::SwiftInvocation SwiftArgs;
Invok->raw(SwiftArgs.Args.Args, SwiftArgs.Args.PrimaryFile);
trace::initTraceFiles(SwiftArgs, CompInst);
TracedOp.start(trace::OperationKind::RelatedIdents, SwiftArgs,
{std::make_pair("Offset", std::to_string(Offset))});
}
unsigned BufferID = SrcFile.getBufferID().getValue();
SourceLoc Loc =
Lexer::getLocForStartOfToken(CompInst.getSourceMgr(), BufferID, Offset);
if (Loc.isInvalid())
return;
SemaLocResolver Resolver(SrcFile);
SemaToken SemaTok = Resolver.resolve(Loc);
if (SemaTok.isInvalid())
return;
if (SemaTok.IsKeywordArgument)
return;
ValueDecl *VD = SemaTok.CtorTyRef ? SemaTok.CtorTyRef : SemaTok.ValueD;
if (!VD)
return; // This was a module reference.
// Only accept pointing to an identifier.
if (!SemaTok.IsRef &&
(isa<ConstructorDecl>(VD) ||
isa<DestructorDecl>(VD) ||
isa<SubscriptDecl>(VD)))
return;
if (VD->getName().isOperator())
return;
RelatedIdScanner Scanner(SrcFile, BufferID, VD, Ranges);
if (DeclContext *LocalDC = VD->getDeclContext()->getLocalContext()) {
Scanner.walk(LocalDC);
} else {
Scanner.walk(SrcFile);
}
};
Action();
RelatedIdentsInfo Info;
Info.Ranges = Ranges;
Receiver(Info);
}