48     logChecker(
"Check64BitPortability::pointerassignment"); 
 
   57         bool retPointer = 
false;
 
   67             if (tok->str() == 
"{") {
 
   68                 if (tok->scope()->type == Scope::ScopeType::eFunction || tok->scope()->type == Scope::ScopeType::eLambda)
 
   72             if (tok->str() != 
"return")
 
   75             if (!tok->astOperand1() || tok->astOperand1()->isNumber())
 
   78             const ValueType * 
const returnType = tok->astOperand1()->valueType();
 
   85             if (!retPointer && returnType->
pointer >= 1U)
 
   93             if (tok->str() != 
"=")
 
   96             const ValueType *lhstype = tok->astOperand1() ? tok->astOperand1()->valueType() : 
nullptr;
 
   97             const ValueType *rhstype = tok->astOperand2() ? tok->astOperand2()->valueType() : 
nullptr;
 
   98             if (!lhstype || !rhstype)
 
  103                 !tok->astOperand2()->isNumber() &&
 
  106                 rhstype->
type == ValueType::Type::INT)
 
  114                 lhstype->
type >= ValueType::Type::CHAR &&
 
  115                 lhstype->
type <= ValueType::Type::INT)
 
  124                 "AssignmentAddressToInteger",
 
  125                 "Assigning a pointer to an integer is not portable.\n" 
  126                 "Assigning a pointer to an integer (int/long/etc) is not portable across different platforms and " 
  127                 "compilers. For example in 32-bit Windows and linux they are same width, but in 64-bit Windows and linux " 
  128                 "they are of different width. In worst case you end up assigning 64-bit address to 32-bit integer. The safe " 
  135                 "AssignmentIntegerToAddress",
 
  136                 "Assigning an integer to a pointer is not portable.\n" 
  137                 "Assigning an integer (int/long/etc) to a pointer is not portable across different platforms and " 
  138                 "compilers. For example in 32-bit Windows and linux they are same width, but in 64-bit Windows and linux " 
  139                 "they are of different width. In worst case you end up assigning 64-bit integer to 32-bit pointer. The safe " 
  146                 "CastAddressToIntegerAtReturn",
 
  147                 "Returning an address value in a function with integer return type is not portable.\n" 
  148                 "Returning an address value in a function with integer (int/long/etc) return type is not portable across " 
  149                 "different platforms and compilers. For example in 32-bit Windows and Linux they are same width, but in " 
  150                 "64-bit Windows and Linux they are of different width. In worst case you end up casting 64-bit address down " 
  157                 "CastIntegerToAddressAtReturn",
 
  158                 "Returning an integer in a function with pointer return type is not portable.\n" 
  159                 "Returning an integer (int/long/etc) in a function with pointer return type is not portable across different " 
  160                 "platforms and compilers. For example in 32-bit Windows and Linux they are same width, but in 64-bit Windows " 
  161                 "and Linux they are of different width. In worst case you end up casting 64-bit integer down to 32-bit pointer. " 
static const CWE CWE758(758U)
 
Check for 64-bit portability issues.
 
void assignmentAddressToIntegerError(const Token *tok)
 
void returnIntegerError(const Token *tok)
 
void assignmentIntegerToAddressError(const Token *tok)
 
void returnPointerError(const Token *tok)
 
void pointerassignment()
Check for pointer assignment.
 
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg)
report an error
 
const Settings *const mSettings
 
const Tokenizer *const mTokenizer
 
void logChecker(const char id[])
log checker
 
const Token * token
function name token in implementation
 
Function * function
function info for this function
 
const Token * bodyStart
'{' token
 
const Token * bodyEnd
'}' token
 
SimpleEnableGroup< Severity > severity
 
bool isEnabled(T flag) const
 
std::vector< const Scope * > functionScopes
Fast access to function scopes.
 
The token list that the TokenList generates is a linked-list of this class.
 
static bool Match(const Token *tok, const char pattern[], nonneg int varid=0)
Match given token (or list of tokens) to a pattern list.
 
const std::string & strAt(int index) const
 
const SymbolDatabase * getSymbolDatabase() const
 
enum ValueType::Type type
 
nonneg int pointer
0=>not pointer, 1=>*, 2=>**, 3=>***, etc
 
std::string originalTypeName
original type name as written in the source code.
 
const Scope * typeScope
if the type definition is seen this point out the type scope
 
@ portability
Portability warning.