File: T002.tcl

package info (click to toggle)
vera%2B%2B 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,184 kB
  • sloc: cpp: 10,361; tcl: 921; python: 32; makefile: 5
file content (99 lines) | stat: -rwxr-xr-x 1,726 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/tclsh
# Reserved names should not be used for preprocessor macros

set keywords {
    asm
    auto
    bool
    break
    case
    catch
    char
    class
    const
    const_cast
    continue
    default
    delete
    goto
    do
    double
    dynamic_cast
    else
    enum
    explicit
    export
    extern
    false
    float
    for
    friend
    if
    inline
    int
    long
    mutable
    namespace
    new
    operator
    private
    protected
    public
    register
    reinterpret_cast
    return
    short
    signed
    sizeof
    static
    static_cast
    struct
    switch
    template
    this
    throw
    true
    try
    typedef
    typeid
    typename
    union
    unsigned
    using
    virtual
    void
    volatile
    wchar_t
    while

    and
    and_eq
    bitand
    bitor
    compl
    not
    not_eq
    or
    or_eq
    xor
    xor_eq
}

foreach f [getSourceFileNames] {
    foreach t [getTokens $f 1 0 -1 -1 {pp_define}] {
        set lineNumber [lindex $t 1]

        set line [getLine $f $lineNumber]
        set rest [string trimleft [string range $line \
                                       [expr [lindex $t 2] + [string length [lindex $t 0]]] end]]
        set macroName [string range $rest 0 [expr [string wordend $rest 0] - 1]]

        if {([regexp {^_} $macroName] && [string is upper -strict [string index $macroName 1]]) ||
            [string first "__" $macroName] != -1} {
            report $f $lineNumber "reserved name used for macro (incorrect use of underscore)"
        }
        if {[lsearch $keywords $macroName] != -1} {
            report $f $lineNumber "reserved name used for macro (keyword or alternative token redefined)"
        }
    }
}