本文整理汇总了C++中NamedDecl::getQualifiedNameAsString方法的典型用法代码示例。如果您正苦于以下问题:C++ NamedDecl::getQualifiedNameAsString方法的具体用法?C++ NamedDecl::getQualifiedNameAsString怎么用?C++ NamedDecl::getQualifiedNameAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NamedDecl
的用法示例。
在下文中一共展示了NamedDecl::getQualifiedNameAsString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VisitCXXMemberCallExpr
void gpWalkAST::VisitCXXMemberCallExpr( clang::CXXMemberCallExpr *CE ) {
const FunctionDecl * FD = CE->getMethodDecl();
if (!FD) return;
std::string mname = FD->getQualifiedNameAsString();
const char *sfile=BR.getSourceManager().getPresumedLoc(CE->getExprLoc()).getFilename();
std::string sname(sfile);
if ( ! support::isInterestingLocation(sname) ) return;
std::string mdname = ND->getQualifiedNameAsString();
const Expr * IOA = CE->getImplicitObjectArgument();
std::string tname = "getparam-dumper.txt.unsorted";
std::string ps = "const class edm::ParameterSet ";
std::string ups = "const class edm::UntrackedParameterSet ";
std::string gp = "edm::ParameterSet::getParameter";
std::string gup = "edm::ParameterSet::getUntrackedParameter";
if (mname.substr(0,gp.length()) == gp || mname.substr(0,gup.length()) == gup ) {
std::string buf;
llvm::raw_string_ostream os(buf);
const NamedDecl * nd = llvm::dyn_cast<NamedDecl>(AC->getDecl());
if ( FunctionDecl::classof(ND) ) {
os << "function decl '" << nd->getQualifiedNameAsString() ;
os << "' this '"<<mdname;
} else {
os << "constructor decl '" << nd->getQualifiedNameAsString() ;
os << "' initializer for member decl '"<<mdname;
}
clang::LangOptions LangOpts;
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy(LangOpts);
os << "' with call args '";
for ( unsigned I=0, E=CE->getNumArgs(); I != E; ++I) {
if (I) os <<", ";
os << CE->getType().getCanonicalType().getAsString()<<" ";
CE->getArg(I)->printPretty(os,0,Policy);
}
os << "' with implicit object '";
const Expr * E = IOA->IgnoreParenCasts();
QualType QE = E->getType().getCanonicalType();
os << QE.getAsString()<<" ";
switch( E->getStmtClass() ) {
case Stmt::MemberExprClass:
os << dyn_cast<MemberExpr>(E)->getMemberDecl()->getQualifiedNameAsString();
break;
case Stmt::DeclRefExprClass:
os << dyn_cast<DeclRefExpr>(E)->getDecl()->getQualifiedNameAsString();
break;
case Stmt::CXXOperatorCallExprClass:
dyn_cast<CXXOperatorCallExpr>(E)->printPretty(os,0,Policy);
break;
case Stmt::CXXBindTemporaryExprClass:
dyn_cast<CXXBindTemporaryExpr>(E)->printPretty(os,0,Policy);
break;
case Stmt::CXXMemberCallExprClass:
dyn_cast<CXXMemberCallExpr>(E)->printPretty(os,0,Policy);
break;
case Stmt::UnaryOperatorClass:
dyn_cast<UnaryOperator>(E)->printPretty(os,0,Policy);
break;
default:
E->printPretty(os,0,Policy);
os << " unhandled expr class " <<E->getStmtClassName();
}
os<<"'\n";
support::writeLog(os.str(),tname);
}
return ;
}
示例2: VisitCallExpr
bool VisitCallExpr(CallExpr* call) {
//outs() << "do found" << "\n";
NamedDecl* calleedecl = (NamedDecl*)call->getCalleeDecl();
if (calleedecl != NULL) {
//ignore macro expansion
SourceLocation loc = call->getLocStart();
if (!sm->isInMainFile(loc))
return true;
if (call->getCalleeDecl()->isFunctionOrFunctionTemplate()) {
SourceRange sr = call->getCalleeDecl()->getAsFunction()->getSourceRange();
SourceLocation start_pos = sr.getBegin();
if (!start_pos.isValid()) {
//outs() << "error: invalid location." << "\n";
//outfile << "error: invalid location." << "\n";
return true;
}
else {
StringRef headerFilename = sm->getFilename(start_pos);
string fullheaderfile = headerFilename.str();
if (fullheaderfile == "")
return true;
if (fullheaderfile.find(project_name) < fullheaderfile.length())
return true;
if (fullheaderfile[0] != '/')
return true;
/*
int i;
for (i = fullheaderfile.length() - 1; i >=0; i--)
if (fullheaderfile[i] == '/')
break;
string headerfile;
if (fullheaderfile.substr(fullheaderfile.length()-2, 2) == ".h")
headerfile = fullheaderfile.substr(i+1, fullheaderfile.length() - i - 3);
else
headerfile = fullheaderfile.substr(i+1, fullheaderfile.length() - i - 1);
bool flag = false;
for (int j = 0; j < API_NUM; j++)
{
bool flag2 = true;
for (int k = 0; k < headerfile.length(); k++){
if (headerfile[k] != APIList[j][k])
flag2 = false;
}
if (flag2 == true){
flag = true;
}
}
if (!flag)
return true;
*/
}
}
else {
//return true;
}
outs() << "Found " << calleedecl->getQualifiedNameAsString() <<" at: ";
//outfile << "Found " << calleedecl->getQualifiedNameAsString() <<" at: ";
string s = calleedecl->getQualifiedNameAsString();
qualified_name = "";
short_name = "";
unsigned int pos = s.length()-1;
while (pos > 0) {
if (s[pos] == ':' && s[pos-1] == ':')
break;
pos--;
}
if (pos == 0)
pos = -1;
short_name = s.substr(pos+1, s.length()-pos-1);
int mark = 0;
for (unsigned int i = 0; i < s.length(); i++) {
if (s[i] == ',')
s[i] = ';';
if (s[i] == '<') {
mark ++;
}
if (i > 0) {
if (s[i-1] == '>') {
mark --;
}
}
if (mark == 0 || i >= pos+1)
qualified_name = qualified_name + s[i];
}
StringRef filename = sm->getFilename(loc);
//unsigned int col = sm->getSpellingColumnNumber(loc);
//unsigned int line = sm->getSpellingLineNumber(loc);
outs() << filename << "\n";
//file_name = filename.str();
//outfile << filename.str() << "\n";
//outfile <<filename.str();
//outs() << ", line: " <<line<< " column: " << col << "\n";
//outfile << ", line: " <<line<< " column: " << col << "\n";
//get parent function
if (CurrentFunc != NULL) {
SourceRange sr = CurrentFunc->getSourceRange();
//.........这里部分代码省略.........