本文整理汇总了C++中ParmVarDecl::getNameAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ ParmVarDecl::getNameAsString方法的具体用法?C++ ParmVarDecl::getNameAsString怎么用?C++ ParmVarDecl::getNameAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParmVarDecl
的用法示例。
在下文中一共展示了ParmVarDecl::getNameAsString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VisitFunctionDecl
bool VisitFunctionDecl(FunctionDecl *decl)
{
vector<string> names;
for (size_t i = 0; i != decl->getNumParams(); ++i)
{
ParmVarDecl *parmVarDecl = decl->getParamDecl(i);
if (parmVarDecl->getNameAsString() != "")
{
names.push_back(parmVarDecl->getNameAsString());
}
}
locateParamNames(decl, names);
return true;
}
示例2: VisitObjCMethodDecl
bool VisitObjCMethodDecl(ObjCMethodDecl *decl)
{
vector<string> names;
for (ObjCMethodDecl::param_iterator param = decl->param_begin(),
paramEnd = decl->param_end(); param != paramEnd; param++)
{
ParmVarDecl *parmVarDecl = *param;
if (parmVarDecl->getNameAsString() != "")
{
names.push_back(parmVarDecl->getNameAsString());
}
}
locateParamNames(decl, names);
return true;
}
示例3: PrintDeclContext
void DeclContextPrinter::PrintDeclContext(const DeclContext* DC,
unsigned Indentation) {
// Print DeclContext name.
switch (DC->getDeclKind()) {
case Decl::TranslationUnit:
Out << "[translation unit] " << DC;
break;
case Decl::Namespace: {
Out << "[namespace] ";
const NamespaceDecl* ND = cast<NamespaceDecl>(DC);
Out << ND->getNameAsString();
break;
}
case Decl::Enum: {
const EnumDecl* ED = cast<EnumDecl>(DC);
if (ED->isDefinition())
Out << "[enum] ";
else
Out << "<enum> ";
Out << ED->getNameAsString();
break;
}
case Decl::Record: {
const RecordDecl* RD = cast<RecordDecl>(DC);
if (RD->isDefinition())
Out << "[struct] ";
else
Out << "<struct> ";
Out << RD->getNameAsString();
break;
}
case Decl::CXXRecord: {
const CXXRecordDecl* RD = cast<CXXRecordDecl>(DC);
if (RD->isDefinition())
Out << "[class] ";
else
Out << "<class> ";
Out << RD->getNameAsString() << " " << DC;
break;
}
case Decl::ObjCMethod:
Out << "[objc method]";
break;
case Decl::ObjCInterface:
Out << "[objc interface]";
break;
case Decl::ObjCCategory:
Out << "[objc category]";
break;
case Decl::ObjCProtocol:
Out << "[objc protocol]";
break;
case Decl::ObjCImplementation:
Out << "[objc implementation]";
break;
case Decl::ObjCCategoryImpl:
Out << "[objc categoryimpl]";
break;
case Decl::LinkageSpec:
Out << "[linkage spec]";
break;
case Decl::Block:
Out << "[block]";
break;
case Decl::Function: {
const FunctionDecl* FD = cast<FunctionDecl>(DC);
if (FD->isThisDeclarationADefinition())
Out << "[function] ";
else
Out << "<function> ";
Out << FD->getNameAsString();
// Print the parameters.
Out << "(";
bool PrintComma = false;
for (FunctionDecl::param_const_iterator I = FD->param_begin(),
E = FD->param_end(); I != E; ++I) {
if (PrintComma)
Out << ", ";
else
PrintComma = true;
Out << (*I)->getNameAsString();
}
Out << ")";
break;
}
case Decl::CXXMethod: {
const CXXMethodDecl* D = cast<CXXMethodDecl>(DC);
if (D->isOutOfLineDefinition())
Out << "[c++ method] ";
else if (D->isImplicit())
Out << "(c++ method) ";
else
Out << "<c++ method> ";
Out << D->getNameAsString();
// Print the parameters.
Out << "(";
bool PrintComma = false;
for (FunctionDecl::param_const_iterator I = D->param_begin(),
E = D->param_end(); I != E; ++I) {
if (PrintComma)
//.........这里部分代码省略.........