주요 콘텐츠

Cpp.Type Class

Namespace: Cpp
Superclasses: ObjectWithPosition

Represents the type of a C/C++ object

Since R2026a

Description

Type class represents the type of an object. This class inherits from the class ObjectWithPosition. You can use the predicates associated with this class and the base class with objects of this object.

Predicates

expand all

Examples

collapse all

  1. In a new folder Field, initialize a new coding standard. At the command line, enter:

    polyspace-query-language init

  2. In the file main.pql, enter this content:

    package main
    
    // Main PQL file defines the catalog of your PQL project.
    // The catalog is a collection of sections.
    catalog FieldExample = {
    #[Description("Example Section")]
    	section ExampleSection = {
    #[Description("Unused public field in header"),Id(myRule)]
    		rule ExampleRule = {
    			defect Exampledefect =
    			when			
    				Cpp.Field.is(&field)
    				and field.isUnused()
    				and field.isPublic()
    				and field.extension(&ext)
    				and ext == ".h"
    				and field.filename(&fnstr)
    			raise "Unused public field in header: \"{fnstr}\""
    			on field
    
    		}
    	}
    }

  3. Create the coding standard Field.pschk using this command at the command line:

    polyspace-query-language package

  4. Using the generated coding standard, run a Bug Finder analysis on your source file. Foe example, at the command line, enter:

    polyspace-bug-finder -sources src.cpp -lang cpp -checkers-activation-file Field.pschk
    The analysis reports defects on the unused member variable unusedField in the header file src.h.

Version History

Introduced in R2026a