Skip to content

Commit 60df95b

Browse files
authored
Merge pull request #304 from mbaluda/cpp-qcc-compile
Pass all `c++` tests when compiled with `qcc`
2 parents 738c5b8 + f31de91 commit 60df95b

File tree

95 files changed

+1060
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+1060
-208
lines changed
Lines changed: 18 additions & 0 deletions

cpp/autosar/src/rules/A0-4-1/FloatingPointImplementationShallComplyWithIeeeStandard.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import codingstandards.cpp.autosar
2121
import codingstandards.cpp.TypeUses
2222

2323
class NumericLimits extends Class {
24-
NumericLimits() { this.hasQualifiedName("std", "numeric_limits") }
24+
NumericLimits() { this.hasQualifiedName("std", ["numeric_limits", "__libcpp_numeric_limits"]) }
2525

2626
/**
2727
* Gets the template argument specified for this type.

cpp/autosar/src/rules/A0-4-3/CompilerImplementationShallComplyWithCPP14Standard.ql

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ from File f, string flag
2020
where
2121
not isExcluded(f, ToolchainPackage::compilerImplementationShallComplyWithCPP14StandardQuery()) and
2222
exists(Compilation c | f = c.getAFileCompiled() |
23-
c.getAnArgument() = flag and flag.regexpMatch("-std=(?!c\\+\\+14)[\\w+]+")
24-
)
23+
flag =
24+
max(string std, int index |
25+
c.getArgument(index) = std and std.matches("-std=%")
26+
|
27+
std order by index
28+
)
29+
) and
30+
flag != "-std=c++14"
2531
select f,
2632
"File '" + f.getBaseName() + "' compiled with flag '" + flag +
2733
"' which does not strictly comply with ISO C++14."

cpp/autosar/src/rules/A1-1-1/StrstreamTypesAreDeprecated.ql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414

1515
import cpp
1616
import codingstandards.cpp.autosar
17-
import codingstandards.cpp.TypeUses
1817

19-
from Class c, Locatable l
18+
from TypeMention l, Class c
2019
where
2120
not isExcluded(l, ToolchainPackage::strstreamTypesAreDeprecatedQuery()) and
2221
c.hasQualifiedName("std", ["strstreambuf", "ostrstream", "istrstream"]) and
23-
exists(Type t | t = c | l = getATypeUse(t))
24-
select l, "Use of <strstream> class '" + c.getQualifiedName() + "' is deprecated."
22+
l.getMentionedType() = c
23+
select l, "Use of <strstream> class '" + c.getName() + "' is deprecated."

cpp/autosar/src/rules/A1-1-3/UncompliantOptimizationOptionMustBeDisabledInCompiler.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
c.getAnArgument() = flag and
2727
flag =
2828
[
29-
"-Ofast", "-ffast-math", "-fgnu-keywords", "-fno-signed-zeroes", "-fno-signed-zeros", "-menable-unsafe-fp-math",
29+
"-Ofast", "-ffast-math", "-fgnu-keywords", "-fno-signed-zeros", "-menable-unsafe-fp-math",
3030
"-menable-no-nans", "-menable-no-infs", "-menable-unsafe-fp-math", "-ffinite-math-only",
3131
"-ffloat-store"
3232
]

cpp/autosar/src/rules/A17-1-1/CStandardLibraryFunctionCalls.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import cpp
1818
import codingstandards.cpp.autosar
1919
import codingstandards.cpp.Naming
20+
import codingstandards.cpp.StdNamespace
2021

2122
FunctionCall nonCompliantCStdlibCalls(File f) {
2223
result =
@@ -55,7 +56,7 @@ FunctionCall nonCompliantCStdlibCalls(File f) {
5556
nq = fc.getNameQualifier() and
5657
(
5758
nq.getQualifyingElement() instanceof GlobalNamespace or
58-
nq.getQualifyingElement() instanceof StdNamespace
59+
nq.getQualifyingElement() instanceof StdNS
5960
)
6061
)
6162
)

cpp/autosar/src/rules/A18-1-2/VectorboolSpecializationUsed.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717

1818
import cpp
1919
import codingstandards.cpp.autosar
20+
import codingstandards.cpp.StdNamespace
2021

2122
predicate isVectorBool(ClassTemplateInstantiation c) {
22-
c.getNamespace() instanceof StdNamespace and
23+
c.getNamespace() instanceof StdNS and
2324
c.getTemplateArgument(0) instanceof BoolType and
2425
c.getSimpleName() = "vector"
2526
}

cpp/autosar/src/rules/A18-1-3/AutoPtrTypeUsed.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515

1616
import cpp
1717
import codingstandards.cpp.autosar
18+
import codingstandards.cpp.StdNamespace
1819

1920
predicate isAutoPtr(ClassTemplateInstantiation c) {
20-
c.getNamespace() instanceof StdNamespace and
21+
c.getNamespace() instanceof StdNS and
2122
c.getSimpleName() = "auto_ptr"
2223
}
2324

cpp/autosar/src/rules/A18-9-1/BindUsed.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515

1616
import cpp
1717
import codingstandards.cpp.autosar
18+
import codingstandards.cpp.StdNamespace
1819

1920
predicate isBind(FunctionCall fc) {
20-
fc.getTarget().getQualifiedName() in ["std::bind", "std::bind1st", "std::bind2nd"]
21+
fc.getTarget().getNamespace() instanceof StdNS and
22+
fc.getTarget().getName() in ["bind", "bind1st", "bind2nd"]
2123
}
2224

2325
from FunctionCall fc
2426
where
2527
isBind(fc) and
2628
not isExcluded(fc, BannedFunctionsPackage::bindUsedQuery())
27-
select fc, "Prefer lambdas to using " + fc.getTarget().getQualifiedName() + "."
29+
select fc, "Prefer lambdas to using `" + fc.getTarget().getName() + "`."

cpp/autosar/src/rules/A2-13-3/TypeWcharTUsed.ql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ predicate isUsingWideCharType(ClassTemplateInstantiation c) {
2626

2727
from Variable v
2828
where
29-
v.getUnderlyingType() instanceof WideCharType and
30-
not v.isFromTemplateInstantiation(_)
31-
or
32-
exists(ClassTemplateInstantiation c |
33-
c = v.getType() and
34-
isUsingWideCharType(c)
35-
) and
36-
not isExcluded(v, BannedTypesPackage::typeWcharTUsedQuery())
29+
not isExcluded(v, BannedTypesPackage::typeWcharTUsedQuery()) and
30+
(
31+
v.getUnderlyingType() instanceof WideCharType and
32+
not v.isFromTemplateInstantiation(_)
33+
or
34+
exists(ClassTemplateInstantiation c |
35+
c = v.getType() and
36+
isUsingWideCharType(c)
37+
)
38+
)
3739
select v, "Use of wchar_t type."

0 commit comments

Comments
 (0)