Code Monkey home page Code Monkey logo

itiviti-cpp-analyzer's People

Contributors

bobisonfire avatar egorkaz avatar kurkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

egorkaz

itiviti-cpp-analyzer's Issues

Proposal: make it standalone

There are several versions of clang being used around there, with corresponding libclang versions. Libclang is not backward compatible, thus, migration to a new version would either force to support ICA on both versions or to abandon older clang support

Making it standalone (ideally, statically-linked) executable would give much more freedom for developers to base on any libclang version they want and for users to not maintain their clang and ica versions synced

Multiple checks= flags overwrite each other

Passing -plugin-arg-ica-plugin checks=redundant-noexcept -plugin-arg-ica-plugin checks=improper-move will actually only enable improper-move checks. I believe that this should be handled in the same way as -plugin-arg-ica-plugin checks=redundant-noexcept,improper-move.

From the user perspective, I am thinking about following use-case:

add_ica_checks(all)
target_ica_checks(foo PRIVATE -redundant-noexcept)

This should run foo compilation with all checks but redundant-noexcept. Right now, this does not enable any check at all for foo, since ICA sees this as checks=-redundant-noexcept.

False warning: 'm_significand' can be constructed in initializer list

Description

Analyzer suggests constructing m_significand in the initializer list

Example

// int64_t m_significand & int64_t m_exponent are private fields of struct Exponential

Exponential::Exponential(int64_t number)
    : m_significand(number)
    , m_exponent(0)
{
    while (m_significand != 0 && m_significand % 10 == 0) {
        ++m_exponent;
        m_significand /= 10;
    }
}

Compile message

[  6%] Building CXX object CMakeFiles/expressions_lib.dir/src/exponential.cpp.o
error: 'm_significand' can be constructed in initializer list
m_significand /= 10;
        ^

'const-param' warning for mutable std::bitset instance

Description

Analyzer suggest adding 'const' qualifier for mutable std::bitset instance that changes in the for-loop.

Example

foo.h

#include <bitset>

struct A {
    static const int length = 128;
    static void bar(std::bitset<length> & a, const std::bitset<length> & b, int a_start = 0, int b_start = 0);
}

foo.cpp

void A::bar(std::bitset<length> & a, const std::bitset<length> & b, int a_start, int b_start)
{
    for (int i = a_start, j = b_start; i < A::length && j < A::length; ++i, ++j) {
        int sum = static_cast<int>(a[i]) + static_cast<int>(b[j]);

        a[i] = static_cast<bool>(sum % 2);
    }
}

Compiler message

[  5%] Building CXX object CMakeFiles/expressions_lib.dir/src/foo.cpp.o
error: 'a' can have 'const' qualifier [const-param]
void A::bar(std::bitset<length> & a, const std::bitset<length> & b, int a_start, int b_start)
                         ^
1 error generated.

Build info

Clang 11.0.0

False-positive 'const-param' warning

Description

When a member function tries to modify some fields of a dereferenced field of its argument passed by non-const reference, we get a [const-param] warning that suggests to make such argument const.

Example code

struct Node
{
    void update(Node & parent) // no warning expected
    {
        if (parent.left != nullptr) {
            parent.left->parent = &parent;
        }
    }

    Node * left;
    Node * right;
    Node * parent;
};

Compile arguments

[ 50%] Building CXX object CMakeFiles/ica_test.dir/main.cpp.o
/usr/bin/c++    -g   -Xclang -plugin-arg-ica-plugin -Xclang checks=all=err -Xclang -load -Xclang /usr/local/lib/libica-plugin.so -Xclang -add-plugin -Xclang ica-plugin -std=gnu++17 -o CMakeFiles/ica_test.dir/main.cpp.o -c /home/imodre/CLionProjects/ica-test/main.cpp
/home/imodre/CLionProjects/ica-test/main.cpp:3:17: error: 'parent' can have 'const' qualifier [const-param]
    void update(Node & parent) // no warning expected
                ^
1 error generated.

Build info

Default build from master branch of this repo, clang 10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.