-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathCompilerWarningLevelNotInCompliance.ql
34 lines (30 loc) · 1.39 KB
/
CompilerWarningLevelNotInCompliance.ql
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
/**
* @id cpp/autosar/compiler-warning-level-not-in-compliance
* @name A1-1-2: A warning level of the compilation process shall be set in compliance with project policies
* @description If compiler enables the high warning level, then it is able to generate useful
* warning messages that point out potential run-time problems during compilation time.
* The information can be used to resolve certain errors before they occur at run-time.
* @kind problem
* @precision very-high
* @problem.severity recommendation
* @tags external/autosar/id/a1-1-2
* maintainability
* external/autosar/allocated-target/implementation
* external/autosar/allocated-target/toolchain
* external/autosar/enforcement/non-automated
* external/autosar/obligation/required
*/
import cpp
import codingstandards.cpp.autosar
class CompilationWithNoWarnings extends Compilation {
CompilationWithNoWarnings() {
getAnArgument() = "-w" or
not getAnArgument().regexpMatch("-W[\\w=-]+")
}
}
predicate hasResponseFileArgument(Compilation c) { c.getAnArgument().matches("@%") }
from File f
where
not isExcluded(f, ToolchainPackage::compilerWarningLevelNotInComplianceQuery()) and
exists(CompilationWithNoWarnings c | f = c.getAFileCompiled() | not hasResponseFileArgument(c))
select f, "No warning-level options were used in the compilation of '" + f.getBaseName() + "'."