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


C++ clang::ASTContext类代码示例

本文整理汇总了C++中clang::ASTContext的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext类的具体用法?C++ ASTContext怎么用?C++ ASTContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: lineBasedShouldSuppress

bool lineBasedShouldSuppress(int beginLine, clang::ASTContext &context)
{
    std::string filePath = getMainFilePath(context);
    auto commentLinesIt = singleLineMapping.find(filePath);
    std::set<int> commentLines;
    if (commentLinesIt == singleLineMapping.end())
    {
        clang::RawCommentList commentList = context.getRawCommentList();
        clang::ArrayRef<clang::RawComment *> commentArray = commentList.getComments();

        for (auto comment : commentArray)
        {

            if (std::string::npos !=
                comment->getRawText(context.getSourceManager()).find("//!OCLINT"))
            {
                clang::SourceLocation startLocation = comment->getLocStart();
                int startLocationLine =
                    context.getSourceManager().getPresumedLineNumber(startLocation);
                commentLines.insert(startLocationLine);
            }
        }
        singleLineMapping[filePath] = commentLines;
    }
    else
    {
        commentLines = commentLinesIt->second;
    }

    return commentLines.find(beginLine) != commentLines.end();
}
开发者ID:GeekMin,项目名称:oclint,代码行数:31,代码来源:SuppressHelper.cpp

示例2: getClangMetatypeType

static clang::CanQualType getClangMetatypeType(
    const clang::ASTContext &clangCtx) {
    clang::QualType clangType =
        clangCtx.getObjCObjectType(clangCtx.ObjCBuiltinClassTy, 0, 0);
    clangType = clangCtx.getObjCObjectPointerType(clangType);
    return clangCtx.getCanonicalType(clangType);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:7,代码来源:GenClangType.cpp

示例3: StreamArr

static void StreamArr(llvm::raw_ostream& o, const void* V, clang::QualType Ty,
                      clang::ASTContext& C) {
  const clang::ArrayType* ArrTy = Ty->getAsArrayTypeUnsafe();
  clang::QualType ElementTy = ArrTy->getElementType();
  if (ElementTy->isCharType())
    StreamCharPtr(o, (const char*)V);
  else if (Ty->isConstantArrayType()) {
    // Stream a constant array by streaming up to 5 elements.
    const clang::ConstantArrayType* CArrTy
      = C.getAsConstantArrayType(Ty);
    const llvm::APInt& APSize = CArrTy->getSize();
    size_t ElBytes = C.getTypeSize(ElementTy) / C.getCharWidth();
    size_t Size = (size_t)APSize.getZExtValue();
    o << "{ ";
    for (size_t i = 0; i < Size; ++i) {
      StreamValue(o, (const char*) V + i * ElBytes, ElementTy, C);
      if (i + 1 < Size) {
        if (i == 4) {
          o << "...";
          break;
        }
        else o << ", ";
      }
    }
    o << " }";
  } else
    StreamPtr(o, V);
}
开发者ID:rpatkennyiii,项目名称:root,代码行数:28,代码来源:ValuePrinter.cpp

示例4: getClangIdType

static clang::CanQualType getClangIdType(
  const clang::ASTContext &clangCtx) {
  clang::QualType clangType =
      clangCtx.getObjCObjectType(clangCtx.ObjCBuiltinIdTy, nullptr, 0);
  clangType = clangCtx.getObjCObjectPointerType(clangType);
  return clangCtx.getCanonicalType(clangType);
}
开发者ID:PiersonBro,项目名称:swift,代码行数:7,代码来源:GenClangType.cpp

示例5: getClangDecayedVaListType

static clang::CanQualType getClangDecayedVaListType(
    const clang::ASTContext &clangCtx) {
    clang::QualType clangType =
        clangCtx.getCanonicalType(clangCtx.getBuiltinVaListType());
    if (clangType->isConstantArrayType())
        clangType = clangCtx.getDecayedType(clangType);
    return clangCtx.getCanonicalType(clangType);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:8,代码来源:GenClangType.cpp

示例6: getClangVectorType

static clang::CanQualType getClangVectorType(const clang::ASTContext &ctx,
        clang::BuiltinType::Kind eltKind,
        clang::VectorType::VectorKind vecKind,
        StringRef numEltsString) {
    unsigned numElts;
    bool failedParse = numEltsString.getAsInteger<unsigned>(10, numElts);
    assert(!failedParse && "vector type name didn't end in count?");
    (void) failedParse;

    auto eltTy = getClangBuiltinTypeFromKind(ctx, eltKind);
    auto vecTy = ctx.getVectorType(eltTy, numElts, vecKind);
    return ctx.getCanonicalType(vecTy);
}
开发者ID:yasirmcs,项目名称:swift,代码行数:13,代码来源:GenClangType.cpp

示例7: HandleTranslationUnit

  virtual void HandleTranslationUnit(clang::ASTContext &ctx)
  {
    llvm::raw_ostream &out = llvm::errs();
    clang::TranslationUnitDecl *translationUnit = ctx.getTranslationUnitDecl();

    MyDeclVisitor(out, _astinfo).Visit(translationUnit);
  }
开发者ID:wkia,项目名称:white-knight-is-alive,代码行数:7,代码来源:testclang.cpp

示例8: markedParentsAsSuppress

bool markedParentsAsSuppress(const T &node, clang::ASTContext &context, oclint::RuleBase *rule)
{
    const auto &parents = context.getParents(node);
    if (parents.empty())
    {
        return false;
    }

    clang::ast_type_traits::DynTypedNode dynTypedNode = parents.front();
    const clang::Decl *aDecl = dynTypedNode.get<clang::Decl>();
    if (aDecl)
    {
        if (markedAsSuppress(aDecl, rule))
        {
            return true;
        }
        return markedParentsAsSuppress(*aDecl, context, rule);
    }
    const clang::Stmt *aStmt = dynTypedNode.get<clang::Stmt>();
    if (aStmt)
    {
        return markedParentsAsSuppress(*aStmt, context, rule);
    }

    return false;
}
开发者ID:GeekMin,项目名称:oclint,代码行数:26,代码来源:SuppressHelper.cpp

示例9: HandleTranslationUnit

    void HandleTranslationUnit(clang::ASTContext &astContext) override {
        const auto &sourceManager = astContext.getSourceManager();
        const auto cursorSourceLocation = sourceManager.translateLineCol(sourceManager.getMainFileID(),
                                                                         line,
                                                                         column);

        if (cursorSourceLocation.isValid())
            collectUnifiedSymbolResoltions(astContext, cursorSourceLocation);
    }
开发者ID:yueying,项目名称:qt-creator,代码行数:9,代码来源:findusrforcursoraction.cpp

示例10: ExitIfError

	void ExitIfError(clang::ASTContext &Context)
	{
		DiagnosticsEngine & diags = Context.getDiagnostics();
		if (diags.hasErrorOccurred()) {
			unsigned DiagID = diags.getCustomDiagID(DiagnosticsEngine::Fatal,
				"previous errors prevent further compilation");
			diags.Report(DiagID);
			exit(1);
		}
	}
开发者ID:CarlEbeling,项目名称:OpenHT,代码行数:10,代码来源:HtDesign.cpp

示例11: HandleTranslationUnit

void ReplaceArrayAccessWithIndex::HandleTranslationUnit(clang::ASTContext &Ctx)
{
  TransAssert(Collector && "NULL Collector");
  Collector->TraverseDecl(Ctx.getTranslationUnitDecl());

  if (QueryInstanceOnly)
    return;

  if (TransformationCounter > ValidInstanceNum) {
    TransError = TransMaxInstanceError;
    return;
  }

  Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
  doRewrite();

  if (Ctx.getDiagnostics().hasErrorOccurred() ||
      Ctx.getDiagnostics().hasFatalErrorOccurred())
    TransError = TransInternalError;
}
开发者ID:vgvassilev,项目名称:creduce,代码行数:20,代码来源:ReplaceArrayAccessWithIndex.cpp

示例12: checkAndAnalyze

void WebCLConsumer::checkAndAnalyze(clang::ASTContext &context)
{
    clang::TranslationUnitDecl *decl = context.getTranslationUnitDecl();
    for (Visitors::iterator i = visitors_.begin(); i != visitors_.end(); ++i) {
        // There is no point to continue if an error has been reported.
        if (!hasErrors(context)) {
            WebCLVisitor *visitor = (*i);
            visitor->TraverseDecl(decl);
        }
    }
}
开发者ID:ChiahungTai,项目名称:webcl-validator,代码行数:11,代码来源:WebCLConsumer.cpp

示例13: GetTokenBeforeLocation

clang::Token GetTokenBeforeLocation(clang::SourceLocation loc,
                                    const clang::ASTContext& ast_context) {
    clang::Token token;
    token.setKind(clang::tok::unknown);
    clang::LangOptions lang_options = ast_context.getLangOpts();
    const clang::SourceManager& source_manager = ast_context.getSourceManager();
    clang::SourceLocation file_start_loc =
        source_manager.getLocForStartOfFile(source_manager.getFileID(loc));
    loc = loc.getLocWithOffset(-1);
    while (loc != file_start_loc) {
        loc = clang::Lexer::GetBeginningOfToken(loc, source_manager, lang_options);
        if (!clang::Lexer::getRawToken(loc, token, source_manager, lang_options)) {
            if (!token.is(clang::tok::comment)) {
                break;
            }
        }
        loc = loc.getLocWithOffset(-1);
    }
    return token;
}
开发者ID:hfeeki,项目名称:llvm-clang-samples,代码行数:20,代码来源:try_matcher.cpp

示例14:

PPIncludeCallback::PPIncludeCallback(
  ParserContext& ctx_,
  clang::ASTContext& astContext_,
  MangledNameCache& mangledNameCache_,
  clang::Preprocessor&) :
    _ctx(ctx_),
    _cppSourceType("CPP"),
    _clangSrcMgr(astContext_.getSourceManager()),
    _fileLocUtil(astContext_.getSourceManager()),
    _mangledNameCache(mangledNameCache_)
{
}
开发者ID:Ericsson,项目名称:CodeCompass,代码行数:12,代码来源:ppincludecallback.cpp

示例15: collect

    RangeSet collect(clang::ASTContext &astContext, oclint::RuleBase *rule)
    {
        _rule = rule;
        _sourceManager = &astContext.getSourceManager();
        _range.clear();

        clang::DeclContext *decl = astContext.getTranslationUnitDecl();
        for (clang::DeclContext::decl_iterator declIt = decl->decls_begin(),
            declEnd = decl->decls_end(); declIt != declEnd; ++declIt)
        {
            clang::SourceLocation startLocation = (*declIt)->getLocStart();
            if (startLocation.isValid() &&
                _sourceManager->getMainFileID() == _sourceManager->getFileID(startLocation))
            {
                (void) /* explicitly ignore the return of this function */
                    clang::RecursiveASTVisitor<DeclAnnotationRangeCollector>::TraverseDecl(*declIt);
            }
        }

        return _range;
    }
开发者ID:GeekMin,项目名称:oclint,代码行数:21,代码来源:SuppressHelper.cpp


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