Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.19.4 upgrade performance improvements #858

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import codingstandards.cpp.CommonTypes as CommonTypes

abstract class HardwareOrProtocolInterfaceClass extends Class { }

class HardwareOrProtocolInterfaceComment extends Comment {
HardwareOrProtocolInterfaceComment() {
getContents().regexpMatch("(?m)^\\s*(//|\\*)\\s*@HardwareOrProtocolInterface\\s*$")
}
}

class AnnotatedHardwareOrProtocolInterfaceClass extends HardwareOrProtocolInterfaceClass {
AnnotatedHardwareOrProtocolInterfaceClass() {
exists(Comment c, string contents |
c.getCommentedElement() = this.getADeclarationEntry() and
contents =
c.getContents()
.splitAt("\n")
.regexpFind("^\\s*(//|\\*)\\s*@HardwareOrProtocolInterface\\s*$", _, _)
exists(HardwareOrProtocolInterfaceComment c |
c.getCommentedElement() = this.getADeclarationEntry()
)
}
}
Expand Down
24 changes: 13 additions & 11 deletions cpp/autosar/src/rules/A2-3-1/InvalidCharacterInComment.ql
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@
import cpp
import codingstandards.cpp.autosar

bindingset[s]
string getCharOutsideBasicSourceCharSet(string s) {
result = s.regexpFind("[\\u0000-\\u007f]", _, _) and
not result.regexpMatch("[\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@]")
or
result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _)
or
result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _)
or
result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _)
string getCharOutsideBasicSourceCharSet(Comment c) {
exists(string s | s = c.getContents() |
result =
s.regexpFind("(?![\\p{Alnum}\\p{Space}_{}\\[\\]#()<>%:;.?*+-/^&|~!=,\\\\\"'@])[\\u0000-\\u007f]",
_, _)
or
result = s.regexpFind("[\\u00c0-\\u00df][\\u0080-\\u00bf]", _, _)
or
result = s.regexpFind("[\\u00e0-\\u00ef][\\u0080-\\u00bf]{2}", _, _)
or
result = s.regexpFind("[\\u00f0-\\u00f7][\\u0080-\\u00bf]{3}", _, _)
)
}

from Comment c, string ch
where
not isExcluded(c, NamingPackage::invalidCharacterInCommentQuery()) and
ch = getCharOutsideBasicSourceCharSet(c.getContents())
ch = getCharOutsideBasicSourceCharSet(c)
select c,
"Comment uses the character '" + ch + "' that is outside the language basic character set."
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ abstract class OrderingPredicateMustBeStrictlyWeakSharedQuery extends Query { }

Query getQuery() { result instanceof OrderingPredicateMustBeStrictlyWeakSharedQuery }

class IsStrictlyWeaklyOrderedComment extends Comment {
IsStrictlyWeaklyOrderedComment() {
getContents().regexpMatch("(?m)^\\s*(//|\\*)\\s*@IsStrictlyWeaklyOrdered\\s*$")
}
}

/**
* User annotated class indicating a comparator is axiomatically strictly weakly
* ordering.
*/
class UserDefinedStrictlyWeakOrderingComparator extends Class {
UserDefinedStrictlyWeakOrderingComparator() {
exists(Comment c, string contents |
c.getCommentedElement() = this.getADeclarationEntry() and
contents =
c.getContents()
.splitAt("\n")
.regexpFind("^\\s*(//|\\*)\\s*@IsStrictlyWeaklyOrdered\\s*$", _, _)
)
exists(IsStrictlyWeaklyOrderedComment c | c.getCommentedElement() = this.getADeclarationEntry())
}
}

Expand Down
Loading