Skip to content

Commit 576499a

Browse files
authoredMar 31, 2023
Merge pull request #288 from github/lcartey/rule-7-4-perf
Rule 7.4: Improve performance
2 parents 966f5c3 + 7dfca8f commit 576499a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
 

‎c/misra/src/rules/RULE-7-4/StringLiteralAssignedToNonConstChar.ql

+9-5
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ class WideCharPointerType extends PointerType {
2020
override string getAPrimaryQlClass() { result = "WideCharPointerType" }
2121
}
2222

23-
class GenericCharPointerType extends PointerType {
23+
class GenericCharPointerType extends Type {
2424
GenericCharPointerType() {
25-
/* This type resolves to wchar_t* (which is in turn a typedef depending on its implementation) */
26-
this.resolveTypedefs*() instanceof WideCharPointerType
25+
// A wide char pointer type
26+
this instanceof WideCharPointerType
2727
or
28-
/* This type eventually resolves to char* */
29-
this.resolveTypedefs*() instanceof CharPointerType
28+
// A char pointer type
29+
this.getUnspecifiedType() instanceof CharPointerType
30+
or
31+
// A typedef to any such type.
32+
// Note: wchar_t is usually a typedef, so we cannot just use getUnspecifiedType() here.
33+
this.(TypedefType).getBaseType() instanceof GenericCharPointerType
3034
}
3135
}
3236

0 commit comments

Comments
 (0)
Please sign in to comment.