Using CAC++ as a user

List of verifications

  • The full list of verificactions available in the library can be seen in "caclibrary.h".
  • Each of the verifications includes:
    • A description of the utility of the verification.
    • The signature of the method to invoke the verification.
    • A description of the parameters to configure the verification.
    • Examples of different situations that pass and fail the verification.

Shared parameters

There are some parameters that are shared for all or several of the available verifications:
  • string message:

    Optionally, you can include a parameter with the message to be shown when the check fails. If this parameter is not included, a default message will be shown.

  • bool exist:

    By default, a check validates the existence of an element in the code. With this parameter, this behavior can be inverted to validate that an element does not exist in the code. By default, the parameter is set to "true".

  • string constant:

    This parameter can be usedTo indicate whether a method is constant (in this case, "const") or not (in this case, "noconst");


Considerations

There are also some considerations that should be taken into account when using the library:
  • Methods: A particular method is identified by:
    1. the class to which it belongs.
    2. its name.
    3. a list of types of its parameters (and no by its names).
    4. whether it is constant or not.

  • Overloading: If the method is an overloaded operator, the name will be the word "operator" followed by the operator without leaving any spaces in between. For example "operator+=".

  • Types: Regarding the types, the original type has to be indicated, that is, without taking into account typedef or alias.

    For example:

     typedef unsigned long myType;
    int method(myType parameter);
    The type of "parameter" is "unsigned long" and no "myType".

  • Wildcards: In some parameters of some of these checks, it is allowed to introduce "?" (interrogation mark) to indicate that the parameter does not have to be taken into account. This is mainly useful when that information is not known.

    For example, if "{"?"}" is set as the list of parameters of a method, the check will not adhere to a particular method, but it will try to match all the methods with the same name in the indicated class (regardless of their parameters).
    In the descriptions of the checks in this file, this property is indicated with (?).

    Note:
    • In the case of setting "?" as argument of a parameter to indicate the list of parameters of a method, the check will not take into account the parameter list. We have to distinguish between this case and the situation of a method without parameters; that case is indicated with an empty list {}.

  • Regular expressions: In some parameters of some of these checks, it is allowed to use a regular exprression. This is mainly useful when the name of the element to be searched is not fixed.

    For example, if "A.*" is set as the name of a class, the check will apply to all the classes whose name starts with "A".

    In the descriptions of the checks in this file, this property is indicated with (*).

Setup

  • Makefile: Copy and paste the Makefile included in example.tar. Then:
    1. Change the variables:
      • CHECKSOURCE: user-created file with the invocation to the verifications (lecturer's file).
      • FILESTOCHECK: list of files to be analyzed with the program. (student's files).
      • CACDIR: path to the directory of the library.

    2. Optionally, change the target "check" to include any extra options required to analyze the files. The command "make check" should analyze the source files generated by the student with the static analysis program that you have developed.

  • "checkCode" object: The "checkCode" object created to analyze a source file has a constructor that receives:
    1. argc.
    2. argv.
    3. Name of the source file of the student.
    4. String to display when running the executable with option --help.

    Example:

     checkCode c(argc, argv, "student.cpp", "Command: ./example student.cpp");
    Note that more than one file can be analyzed in the same execution, but different "checkCode" objects have to be created to address each of those files (each of them should have a different file as third parameter in the call to the constructor).