Skip to content

General

26 results found

  1. compute function cyclomatic complexity...

    ...and issue message if above a threshold.

    Since you're already analyzing the functions, it would seem to be a relatively minor addition to compute a cyclomatic complexity for the function (he said, while signing up someone else to do all the work).

    Then, similarly to the "-size" option, the user could be allowed to set a max complexity, above which an info message could be generated.

    This would help reduce our reliance on additional tools.

    35 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    1 comment  ·  Admin →

    The recently released PC-lint Plus version 2.0 provides a comprehensive Metrics solution that provides the ability to report the values of dozens of built in metrics, including cyclomatic complexity, define custom metrics, and diagnose situations where metrics exceed specified thresholds.  See Chapter 10 of the version 2.0 Reference Manual for details.

  2. make use of multiple cores on modern CPU/OS

    Similar to what GNU makes offers with it´s -j switch, large projects would benefit greatly, if LINT was able to scan multiple files simultaneously (e.g. four on a quad core CPU).

    33 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  3. -efile2 for inhibition within a file

    -efile only inhibits messages about a file. This causes requests in the forum/to support from time to time. Mostly the questioner will be explained that -efile works only for messages about the file. The answer is correct, but leaves the questioner unsatisfied, as he/she is looking for something like -efile2.

    It should not be too difficult to implement it and would help many people.

    23 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  4. Having multiple initializer functions in a constructor

    Lint checks, if all of the members are initialized in the constructor. Optionally this check could be redirected to an initializer-function introduced with the -sem Command. But then the initialization has to be done completely in the initializer-function.

    In our embedded software it is quite common to have more than one function doing the initialization task, e.g.:

    class A
    {
    public:
    A()
    {
    membera = 0;
    initFunction1();
    initFunction2();
    }
    private:
    void initFunction1()
    {
    member
    b = 0;
    }

    void initFunction2()
    {
        member_c = 0;
    }
    
    int member_a;
    int member_b;
    int member_c;
    

    };

    It would be very helpful, that lint…

    19 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    In the upcoming PC-lint Plus, full or partial initializations that takes place in functions called by a constructor are automatically recognized without the need for an initializer semantic. In the example provided, no message would be issued. The initializer semantic can still be used if the definition of an initializing member function is not available but otherwise isn’t necessary.

  5. Expected Warning 438: Last value assigned to variable not used

    Hi,

    For the following code I really expected lint
    warning 438. However, lint isn't complaining about
    that. Not even when I use -w4 (it complains about
    using ++ inside a function call, but not about
    438, which is more serious in my opinion)

    extern int f(void);
    extern void g(int x);

    void bla(void)
    {
    int x = f();
    g(x++);
    }

    Am I misunderstanding something, or is Lint really
    lacking here?

    Note: If I change the code to do

    g(x)
    x++;

    Which I would think is 'the same', I do get the
    438 lint warning of course.

    Best regards,

    Arnaud Gouder de…

    18 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  6. Implement structure value tracking

    Provide basic structure value tracking. Especially for null pointers. Consider the following:

    xres->lif=NULL;
    foo(xres->lif->stuff);

    Should flag deference of xres->lif as "known null access"

    16 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  7. Add support for AUTOSAR coding guidelines

    Now that PC-LINT plus is based on clang it should be fairly easy to come up with an author file for https://www.autosar.org/fileadmin/user_upload/standards/adaptive/17-03/AUTOSAR_RS_CPP14Guidelines.pdf which basically adds C++14 on top of MISRA C++ 2008 (which itself is working on a revised standard).

    15 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  8. Expedite support for C++20

    I used PC-Lint many years ago, and was quite satisfied. Just to see what the current state of the program was, I pasted a bit of code I was working on into your online evaluator. Unfortunately, it couldn't handle a number of bits of C++20-specific code. (It also refused to recognize the VS flag /std:c++latest, which is legitimate.)

    13 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    The recently released PC-lint Plus 2.0 supports most of C++20 allowing it to be used with current versions of most compilers, including Visual Studio 2022.  The -std=c++20 option may be used to enable support for C++20.  The Online Demo will be updated with the new version soon, in the mean time an evaluation version of 2.0 is available for download here.

  9. Make wildcards work in -sem statements

    Would allow single -sem statement for group of similarly named methods. Example:

    //lint -sem(CTest::Pre*Post, pure)

    class CTest
    {
    public:
    int PreOnePost() const;
    int PreTwoPost() const;
    int PreThreePost() const;
    };

    Would cover all 3 methods in CTest.

    12 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  10. 9xxx messages for MISRA C++

    PC-lint 9.00k introduced support for MISRA C 2012 via a set of 9000-series messages which is a significant improvement over previous versions which lumped the messages together under a couple of messages. This is a request to extend the 9000 messages to cover MISRA C++.

    11 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  11. generate an Info message for inefficient structure packing

    Since PC-Lint already has the size and alignment information, it could determine if structures members are not arranged most efficiently.

    For example, in a standard 32-bit system, a structure defined as

    struct foo
    {
    uint32t a;
    uint8
    t b;
    uint16_t c;
    }

    is not most efficiently arranged, requiring an additional padding byte between b and c to achieve the necessary alignment for c. A more efficient method would be to define foo as

    struct foo
    {
    uint32t a;
    uint16
    t b;
    uint8_t c;
    }

    I think Lint could determine this and generate some Info message for struct name.

    9 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    Hi Michael, 


    Thank you for the suggestion. In this case, you can implement a query to report on this issue e.g.


    -astquery(

        persistent $size = 100

        persistent $name = RecordDecl.getNameAsString

        if FieldDecl {

           FieldDecl : {

             if getParent.isStruct{

                    echo{ $size = getType.getTypeSizeInBits}

                    echo{ $name = getParent.getNameAsString}

             }

             if getType.getTypeSizeInBits > $size {

             getParent.getNameAsString == $name

             message(8001 "Inefficient structure packing. '" currentnode "' is larger than the previous declaration.")

             }

        }

    })


    This query will report on the example provided e.g.

    //lint -w1 +e8001

    #include <stdint.h>

    struct foo

    {

    uint32_t g;

    uint16_t h;

    uint8_t i;

    };


    struct foo1

    {

    uint32_t a;

    uint8_t c; 

    uint16_t b; //Reports here.

    };


    Output:

    Message 8001: (info -- Inefficient structure packing. 'foo1::b' is larger than the previous declaration.)


    This query can be placed in a .lnt file and passed to PC-lint Plus as an argument. The documentation for queries can be found in section 16 of…

  12. Stop reporting 948 for expressions in C++11 static_assert()'s

    Since C++11, static_assert can be used to express conditions which have to be met at compile time and PC-lint claims to support this since version 9.00k.

    But even with 9.00L with co-msc110, env-vc10 and au-misra-cpp, the following code will trigger a 948:

    static const sizet SOMESIZE = 42U;
    staticassert( SOMESIZE < 100U, "..." ); // Triggers Note 948: Operator '<' always evaluates to True

    This should not be reported, as this is exactly the point of static_assert to always evaluate to true!

    8 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  13. HIS Source Code Metrics

    The Hersteller Initiative Software (HIS) source code metrics define recommended thresholds for a set of key code quality metrics, to help ensure efficient project and quality management. The HIS Metriken set was originally defined by several large automotive manufacturers (including Audi, BMW Group, DaimlerChrysler, Porsche and Volkswagen), to provide an agreed standard for developing higher quality and more maintainable code for automotive systems.

    The HIS metric set is still widely used within the automotive industry today and many of the same metrics are now specifically required by the ISO 26262 automotive functional safety (FuSa) standard (Section 6). However, the guidelines…

    8 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    The recently released PC-lint Plus version 2.0 includes a comprehensive Metrics solution that provides the ability to report the values of dozens of built in metrics, define custom metrics, and diagnose situations where metrics exceed specified thresholds.  This feature supports calculation and reporting of HIS metrics.  See Chapter 10 of the version 2.0 Reference Manual for details.

  14. enhancement for error 1762 "Member function could be made const"

    The message:
    Pages.cpp(206): error 1762: (Info -- Member function 'xxx:yyy(void)' could be made const)

    could be enhanced to make it easier to type in "const" in both the source and header files:
    1. The line number reference should the first line the function and not the function's closing brace
    2. add a "error 830: (Info -- Location cited in prior message)" line that references the function's declaration in the header file

    7 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    The first part of this request (more useful location for the diagnostic) has been implemented for the upcoming PC-lint Plus. We are declining to implement the second part of the request (adding a supplemental message containing the location of the declaration) but may reconsider if the this is made into a separate suggestion.

  15. Prevent a user to suppress a specific message

    For example I wouldn't want anybody to turn off message '527 Unreachable'. I got some good help on your forum, please see this thread: http://www.gimpel.com/Discussion.cfm?ThreadID=4512. But I think it would be very good if you could add a more intuitive interface for doing this than what's suggested in the thread. Maybe something like this
    +e527
    +efreeze{527}

    7 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    1 comment  ·  Admin →
  16. Add Support for Modified Cyclomatic Complexity

    It would be nice if support was added for "Modified" cyclomatic complexity. It's the metric we prefer to use because we agree that the number of cases a switch statement contains doesn't make a significant difference in how difficult it is to understand the switch statement.

    From https://www.unix.com/man-page/debian/1/pmccabe/

          Modified McCabe Cyclomatic Complexity
          |   Traditional McCabe Cyclomatic Complexity
          |       |    # Statements in function
          |       |        |   First line of function
          |       |        |       |   # lines in function
          |       |        |       |       |  filename(definition line number):function
          |       |        |       |       |       |
          5       6       11      34      27      gettoken.c(35): matchparen
    
       Column
    5 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)

    Hi Kevin, 


    The metric you are looking for is defined as: 


    +metric(function.cyclomatic_complexity_switch_modified = function.cyclomatic_complexity - function.num_switch_cases + function.num_switch_stmts)


    Keep in mind that this will not work on the current version PC-lint Plus 2.0 and will work on the upcoming beta. Since the function needed to make this metric num_switch_cases is not available in PC-lint Pus 2.0. The emails for the beta release will be sent out soon. 

  17. Stop reporting1746 within extern "C" code as its wrong!

    In c++ code which is defining a C interface we get lots of 1746 errors. This is lint telling us to use const reference, how is that gonna work in C! These functions are in extern "C" scope so cannot use references. This seems like a bu/omission as of lint 9.0K.

    4 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    1 comment  ·  Admin →
  18. C99 struct initialization

    Error is generated with the foolowing code, which is valide C99:
    typedef union
    {
    struct
    {
    unsigned int a : 4;
    unsigned int b : 4;
    unsigned int c : 4;
    unsigned int d : 4;
    } bits;
    unsigned short value;
    } My_Value;

    int main(void)
    {
    My_Value test[] =
    {
    {
    .bits.a = 2,
    .bits.b = 3,
    .bits.c = 2,
    .bits.d = 3,
    },
    {
    .bits.a = 1,
    .bits.b = 1,
    .bits.c = 1,
    .bits.d = 0,
    },
    };
    return 0;
    }

    4 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    1 comment  ·  Admin →
  19. Support for labels as values (GNU extension)

    GNU C / Clang support an extension where the address of a label can be taken as a value and assigned to a variable, and then jumped to using goto.
    https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

    For example, this small test program:

    int main(void)
    {
    int r;
    foo:
    r = 4;

    void *f = &&foo;
    
    goto *f;
    
    return 0;
    

    }

    causes the following errors from FlexeLint:

    --- Module: main.c (C)
    _
    void *f = &&foo;
    main.c 8 Error 24: Expected an expression, found '&&'
    main.c 8 Error 40: Undeclared identifier 'foo'
    _
    goto *f;
    main.c 11 Error 10: Expecting identifier

    Is there some combination of…

    3 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
  20. Add output of the received and expected types for messages that indicate type differences

    With the MISRA 2012 "essential type" implementation, we often see messages that indicated "Expression assigned to a narrower or different essential type" or "Composite expression with smaller essential type than other operand". For these types of messages that indicate a discrepancy of type, it would help in debugging these messages if the types involved could be added into the output.

    3 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    completed  ·  3 comments  ·  Admin →
← Previous 1
  • Don't see your idea?

General

Categories

Feedback and Knowledge Base