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


C++ Analyser类代码示例

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


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

示例1: Surface

void BindablePlatform::init_bindable_platform (int posx, int posy, std::string file_name)
{
    m_pos.x = posx;
    m_pos.y = posy;

    file_name = PIC_STATICS_R + file_name;
    m_image = new Surface (file_name + ".png");
    m_pos.h = m_image->h();
    m_pos.w = m_image->w();
    Analyser analyser;
    analyser.open (file_name + ".col");
    m_collisions_matrix_w = analyser.read_int();
    m_collisions_matrix_h = analyser.read_int();
    m_collisions_matrix = new unsigned int*[m_collisions_matrix_w];
    for (int i = 0; i < m_collisions_matrix_w; i++)
    {
        m_collisions_matrix[i] = new unsigned int[m_collisions_matrix_h];
    }
    for (int j = 0; j < m_collisions_matrix_h; j++)
    {
        for (int i = 0; i < m_collisions_matrix_w; i++)
        {
            m_collisions_matrix[i][j] = analyser.read_int();
        }
    }
    analyser.close();
}
开发者ID:joetde,项目名称:SuperBadbar,代码行数:27,代码来源:BindablePlatform.cpp

示例2: check

static void check(Analyser& analyser, CastExpr const *expr)
{
    if (expr->getSubExpr()->isNullPointerConstant(
            *analyser.context(), Expr::NPC_ValueDependentIsNotNull)) {
        return;                                                       // RETURN
    }
    if (expr->getCastKind() != CK_BitCast &&
        expr->getCastKind() != CK_LValueBitCast &&
        expr->getCastKind() != CK_IntegralToPointer) {
        return;                                                       // RETURN
    }
    CanQualType source(getType(expr->getSubExpr()->getType()));
    CanQualType target(getType(expr->getType()));
    std::string tt = static_cast<QualType>(target).getAsString();
    if ((source != target &&
         tt != "char" &&
         tt != "unsigned char" &&
         tt != "signed char" &&
         tt != "void") ||
        (expr->getType()->isPointerType() !=
         expr->getSubExpr()->getType()->isPointerType())) {
        analyser.report(expr, check_name, "AL01",
                        "Possible strict-aliasing violation")
            << expr->getSourceRange();
    }
}
开发者ID:gstrauss,项目名称:bde-tools,代码行数:26,代码来源:csamisc_strictaliasing.cpp

示例3: member_definition_in_class_definition

static void
member_definition_in_class_definition(Analyser& analyser,
                                      CXXMethodDecl const* decl)
{
    member_definition& data = analyser.attachment<member_definition>();

    if (decl->isTemplateInstantiation()) {
        if (CXXMethodDecl const* tplt = llvm::dyn_cast<CXXMethodDecl>(
                decl->getTemplateInstantiationPattern())) {
            decl = tplt;
        }
    }

    if (decl->getLexicalDeclContext() == decl->getDeclContext()
        && decl->hasInlineBody()
        && !decl->getParent()->isLocalClass()
        && !decl->isImplicit()
        && !data.reported_[decl->getCanonicalDecl()]
        && !analyser.is_test_driver()
        && !decl->getLocStart().isMacroID())
    {
        analyser.report(decl, check_name, "CD01",
                "Member function '%0' is defined in the class definition.")
            << decl->getQualifiedNameAsString();
        data.reported_[decl->getCanonicalDecl()] = true;
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:27,代码来源:csamisc_memberdefinitioninclassdefinition.cpp

示例4: apply

        static inline void apply(Analyser & analyser, TurnIt first, TurnIt last)
        {
            if ( first == last )
                return;

            for_preceding_rings(analyser, *first);
            //analyser.per_turn(*first);

            TurnIt prev = first;
            for ( ++first ; first != last ; ++first, ++prev )
            {
                // same multi
                if ( prev->operations[OpId].seg_id.multi_index
                  == first->operations[OpId].seg_id.multi_index )
                {
                    // same ring
                    if ( prev->operations[OpId].seg_id.ring_index
                      == first->operations[OpId].seg_id.ring_index )
                    {
                        //analyser.per_turn(*first);
                    }
                    // same multi, next ring
                    else
                    {
                        //analyser.end_ring(*prev);
                        analyser.turns(prev, first);

                        //if ( prev->operations[OpId].seg_id.ring_index + 1
                        //   < first->operations[OpId].seg_id.ring_index)
                        {
                            for_no_turns_rings(analyser,
                                               *first,
                                               prev->operations[OpId].seg_id.ring_index + 1,
                                               first->operations[OpId].seg_id.ring_index);
                        }

                        //analyser.per_turn(*first);
                    }
                }
                // next multi
                else
                {
                    //analyser.end_ring(*prev);
                    analyser.turns(prev, first);
                    for_following_rings(analyser, *prev);
                    for_preceding_rings(analyser, *first);
                    //analyser.per_turn(*first);
                }

                if ( analyser.interrupt )
                {
                    return;
                }
            }

            //analyser.end_ring(*prev);
            analyser.turns(prev, first); // first == last
            for_following_rings(analyser, *prev);
        }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:59,代码来源:areal_areal.hpp

示例5: close_file

static void close_file(Analyser& analyser,
                       SourceLocation where,
                       std::string const&,
                       std::string const& name)
{
    if (analyser.is_component_header(name))
    {
        analyser.attachment<data>().line_ =
            analyser.get_location(where).line();
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:11,代码来源:csatr_componentheaderinclude.cpp

示例6: MyItem

ZoneItem::ZoneItem (QGraphicsScene *scene, TriggerItem *parent, Analyser &analyser) :
    MyItem (NULL, ""),
    m_parent (parent)
{
    Q_UNUSED (scene);
    int x, y;
    x = analyser.read_int();
    y = analyser.read_int();
    m_width = analyser.read_int() - x;
    m_height = analyser.read_int() - y;
    setItem (addRect (0, 0, m_width, m_height) );
    setPos (x, y);
}
开发者ID:joetde,项目名称:SuperBadbar,代码行数:13,代码来源:ZoneItem.cpp

示例7: process

static void
process(Analyser& analyser, Expr const* expr, Decl const* decl)
{
    if (const FunctionDecl* function =
            decl ? llvm::dyn_cast<FunctionDecl>(decl) : 0) {
        function = function->getCanonicalDecl();
        std::string name;
        PrintingPolicy policy(analyser.context()->getLangOpts());
        function->getNameForDiagnostic(name, policy, true);

        std::ostringstream out;
        out << name << "(";
        for (FunctionDecl::param_const_iterator it(function->param_begin()),
             end(function->param_end());
             it != end;
             ++it) {
            if (it != function->param_begin()) {
                out << ", ";
            }
            ParmVarDecl const* param(*it);
            out << param->getType().getAsString();
            if (param->isParameterPack()) {
                out << "...";
            }
        }
        out << ")";
        CXXMethodDecl const* method(llvm::dyn_cast<CXXMethodDecl>(function));
        if (method && !method->isStatic()) {
            if (method->getTypeQualifiers() & Qualifiers::Const) {
                out << " const";
            }
            if (method->getTypeQualifiers() & Qualifiers::Volatile) {
                out << " volatile";
            }
            if (method->getTypeQualifiers() & Qualifiers::Restrict) {
                out << " restrict";
            }
        }

        name += out.str();

        //-dk:TODO analyser.report(expr, check_name, "function decl: '%0'")
        //-dk:TODO     << expr->getSourceRange()
        //-dk:TODO     << out.str()
            ;
    }
    else {
        analyser.report(expr, check_name, "UF01", "Unresolved function call")
            << expr->getSourceRange();
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:51,代码来源:csamisc_calls.cpp

示例8: check

static void check(Analyser& analyser, CXXThrowExpr const* expr)
{
    const TypeDecl *e = analyser.lookup_type("::std::exception");
    Expr *object(const_cast<Expr*>(expr->getSubExpr()));
    if (e && e->getTypeForDecl() && object) // else it is a rethrow...
    {
        QualType t = e->getTypeForDecl()->getCanonicalTypeInternal();
        QualType ot = object->getType()->getCanonicalTypeInternal();
        if (ot != t && !analyser.sema().IsDerivedFrom(ot, t)) {
            analyser.report(expr, check_name, "FE01",
                            "Object of type %0 not derived from "
                            "std::exception is thrown.")
                << ot;
        }
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:16,代码来源:csamisc_thrownonstdexception.cpp

示例9: analyse_each_turn

    static inline void analyse_each_turn(Result & res,
                                         Analyser & analyser,
                                         TurnIt first, TurnIt last)
    {
        if ( first == last )
            return;

        for ( TurnIt it = first ; it != last ; ++it )
        {
            analyser.apply(res, it);

            if ( BOOST_GEOMETRY_CONDITION(res.interrupt) )
                return;
        }

        analyser.apply(res);
    }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:17,代码来源:areal_areal.hpp

示例10: open_file

static void open_file(Analyser& analyser,
                      SourceLocation where,
                      const std::string&,
                      const std::string& name)
{
    FileName fn(name);
    std::string filename = fn.name();
    if (analyser.is_component_header(filename) ||
        name == analyser.toplevel()) {
        const SourceManager &m = analyser.manager();
        llvm::StringRef buf = m.getBuffer(m.getFileID(where))->getBuffer();
        if (buf.size() == 0) {
            return;
        }
        buf = buf.substr(0, buf.find('\n')).rtrim();
        std::string expectcpp("// " + filename);
        expectcpp.resize(70, ' ');
        expectcpp += "-*-C++-*-";
        std::string expectc("/* " + filename);
        expectc.resize(69, ' ');
        expectc += "-*-C-*- */";

        if (   !buf.equals(expectcpp)
            && !buf.equals(expectc)
            && buf.find("GENERATED") == buf.npos) {
            std::pair<size_t, size_t> mcpp = mid_mismatch(buf, expectcpp);
            std::pair<size_t, size_t> mc = mid_mismatch(buf, expectc);
            std::pair<size_t, size_t> m;
            std::string expect;

            if (mcpp.first >= mc.first || mcpp.second >= mc.second) {
                m = mcpp;
                expect = expectcpp;
            } else {
                m = mc;
                expect = expectc;
            }
            analyser.report(where.getLocWithOffset(m.first),
                            check_name, "HL01",
                            "File headline incorrect", true);
            analyser.report(where.getLocWithOffset(m.first),
                            check_name, "HL01",
                            "Correct format is\n%0",
                            true, DiagnosticIDs::Note)
                << expect;
            if (m.first == 0) {
                analyser.InsertTextAfter(
                    where.getLocWithOffset(m.first), expect + "\n");
            } else {
                analyser.ReplaceText(analyser.get_line_range(where), expect);
            }
        }
    }
}
开发者ID:gstrauss,项目名称:bde-tools,代码行数:54,代码来源:csafmt_headline.cpp

示例11: for_no_turns_rings

        static inline void for_no_turns_rings(Analyser & analyser,
                                              Turn const& turn,
                                              signed_size_type first,
                                              signed_size_type last)
        {
            segment_identifier seg_id = turn.operations[OpId].seg_id;

            for ( seg_id.ring_index = first ; seg_id.ring_index < last ; ++seg_id.ring_index )
            {
                analyser.no_turns(seg_id);
            }
        }
开发者ID:Niko-r,项目名称:geofeatures,代码行数:12,代码来源:areal_areal.hpp

示例12: include_file

static void include_file(Analyser& analyser,
                         SourceLocation where,
                         bool,
                         std::string const& name)
{
    data& status(analyser.attachment<data>());
    if (status.check_)
    {
        if (analyser.is_component_header(name) ||
            analyser.is_component_header(analyser.toplevel()))
        {
            status.header_seen_ = true;
        }
        else if (!status.header_seen_
                 && analyser.toplevel() != name
                 && builtin != name
                 && command_line != name
                 && "bdes_ident.h" != name
                 && !analyser.is_main())
        {
            analyser.report(where, check_name, "TR09",
                            "Include files precede component header",
                            true);
            status.check_ = false;
        }
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:27,代码来源:csatr_componentheaderinclude.cpp

示例13: check

static void check(Analyser& analyser, BinaryOperator const* expr)
{
    if ((expr->getOpcode() == BO_Add || expr->getOpcode() == BO_Sub) &&
        (is_addition(
             analyser, expr->getLHS(), expr->getRHS(), expr->getOpcode()) ||
         is_addition(
             analyser, expr->getRHS(), expr->getLHS(), expr->getOpcode()))) {
        analyser.report(expr->getOperatorLoc(), check_name, "SA01",
                        "%0 integer %1 string literal")
            << expr->getSourceRange()
            << (expr->getOpcode() == BO_Add? "Adding": "Subtracting")
            << (expr->getOpcode() == BO_Add? "to": "from");
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:14,代码来源:csamisc_stringadd.cpp

示例14: is_addition

static bool is_addition(Analyser& analyser,
                        Expr const* str,
                        Expr const* value,
                        BinaryOperatorKind op)
{
    if (StringLiteral const* lit =
            llvm::dyn_cast<StringLiteral>(str->IgnoreParenCasts())) {
        llvm::APSInt length(32, false);
        llvm::APSInt zero(32, false);
        length = lit->getByteLength();
        zero = 0u;
        value = value->IgnoreParenCasts();
        llvm::APSInt result;
        return !value->isIntegerConstantExpr(result, *analyser.context()) ||
               (op == BO_Add && (result < zero || length < result)) ||
               (op == BO_Sub && (zero < result || length + result < zero));
    }
    return false;
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:19,代码来源:csamisc_stringadd.cpp

示例15: declaration

static void declaration(Analyser& analyser, Decl const* decl)
{
    data& status(analyser.attachment<data>());
    if (status.check_)
    {
        if (!status.header_seen_ ||
            analyser.is_component_header(analyser.toplevel()))
        {
            status.header_seen_ = true;
            status.line_ = 0;
        }

        Location loc(analyser.get_location(decl));
        if ((analyser.toplevel() != loc.file() && status.header_seen_)
            || (analyser.toplevel() == loc.file()
                && status.line_ < loc.line()))
        {
            status.check_ = false;
        }
        else if (((analyser.toplevel() != loc.file() && !status.header_seen_)
                  || loc.line() < status.line_)
                 && builtin != loc.file() && command_line != loc.file()
                 && (llvm::dyn_cast<NamedDecl>(decl) == 0
                     || utils::end(id_names)
                          == std::find(utils::begin(id_names),
                                       utils::end(id_names),
                                       llvm::dyn_cast<NamedDecl>(decl)
                                                          ->getNameAsString()))
                 && !analyser.is_main())
        {
            analyser.report(decl, check_name, "TR09",
                            "Declarations precede component header",
                            true);
            status.check_ = false;
        }
    }
}
开发者ID:Stackingit,项目名称:bde-tools,代码行数:37,代码来源:csatr_componentheaderinclude.cpp


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