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


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

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


在下文中一共展示了SourceLocation::isFileID方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
	}
开发者ID:zmanchun,项目名称:insieme,代码行数:30,代码来源:source_locations.cpp

示例2: string

// Get a "file:line:column" source location string.
static std::string getSourceLocationString(clang::Preprocessor &PP,
                                           clang::SourceLocation Loc) {
  if (Loc.isInvalid())
    return std::string("(none)");

  if (Loc.isFileID()) {
    clang::PresumedLoc PLoc = PP.getSourceManager().getPresumedLoc(Loc);

    if (PLoc.isInvalid()) {
      return std::string("(invalid)");
    }

    std::string Str;
    llvm::raw_string_ostream SS(Str);

    // The macro expansion and spelling pos is identical for file locs.
    SS << "\"" << PLoc.getFilename() << ':' << PLoc.getLine() << ':'
       << PLoc.getColumn() << "\"";

    std::string Result = SS.str();

    // YAML treats backslash as escape, so use forward slashes.
    std::replace(Result.begin(), Result.end(), '\\', '/');

    return Result;
  }

  return std::string("(nonfile)");
}
开发者ID:PdedP,项目名称:clang-tools-extra,代码行数:30,代码来源:PPCallbacksTracker.cpp

示例3: HandlePPCond

void PreprocessorCallback::HandlePPCond(clang::SourceLocation Loc, clang::SourceLocation IfLoc)
{
    if (!Loc.isValid() || !Loc.isFileID())
        return;

    clang::SourceManager &SM = annotator.getSourceMgr();
    clang::FileID FID = SM.getFileID(Loc);
    if (!annotator.shouldProcess(FID))
        return;

    while(ElifMapping.count(IfLoc)) {
        IfLoc = Loc;
    }

    if (SM.getFileID(IfLoc) != FID) {
        return;
    }

    annotator.generator(FID).addTag("span", ("data-ppcond=\"" + clang::Twine(SM.getExpansionLineNumber(IfLoc)) + "\"").str(),
                                    SM.getFileOffset(Loc), clang::Lexer::MeasureTokenLength(Loc, SM, PP.getLangOpts()));
}
开发者ID:ClockMan,项目名称:woboq_codebrowser,代码行数:21,代码来源:preprocessorcallback.cpp

示例4: InclusionDirective

void PreprocessorCallback::InclusionDirective(clang::SourceLocation HashLoc, const clang::Token& IncludeTok,
                                              llvm::StringRef FileName, bool IsAngled,
                                              clang::CharSourceRange FilenameRange, const clang::FileEntry* File,
                                              llvm::StringRef SearchPath, llvm::StringRef RelativePath,
                                              const clang::Module* Imported)
{
    if (!HashLoc.isValid() || !HashLoc.isFileID() || !File)
        return;
    clang::SourceManager &sm = annotator.getSourceMgr();
    clang::FileID FID = sm.getFileID(HashLoc);
    if (!annotator.shouldProcess(FID))
        return;

    std::string link = annotator.pathTo(FID, File);
    if (link.empty())
      return;

    auto B = sm.getFileOffset(FilenameRange.getBegin());
    auto E = sm.getFileOffset(FilenameRange.getEnd());

    annotator.generator(FID).addTag("a", "href=\"" % link % "\"", B, E-B);
}
开发者ID:abigagli,项目名称:woboq_codebrowser,代码行数:22,代码来源:preprocessorcallback.cpp

示例5: addFileLocation

void RefFinder::addFileLocation(clang::SourceLocation loc) {
    if (!loc.isFileID()) return;         // skip macro expansions etc
    locs.push_back(loc);
}
开发者ID:luciusmagn,项目名称:c2compiler,代码行数:4,代码来源:RefFinder.cpp


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