RuleDescriptionExampleKPI
debug.AnalysisOrderPrint callbacks that are called during analysis in orderMaintainability
debug.ConfigDumperDump config tableMaintainability
debug.DumpBugHashDump the bug hash for all statements.Maintainability
debug.DumpCallGraphDisplay Call GraphMaintainability
debug.DumpCallsPrint calls as they are traversed by the engineMaintainability
debug.DumpCFGDisplay Control-Flow GraphsMaintainability
debug.DumpDominatorsPrint the dominance tree for a given CFGMaintainability
debug.DumpLiveVarsPrint results of live variable analysisMaintainability
debug.DumpTraversalPrint branch conditions as they are traversed by the engineMaintainability
debug.ExprInspectionCheck the analyzer’s understanding of expressionsMaintainability
debug.StatsEmit warnings with analyzer statisticsMaintainability
debug.TaintTestMark tainted symbols as such.Maintainability
debug.ViewCallGraphView Call Graph using GraphVizMaintainability
debug.ViewCFGView Control-Flow Graphs using GraphVizMaintainability
debug.ViewExplodedGraphView Exploded Graphs using GraphVizMaintainability
llvm.ConventionsCheck code for LLVM codebase conventionsMaintainability
llvm.ConventionsCheck code for LLVM codebase conventionsMaintainability
empty-catch The catch block should not be vacant. If you catch an exception, ensure you process it and avoid an unexpected behavior in the system.Complaint Code:
int x = -1;
try
{
if (x < 0)
{
throw x;
}
}
catch (int x )
{
cout<<"Exception caught";
}



Non-Complaint Code:
int x = -1;
try
{
if (x < 0)
{
throw x;
}
}
catch (int x )
{

}
Maintainability
char signednessSpecify the signess of char explicitly. Else, the compiler which is not portable can cause subtle errors if a char is unexpectedly "signed" instead of unsigned.Complaint Code:
unsigned char abc;
signed char xyz;

Non-Complaint Code:

char abc;
char xyz;
Maintainability
fixed size memory operation Memory operations should not be called with a hard-coded value instead of using a macro or sizeof() or constant. This can be quickly forgotten while changing the size.

Complaint Code:
char str1[] = "abc";
char str2[] = "xyz";
memcpy (str1, str2, sizeof(str2));

Non-Complaint Code:



char str1[] = "abc";
char str2[] = "xyz";
memcpy (str1, str2, 4);
Maintainability
hidden parameterA function declares a variable with the same name as a parameter, which is then "hidden".Complaint Code:



int add(int a, int b)
{
int a1;
int x = 1;



if(x == 1)
{
int b1;
}
return 0;
}




Non-Complaint Code:



int add(int a, int b)
{
int a; /* reuse of 'a' */
int x = 1;



if(x == 1)
{
int b; /* reuse of 'b' */
}
return 0;
}
Maintainability
hidden parameterA function declares a variable with the same name as a parameter, which is then "hidden".Complaint Code:



int add(int a, int b)
{
int a1;
int x = 1;



if(x == 1)
{
int b1;
}
return 0;
}




Non-Complaint Code:



int add(int a, int b)
{
int a; /* reuse of 'a' */
int x = 1;



if(x == 1)
{
int b; /* reuse of 'b' */
}
return 0;
}
Maintainability
deactivated codeCode segments that are permanently disabled by the preprocessor. Indication of inactive code. Only cases with condition would be OK.Non-complaint code:

#if 0 /* Non-Complaint */
#if 1 /* Non-Complaint */

Complaint Code:

#if 0 == xyz /* Complaint */

Maintainability
Assignment Operator Non-Const ArgAssignment operator must not have non-const argument.Non-complaint code:

class Alpha {

const Alpha& operator=(Alpha& pOther) /* Non-Compliant - Argument must be of type "const Alpha&" */
{
//assignment operation
}
};

Complaint Code:
struct Beta {

const Beta& operator=(Beta& pOther) /* Non-Compliant - Argument must be of type "const Beta&" */
{
//assignment operation
}
};

Robustness
Assignment Operator Returns VoidAssignment operator must return a valid object. Return type should not be void.Non-Complaint code:

class Alpha {

void operator=(const Alpha& pOther) /* Non-Compliant - Return type must not be "void" */
{
//assignment operation
}
};


Complaint Code:


struct Beta {

void operator=(const Beta& pOther) /* Non-Compliant - Return type must not be "void" */
{
//assignment operation
}
};
Robustness
Assignment Operator Non-Const ReturnAssignment operator must return const qualified valid object.Non-Complaint code:

class Alpha {

Alpha& operator=(const Alpha& pOther) /* Non-Compliant - Return type must be "const Alpha&" */
{
//assignment operation
return *this;
}
};


Complaint Code:


struct Beta {

Beta& operator=(const Beta& pOther) /* Non-Compliant - Return type must be "const Beta&" */
{
//assignment operation
return *this;
}
};
Robustness