view vera/rules/T017.tcl @ 521:e03521cf207b

Common: split util.hpp into more appropriate files, closes #721
author David Demelier <markand@malikania.fr>
date Fri, 27 Oct 2017 21:45:32 +0200
parents 6ec510722582
children
line wrap: on
line source

#!/usr/bin/tclsh
# Unnamed namespaces are not allowed in header files

foreach fileName [getSourceFileNames] {
    set extension [file extension $fileName]
    if {[lsearch {.h .hh .hpp .hxx .ipp} $extension] != -1} {

        set state "start"
        foreach token [getTokens $fileName 1 0 -1 -1 {namespace identifier leftbrace}] {
            set type [lindex $token 3]

            if {$state == "namespace" && $type == "leftbrace"} {
                report $fileName $namespaceLine "unnamed namespace not allowed in header file"
            }

            if {$type == "namespace"} {
                set namespaceLine [lindex $token 1]
            }

            set state $type
        }
    }
}