本文整理汇总了C++中clang::SourceLocation::printToString方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceLocation::printToString方法的具体用法?C++ SourceLocation::printToString怎么用?C++ SourceLocation::printToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clang::SourceLocation
的用法示例。
在下文中一共展示了SourceLocation::printToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: location
std::string location(clang::SourceLocation const& l, clang::SourceManager const& sm) {
if(l.isValid()) {
if(l.isFileID()) {
// if (sm.isLoadedFileID (sm.getFileID(l))) return "PRELOADED MODULE";
if(sm.isLoadedSourceLocation(l)) { return "PRELOADED MODULE"; }
return l.printToString(sm);
}
if(l.isMacroID()) {
// FIXME: what do we do here? somehow clang fails
/*
std::cout << "SLoc isMacroID\n";
auto sl = sm.getSpellingLoc(l);
if (sm.isLoadedSourceLocation(sl) ) { return "PRELOADED MODULE"; }
if(sl.isValid()) {
return sl.printToString(sm);
}
PresumedLoc pl = sm.getPresumedLoc(l);
if (pl.isValid()){
return string(pl.getFilename());
}
*/
}
return string("UNKNOWN FILE");
}
return string("INVALID LOC");
}
示例2: report
ReportStream Reporter::report(const clang::SourceRange &range)
{
// Track this report
mTotalReports++;
// Print the expansion location
const clang::SourceLocation expansionLoc(mSourceManager.getExpansionLoc(range.getBegin()));
std::cerr << boldCode() << expansionLoc.printToString(mSourceManager) << ": ";
// Print the "connect" in a different color than warnings or errors
std::cerr << connectColorCode() << "connect:" << defaultColorCode();
return ReportStream();
}
示例3: if
void c2ffi::process_macros(clang::CompilerInstance &ci, std::ostream &os) {
using namespace c2ffi;
clang::SourceManager &sm = ci.getSourceManager();
clang::Preprocessor &pp = ci.getPreprocessor();
for(clang::Preprocessor::macro_iterator i = pp.macro_begin();
i != pp.macro_end(); i++) {
const clang::MacroInfo *mi = (*i).second->getMacroInfo();
const clang::SourceLocation sl = mi->getDefinitionLoc();
std::string loc = sl.printToString(sm);
const char *name = (*i).first->getNameStart();
if(mi->isBuiltinMacro() || loc.substr(0,10) == "<built-in>") {
} else if(mi->isFunctionLike()) {
} else if(best_guess type = macro_type(pp, name, mi)) {
os << "/* " << loc << " */" << std::endl;
os << "#define " << name << " "
<< macro_to_string(pp, mi)
<< std::endl << std::endl;
}
}
for(clang::Preprocessor::macro_iterator i = pp.macro_begin();
i != pp.macro_end(); i++) {
clang::MacroInfo *mi = (*i).second->getMacroInfo();
clang::SourceLocation sl = mi->getDefinitionLoc();
std::string loc = sl.printToString(sm);
const char *name = (*i).first->getNameStart();
if(mi->isBuiltinMacro() || loc.substr(0,10) == "<built-in>") {
} else if(mi->isFunctionLike()) {
} else if(best_guess type = macro_type(pp, name, mi)) {
output_redef(pp, name, mi, type, os);
}
}
}
示例4:
std::string
NamedDeclMatcher::loc(clang::SourceLocation L)
{
return L.printToString(ci->getSourceManager());
}