Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ba5f3a

Browse files
authored
Issue 18: exclude uninstantiated templates (#61)
* Fix issue 18: exclude uninstantiated templates
1 parentd09605b commit5ba5f3a

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-`A7-1-1` -`DeclarationUnmodifiedObjectMissingConstSpecifier.ql`:
2+
- Remove findings in uninstantiated Templates.

‎cpp/autosar/src/rules/A7-1-1/DeclarationUnmodifiedObjectMissingConstSpecifier.ql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ where
3535
cond=" points to an object"
3636
elsecond=" is used for an object"
3737
)and
38-
notexists(LambdaExpressionlc|lc.getACapture().getField()=v)
38+
notexists(LambdaExpressionlc|lc.getACapture().getField()=v)and
39+
notv.isFromUninstantiatedTemplate(_)
3940
selectv,"Non-constant variable "+v.getName()+cond+" and is not modified."

‎cpp/autosar/test/rules/A7-1-1/test.cpp‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,42 @@ class A7_1_1a final {
3939
m_ = a.m;
4040
}
4141
voidCall() {
42-
[this]() { std::cout << m_ <<'\n'; }();// COMPLIANT ignore lambdas
42+
// ignore lambdas
43+
[this]() { std::cout << m_ <<'\n'; }();// COMPLIANT
4344
}
4445

4546
private:
4647
std::string m_;
4748
};
49+
50+
template<typename T>classA7_1_1bfinal {
51+
public:
52+
explicitA7_1_1b(int i)noexcept {
53+
t_.Init(i);
54+
}// t_ is modified here by Init
55+
private:
56+
// ignore uninstantiated templates
57+
T t_;// COMPLIANT
58+
};
59+
60+
classA7_1_1bHelper {
61+
public:
62+
voidInit(int i) {}
63+
};
64+
65+
classIssue18 {
66+
public:
67+
template<typename T>voidF(const T &s) {
68+
// ignore uninstantiated templates
69+
std::ostream ostr;// COMPLIANT
70+
ostr << s;// <= Modified here
71+
return;
72+
}
73+
};
74+
75+
/// main
76+
intmain(int,char **)noexcept {
77+
new A7_1_1b<A7_1_1bHelper>(0);
78+
79+
(new Issue18)->F(0);
80+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp