Coverage Report

Created: 2025-01-24 06:31

/src/cppcheck/lib/check64bit.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- C++ -*-
2
 * Cppcheck - A tool for static C/C++ code analysis
3
 * Copyright (C) 2007-2024 Cppcheck team.
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
20
//---------------------------------------------------------------------------
21
#ifndef check64bitH
22
#define check64bitH
23
//---------------------------------------------------------------------------
24
25
#include "check.h"
26
#include "config.h"
27
28
#include <string>
29
30
class ErrorLogger;
31
class Settings;
32
class Token;
33
class Tokenizer;
34
35
/// @addtogroup Checks
36
/// @{
37
38
/**
39
 * @brief Check for 64-bit portability issues
40
 */
41
42
class CPPCHECKLIB Check64BitPortability : public Check {
43
    friend class Test64BitPortability;
44
45
public:
46
    /** This constructor is used when registering the Check64BitPortability */
47
2
    Check64BitPortability() : Check(myName()) {}
48
49
private:
50
    /** This constructor is used when running checks. */
51
    Check64BitPortability(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
52
764
        : Check(myName(), tokenizer, settings, errorLogger) {}
53
54
    /** @brief Run checks against the normal token list */
55
    void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override;
56
57
    /** Check for pointer assignment */
58
    void pointerassignment();
59
60
    void assignmentAddressToIntegerError(const Token *tok);
61
    void assignmentIntegerToAddressError(const Token *tok);
62
    void returnIntegerError(const Token *tok);
63
    void returnPointerError(const Token *tok);
64
65
    void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override;
66
67
766
    static std::string myName() {
68
766
        return "64-bit portability";
69
766
    }
70
71
0
    std::string classInfo() const override {
72
0
        return "Check if there is 64-bit portability issues:\n"
73
0
               "- assign address to/from int/long\n"
74
0
               "- casting address from/to integer when returning from function\n";
75
0
    }
76
};
77
/// @}
78
//---------------------------------------------------------------------------
79
#endif // check64bitH