doc: changed --doc output to Markdown syntax

This commit is contained in:
Daniel Marjamäki 2014-09-30 14:56:12 +02:00
parent 8788e58cbb
commit fbc6323a9b
19 changed files with 161 additions and 162 deletions

View File

@ -657,7 +657,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
const std::string& name((*it)->name());
const std::string info((*it)->classInfo());
if (!name.empty() && !info.empty())
doc << "===" << name << "===\n"
doc << "## " << name << " ##\n"
<< info << "\n";
}

View File

@ -81,8 +81,8 @@ private:
std::string classInfo() const {
return "Check if there is 64-bit portability issues:\n"
"* assign address to/from int/long\n"
"* casting address from/to integer when returning from function\n";
"- assign address to/from int/long\n"
"- casting address from/to integer when returning from function\n";
}
};
/// @}

View File

@ -110,12 +110,12 @@ private:
std::string classInfo() const {
return "A pointer to a variable is only valid as long as the variable is in scope.\n"
"Check:\n"
"* returning a pointer to auto or temporary variable\n"
"* assigning address of an variable to an effective parameter of a function\n"
"* returning reference to local/temporary variable\n"
"* returning address of function parameter\n"
"* suspicious assignment of pointer argument\n"
"* useless assignment of function argument\n";
"- returning a pointer to auto or temporary variable\n"
"- assigning address of an variable to an effective parameter of a function\n"
"- returning reference to local/temporary variable\n"
"- returning address of function parameter\n"
"- suspicious assignment of pointer argument\n"
"- useless assignment of function argument\n";
}
};
/// @}

View File

@ -130,14 +130,13 @@ private:
std::string classInfo() const {
return "Boolean type checks\n"
"* using increment on boolean\n"
"* comparison of a boolean with a non-zero integer\n"
"* comparison of a boolean expression with an integer other than 0 or 1\n"
"* comparison of a function returning boolean value using relational operator\n"
"* comparison of a boolean value with boolean value using relational operator\n"
"* using bool in bitwise expression\n"
"* pointer addition in condition (either dereference is forgot or pointer overflow is required to make the condition false)\n";
"- using increment on boolean\n"
"- comparison of a boolean with a non-zero integer\n"
"- comparison of a boolean expression with an integer other than 0 or 1\n"
"- comparison of a function returning boolean value using relational operator\n"
"- comparison of a boolean value with boolean value using relational operator\n"
"- using bool in bitwise expression\n"
"- pointer addition in condition (either dereference is forgot or pointer overflow is required to make the condition false)\n";
}
};
/// @}

View File

@ -70,7 +70,7 @@ private:
std::string classInfo() const {
return "Check for invalid usage of Boost:\n"
"* container modification during BOOST_FOREACH\n";
"- container modification during BOOST_FOREACH\n";
}
};
/// @}

View File

@ -258,16 +258,16 @@ private:
std::string classInfo() const {
return "Out of bounds checking:\n"
"* Array index out of bounds detection by value flow analysis\n"
"* Dangerous usage of strncat()\n"
"* char constant passed as size to function like memset()\n"
"* strncpy() leaving string unterminated\n"
"* Accessing array with negative index\n"
"* Unsafe usage of main(argv, argc) arguments\n"
"* Accessing array with index variable before checking its value\n"
"* Check for large enough arrays being passed to functions\n"
"* Writing beyond bounds of a buffer\n"
"* Allocating memory with a negative size\n";
"- Array index out of bounds detection by value flow analysis\n"
"- Dangerous usage of strncat()\n"
"- char constant passed as size to function like memset()\n"
"- strncpy() leaving string unterminated\n"
"- Accessing array with negative index\n"
"- Unsafe usage of main(argv, argc) arguments\n"
"- Accessing array with index variable before checking its value\n"
"- Check for large enough arrays being passed to functions\n"
"- Writing beyond bounds of a buffer\n"
"- Allocating memory with a negative size\n";
}
};
/// @}

View File

@ -193,23 +193,23 @@ private:
std::string classInfo() const {
return "Check the code for each class.\n"
"* Missing constructors and copy constructors\n"
//"* Missing allocation of memory in copy constructor\n"
"* Are all variables initialized by the constructors?\n"
"* Are all variables assigned by 'operator='?\n"
"* Warn if memset, memcpy etc are used on a class\n"
"* Warn if memory for classes is allocated with malloc()\n"
"* If it's a base class, check that the destructor is virtual\n"
"* Are there unused private functions?\n"
"* 'operator=' should return reference to self\n"
"* 'operator=' should check for assignment to self\n"
"* Constness for member functions\n"
"* Order of initializations\n"
"* Suggest usage of initialization list\n"
"* Initialization of a member with itself\n"
"* Suspicious subtraction from 'this'\n"
"* Call of pure virtual function in constructor/destructor\n"
"* Duplicated inherited data members\n";
"- Missing constructors and copy constructors\n"
//"- Missing allocation of memory in copy constructor\n"
"- Are all variables initialized by the constructors?\n"
"- Are all variables assigned by 'operator='?\n"
"- Warn if memset, memcpy etc are used on a class\n"
"- Warn if memory for classes is allocated with malloc()\n"
"- If it's a base class, check that the destructor is virtual\n"
"- Are there unused private functions?\n"
"- 'operator=' should return reference to self\n"
"- 'operator=' should check for assignment to self\n"
"- Constness for member functions\n"
"- Order of initializations\n"
"- Suggest usage of initialization list\n"
"- Initialization of a member with itself\n"
"- Suspicious subtraction from 'this'\n"
"- Call of pure virtual function in constructor/destructor\n"
"- Duplicated inherited data members\n";
}
// operatorEqRetRefThis helper functions

View File

@ -130,14 +130,14 @@ private:
std::string classInfo() const {
return "Match conditions with assignments and other conditions:\n"
"* Mismatching assignment and comparison => comparison is always true/false\n"
"* Mismatching lhs and rhs in comparison => comparison is always true/false\n"
"* Detect matching 'if' and 'else if' conditions\n"
"* Mismatching bitand (a &= 0xf0; a &= 1; => a = 0)\n"
"* Find dead code which is inaccessible due to the counter-conditions check in nested if statements\n"
"* condition that is always true/false\n"
"* mutual exclusion over || always evaluating to true\n"
"* Comparisons of modulo results that are always true/false.\n";
"- Mismatching assignment and comparison => comparison is always true/false\n"
"- Mismatching lhs and rhs in comparison => comparison is always true/false\n"
"- Detect matching 'if' and 'else if' conditions\n"
"- Mismatching bitand (a &= 0xf0; a &= 1; => a = 0)\n"
"- Find dead code which is inaccessible due to the counter-conditions check in nested if statements\n"
"- condition that is always true/false\n"
"- mutual exclusion over || always evaluating to true\n"
"- Comparisons of modulo results that are always true/false.\n";
}
};
/// @}

View File

@ -163,15 +163,15 @@ private:
/** wiki formatted description of the class (for --doc) */
std::string classInfo() const {
return "Checking exception safety\n"
"* Throwing exceptions in destructors\n"
"* Throwing exception during invalid state\n"
"* Throwing a copy of a caught exception instead of rethrowing the original exception\n"
"* Exception caught by value instead of by reference\n"
"* Throwing exception in noexcept function\n"
"* Throwing exception in nothrow() function\n"
"* Throwing exception in __attribute__((nothrow)) function\n"
"* Throwing exception in __declspec(nothrow) function\n"
"* Unhandled exception specification when calling function foo()\n";
"- Throwing exceptions in destructors\n"
"- Throwing exception during invalid state\n"
"- Throwing a copy of a caught exception instead of rethrowing the original exception\n"
"- Exception caught by value instead of by reference\n"
"- Throwing exception in noexcept function\n"
"- Throwing exception in nothrow() function\n"
"- Throwing exception in __attribute__((nothrow)) function\n"
"- Throwing exception in __declspec(nothrow) function\n"
"- Unhandled exception specification when calling function foo()\n";
}
};
/// @}

View File

@ -150,20 +150,20 @@ private:
}
static std::string myName() {
return "IO";
return "IO using format string";
}
std::string classInfo() const {
return "Check input/output operations.\n"
"* Bad usage of the function 'sprintf' (overlapping data)\n"
"* Missing or wrong width specifiers in 'scanf' format string\n"
"* Use a file that has been closed\n"
"* File input/output without positioning results in undefined behaviour\n"
"* Read to a file that has only been opened for writing (or vice versa)\n"
"* Repositioning operation on a file opened in append mode\n"
"* Using fflush() on an input stream\n"
"* Invalid usage of output stream. For example: 'std::cout << std::cout;'\n"
"* Wrong number of arguments given to 'printf' or 'scanf;'\n";
return "Check format string input/output operations.\n"
"- Bad usage of the function 'sprintf' (overlapping data)\n"
"- Missing or wrong width specifiers in 'scanf' format string\n"
"- Use a file that has been closed\n"
"- File input/output without positioning results in undefined behaviour\n"
"- Read to a file that has only been opened for writing (or vice versa)\n"
"- Repositioning operation on a file opened in append mode\n"
"- Using fflush() on an input stream\n"
"- Invalid usage of output stream. For example: 'std::cout << std::cout;'\n"
"- Wrong number of arguments given to 'printf' or 'scanf;'\n";
}
};
/// @}

View File

@ -105,7 +105,7 @@ private:
/** class info in WIKI format. Used by --doc */
std::string classInfo() const {
return "Null pointers\n"
"* null pointer dereferencing\n";
"- null pointer dereferencing\n";
}
/**

View File

@ -353,59 +353,59 @@ private:
return "Other checks\n"
// error
"* Assigning bool value to pointer (converting bool value to address)\n"
"* division with zero\n"
"* scoped object destroyed immediately after construction\n"
"* assignment in an assert statement\n"
"* free() or delete of an invalid memory location\n"
"* double free() or double closedir()\n"
"* bitwise operation with negative right operand\n"
"* provide wrong dimensioned array to pipe() system command (--std=posix)\n"
"* cast the return values of getc(),fgetc() and getchar() to character and compare it to EOF\n"
"* invalid input values for functions\n"
"- Assigning bool value to pointer (converting bool value to address)\n"
"- division with zero\n"
"- scoped object destroyed immediately after construction\n"
"- assignment in an assert statement\n"
"- free() or delete of an invalid memory location\n"
"- double free() or double closedir()\n"
"- bitwise operation with negative right operand\n"
"- provide wrong dimensioned array to pipe() system command (--std=posix)\n"
"- cast the return values of getc(),fgetc() and getchar() to character and compare it to EOF\n"
"- invalid input values for functions\n"
// warning
"* either division by zero or useless condition\n"
"* memset() with a value out of range as the 2nd parameter\n"
"* return value of certain functions not used\n"
"- either division by zero or useless condition\n"
"- memset() with a value out of range as the 2nd parameter\n"
"- return value of certain functions not used\n"
// performance
"* redundant data copying for const variable\n"
"* subsequent assignment or copying to a variable or buffer\n"
"- redundant data copying for const variable\n"
"- subsequent assignment or copying to a variable or buffer\n"
// portability
"* memset() with a float as the 2nd parameter\n"
"- memset() with a float as the 2nd parameter\n"
// style
"* C-style pointer cast in cpp file\n"
"* casting between incompatible pointer types\n"
"* redundant if\n"
"* passing parameter by value\n"
"* [[IncompleteStatement|Incomplete statement]]\n"
"* [[charvar|check how signed char variables are used]]\n"
"* variable scope can be limited\n"
"* unusual pointer arithmetic. For example: \"abc\" + 'd'\n"
"* redundant assignment in a switch statement\n"
"* redundant pre/post operation in a switch statement\n"
"* redundant bitwise operation in a switch statement\n"
"* redundant strcpy in a switch statement\n"
"* assignment of a variable to itself\n"
"* Suspicious case labels in switch()\n"
"* Suspicious equality comparisons\n"
"* Comparison of values leading always to true or false\n"
"* Clarify calculation with parentheses\n"
"* suspicious comparison of '\\0' with a char* variable\n"
"* duplicate break statement\n"
"* unreachable code\n"
"* testing if unsigned variable is negative\n"
"* testing is unsigned variable is positive\n"
"* Suspicious use of ; at the end of 'if/for/while' statement.\n"
"* Array filled incompletely using memset/memcpy/memmove.\n"
"* redundant get and set function of user id (--std=posix).\n"
"* Passing NULL pointer to function with variable number of arguments leads to UB on some platforms.\n"
"* NaN (not a number) value used in arithmetic expression.\n"
"* comma in return statement (the comma can easily be misread as a semicolon).\n"
"* prefer erfc, expm1 or log1p to avoid loss of precision.\n";
"- C-style pointer cast in cpp file\n"
"- casting between incompatible pointer types\n"
"- redundant if\n"
"- passing parameter by value\n"
"- [Incomplete statement](IncompleteStatement)\n"
"- [check how signed char variables are used](CharVar)\n"
"- variable scope can be limited\n"
"- unusual pointer arithmetic. For example: \"abc\" + 'd'\n"
"- redundant assignment in a switch statement\n"
"- redundant pre/post operation in a switch statement\n"
"- redundant bitwise operation in a switch statement\n"
"- redundant strcpy in a switch statement\n"
"- assignment of a variable to itself\n"
"- Suspicious case labels in switch()\n"
"- Suspicious equality comparisons\n"
"- Comparison of values leading always to true or false\n"
"- Clarify calculation with parentheses\n"
"- suspicious comparison of '\\0' with a char* variable\n"
"- duplicate break statement\n"
"- unreachable code\n"
"- testing if unsigned variable is negative\n"
"- testing is unsigned variable is positive\n"
"- Suspicious use of ; at the end of 'if/for/while' statement.\n"
"- Array filled incompletely using memset/memcpy/memmove.\n"
"- redundant get and set function of user id (--std=posix).\n"
"- Passing NULL pointer to function with variable number of arguments leads to UB on some platforms.\n"
"- NaN (not a number) value used in arithmetic expression.\n"
"- comma in return statement (the comma can easily be misread as a semicolon).\n"
"- prefer erfc, expm1 or log1p to avoid loss of precision.\n";
}
};
/// @}

View File

@ -120,13 +120,13 @@ private:
std::string classInfo() const {
return "sizeof() usage checks\n"
"* sizeof for array given as function argument\n"
"* sizeof for numeric given as function argument\n"
"* using sizeof(pointer) instead of the size of pointed data\n"
"* look for 'sizeof sizeof ..'\n"
"* look for calculations inside sizeof()\n"
"* look for suspicious calculations with sizeof()\n"
"* using 'sizeof(void)' which is undefined\n";
"- sizeof for array given as function argument\n"
"- sizeof for numeric given as function argument\n"
"- using sizeof(pointer) instead of the size of pointed data\n"
"- look for 'sizeof sizeof ..'\n"
"- look for calculations inside sizeof()\n"
"- look for suspicious calculations with sizeof()\n"
"- using 'sizeof(void)' which is undefined\n";
}
};
/// @}

View File

@ -225,19 +225,19 @@ private:
std::string classInfo() const {
return "Check for invalid usage of STL:\n"
"* out of bounds errors\n"
"* misuse of iterators when iterating through a container\n"
"* mismatching containers in calls\n"
"* dereferencing an erased iterator\n"
"* for vectors: using iterator/pointer after push_back has been used\n"
"* optimisation: use empty() instead of size() to guarantee fast code\n"
"* suspicious condition when using find\n"
"* redundant condition\n"
"* common mistakes when using string::c_str()\n"
"* using auto pointer (auto_ptr)\n"
"* useless calls of string and STL functions\n"
"* dereferencing an invalid iterator\n"
"* reading from empty STL container\n";
"- out of bounds errors\n"
"- misuse of iterators when iterating through a container\n"
"- mismatching containers in calls\n"
"- dereferencing an erased iterator\n"
"- for vectors: using iterator/pointer after push_back has been used\n"
"- optimisation: use empty() instead of size() to guarantee fast code\n"
"- suspicious condition when using find\n"
"- redundant condition\n"
"- common mistakes when using string::c_str()\n"
"- using auto pointer (auto_ptr)\n"
"- useless calls of string and STL functions\n"
"- dereferencing an invalid iterator\n"
"- reading from empty STL container\n";
}
};
/// @}

View File

@ -105,13 +105,12 @@ private:
std::string classInfo() const {
return "Detect misusage of C-style strings:\n"
"* overlapping buffers passed to sprintf as source and destination\n"
"* incorrect length arguments for 'substr' and 'strncmp'\n"
"* suspicious condition (runtime comparison of string literals)\n"
"* suspicious condition (string literals as boolean)\n"
"* suspicious comparison of a string literal with a char* variable\n"
"* suspicious comparison of '\\0' with a char* variable\n";
"- overlapping buffers passed to sprintf as source and destination\n"
"- incorrect length arguments for 'substr' and 'strncmp'\n"
"- suspicious condition (runtime comparison of string literals)\n"
"- suspicious condition (string literals as boolean)\n"
"- suspicious comparison of a string literal with a char* variable\n"
"- suspicious comparison of '\\0' with a char* variable\n";
}
};
/// @}

View File

@ -89,9 +89,9 @@ private:
std::string classInfo() const {
return "Type checks\n"
"* bitwise shift by too many bits (only enabled when --platform is used)\n"
"* signed integer overflow (only enabled when --platform is used)\n"
"* dangerous sign conversion, when signed value can be negative\n";
"- bitwise shift by too many bits (only enabled when --platform is used)\n"
"- signed integer overflow (only enabled when --platform is used)\n"
"- dangerous sign conversion, when signed value can be negative\n";
}
};
/// @}

View File

@ -108,8 +108,9 @@ private:
std::string classInfo() const {
return "Uninitialized variables\n"
"* using uninitialized variables and data\n"
"* using dead pointer\n";
"- using uninitialized local variables\n"
"- using allocated data before it has been initialized\n"
"- using dead pointer\n";
}
};
/// @}

View File

@ -101,11 +101,11 @@ private:
return "UnusedVar checks\n"
// style
"* unused variable\n"
"* allocated but unused variable\n"
"* unred variable\n"
"* unassigned variable\n"
"* unused struct member\n";
"- unused variable\n"
"- allocated but unused variable\n"
"- unred variable\n"
"- unassigned variable\n"
"- unused struct member\n";
}
std::map<const Type *,bool> isRecordTypeWithoutSideEffectsMap;

View File

@ -67,16 +67,16 @@ private:
}
static std::string myName() {
return "CheckVaarg";
return "Vaarg";
}
std::string classInfo() const {
return "Check for misusage of variable argument lists:\n"
"* Wrong parameter passed to va_start()\n"
"* Reference passed to va_start()\n"
"* Missing va_end()\n"
"* Using va_list before it is opened\n"
"* Subsequent calls to va_start/va_copy()\n";
"- Wrong parameter passed to va_start()\n"
"- Reference passed to va_start()\n"
"- Missing va_end()\n"
"- Using va_list before it is opened\n"
"- Subsequent calls to va_start/va_copy()\n";
}
};