当前位置: 首页>>代码示例>>C++>>正文


C++ SourceLocation::printToString方法代码示例

本文整理汇总了C++中SourceLocation::printToString方法的典型用法代码示例。如果您正苦于以下问题:C++ SourceLocation::printToString方法的具体用法?C++ SourceLocation::printToString怎么用?C++ SourceLocation::printToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SourceLocation的用法示例。


在下文中一共展示了SourceLocation::printToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: run

    virtual void run(const MatchFinder::MatchResult &Result){//freeVar
        const DeclRefExpr* DRE = Result.Nodes.getNodeAs<DeclRefExpr>("freeVar");
        #ifdef DEBUG
        llvm::errs()<<"----DRE(freeVar) find----\n";
        #endif
        
        if(!DRE)   return ;

        const SourceManager *SM = Result.SourceManager;
        
        const NamedDecl *ND = DRE->getFoundDecl();
        checkPoint cp;
        cp.name = rewrite.ConvertToString((Stmt*)DRE);
        std::string str_decl = ND->getNameAsString();
        cp.declName = str_decl;
       
        SourceLocation declLocStart = ND->getLocStart();
        std::string str_declLocStart = declLocStart.printToString(*SM);
        loc_strToint(cp.declRow,cp.declCol,str_declLocStart.c_str());

        SourceLocation locStart = DRE->getLocStart();
        std::string str_locStart = locStart.printToString(*SM);
        loc_strToint(cp.row,cp.col,str_locStart.c_str());


        
        cpVecF.push_back(cp);
    #ifdef DEBUG
    llvm::errs()<<"----DRE(freeVar) end----\n";
    #endif
    }
开发者ID:farseer002,项目名称:clangCheckingTool,代码行数:31,代码来源:checkMemory2.cpp

示例2: run

 virtual void run(const MatchFinder::MatchResult &Result) {
     auto *d = Result.Nodes.getNodeAs<TypeLoc>("stuff");
     SourceLocation locstart = d->getLocStart();
     llvm::errs() << "*\n";
     llvm::errs() << " start: " << locstart.printToString(*Result.SourceManager) << "\n";
     SourceLocation locend = d->getLocEnd();
     llvm::errs() << " end: " << locend.printToString(*Result.SourceManager) << "\n";
 }
开发者ID:hfeeki,项目名称:llvm-clang-samples,代码行数:8,代码来源:try_matcher.cpp

示例3: collectModuleHeaders

// Collect referenced headers from one module.
// Collects the headers referenced in the given module into
// HeaderFileNames.
bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {

  // Ignore explicit modules because they often have dependencies
  // we can't know.
  if (Mod.IsExplicit)
    return true;

  // Treat headers in umbrella directory as dependencies.
  DependentsVector UmbrellaDependents;

  // Recursively do submodules.
  for (auto MI = Mod.submodule_begin(), MIEnd = Mod.submodule_end();
       MI != MIEnd; ++MI)
    collectModuleHeaders(**MI);

  if (const FileEntry *UmbrellaHeader = Mod.getUmbrellaHeader().Entry) {
    std::string HeaderPath = getCanonicalPath(UmbrellaHeader->getName());
    // Collect umbrella header.
    HeaderFileNames.push_back(HeaderPath);

    // FUTURE: When needed, umbrella header header collection goes here.
  }
  else if (const DirectoryEntry *UmbrellaDir = Mod.getUmbrellaDir().Entry) {
    // If there normal headers, assume these are umbrellas and skip collection.
    if (Mod.Headers->size() == 0) {
      // Collect headers in umbrella directory.
      if (!collectUmbrellaHeaders(UmbrellaDir->getName(), UmbrellaDependents))
        return false;
    }
  }

  // We ignore HK_Private, HK_Textual, HK_PrivateTextual, and HK_Excluded,
  // assuming they are marked as such either because of unsuitability for
  // modules or because they are meant to be included by another header,
  // and thus should be ignored by modularize.

  int NormalHeaderCount = Mod.Headers[clang::Module::HK_Normal].size();

  for (int Index = 0; Index < NormalHeaderCount; ++Index) {
    DependentsVector NormalDependents;
    // Collect normal header.
    const clang::Module::Header &Header(
      Mod.Headers[clang::Module::HK_Normal][Index]);
    std::string HeaderPath = getCanonicalPath(Header.Entry->getName());
    HeaderFileNames.push_back(HeaderPath);
  }

  int MissingCountThisModule = Mod.MissingHeaders.size();

  for (int Index = 0; Index < MissingCountThisModule; ++Index) {
    std::string MissingFile = Mod.MissingHeaders[Index].FileName;
    SourceLocation Loc = Mod.MissingHeaders[Index].FileNameLoc;
    errs() << Loc.printToString(*SourceMgr)
      << ": error : Header not found: " << MissingFile << "\n";
  }

  MissingHeaderCount += MissingCountThisModule;

  return true;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:63,代码来源:ModularizeUtilities.cpp

示例4: recordCallLog

///record call-log pair
void FindPatternVisitor::recordCallLog(CallExpr *callExpr, CallExpr *logExpr){
    
    if(!callExpr || !logExpr)
        return;
    
    if(callExpr == logExpr)
        return;
    
    if(!callExpr->getDirectCallee() || !logExpr->getDirectCallee())
        return;
    
    if(hasRecorded[logExpr] == 0)
        hasRecorded[logExpr] = 1;
    else
        return;
    
    SourceLocation callLocation = callExpr->getLocStart();
    SourceLocation logLocation = logExpr->getLocStart();
    
    if(callLocation.isValid() && logLocation.isValid()){
        
        if(0){
            llvm::outs()<<callExpr->getDirectCallee()->getQualifiedNameAsString()<<"@"<<callLocation.printToString(CI->getSourceManager());
            llvm::outs()<<"#";
            llvm::outs()<<logExpr->getDirectCallee()->getQualifiedNameAsString()<<"@"<<logLocation.printToString(CI->getSourceManager());
            llvm::outs()<<"\n";
        }
        
        fputs(callExpr->getDirectCallee()->getQualifiedNameAsString().c_str(), out);
        fputs("@", out);
        string callloc = callLocation.printToString(CI->getSourceManager());
        callloc = callloc.substr(0, callloc.find(" "));
        fputs(callloc.c_str(), out);
        fputs("#", out);
        fputs(logExpr->getDirectCallee()->getQualifiedNameAsString().c_str(), out);
        fputs("@", out);
        string logloc = logLocation.printToString(CI->getSourceManager());
        logloc = logloc.substr(0, logloc.find(" "));
        fputs(logloc.c_str(), out);
        fputs("\n", out);
        
        totalPatternSnippet++;
    }
}
开发者ID:ZhouyangJia,项目名称:clang-smartlog,代码行数:45,代码来源:FindPatternSnippet.cpp

示例5: FileName

	string FileName(SourceLocation const& l, SourceManager const& sm) {
		if(l.isValid()) {
			return l.printToString(sm);
			//	if (l.isMacroID()){
			//		PresumedLoc pl = sm.getPresumedLoc(l);
			//		if (pl.isValid()){
			//			return string(pl.getFilename());
			//		}
			//	}
			//	return string(l.getFilename());
		}
		return string("UNKNOWN FILE");
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:13,代码来源:source_locations.cpp


注:本文中的SourceLocation::printToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。