GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C++: Fix FP: bad Location for FieldAccess exprs · github/codeql@96c73bc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • cpp/ql
    • src/Best Practices/Likely Errors
      • CommaBeforeMisleadingIndentation.ql
    • test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation
      • test.cpp
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql‎

Copy file name to clipboardExpand all lines: cpp/ql/src/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation.ql
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ Expr normalizeExpr(Expr e) {
1616
if exists(e.(Call).getQualifier())
1717
then result = normalizeExpr(e.(Call).getQualifier())
1818
else
19-
if e.hasExplicitConversion()
20-
then result = normalizeExpr(e.getFullyConverted())
21-
else result = e
19+
if exists(e.(FieldAccess).getQualifier())
20+
then result = normalizeExpr(e.(FieldAccess).getQualifier())
21+
else
22+
if e.hasExplicitConversion()
23+
then result = normalizeExpr(e.getFullyConverted())
24+
else result = e
2225
}
2326

2427
predicate isInLoopHead(CommaExpr ce) {
@@ -45,4 +48,4 @@ where
4548
not isInDecltypeOrSizeof(ce) and // <- Removes arguable FPs since, like function calls (and loop heads), these Exprs have clear delimiters.
4649
leftLoc.getEndLine() < rightLoc.getStartLine() and
4750
leftLoc.getStartColumn() > rightLoc.getStartColumn()
48-
select right, "The indentation after the comma may be misleading (for some tab sizes)."
51+
select right, "The indentation level may be misleading (for some tab sizes)."
Collapse file

‎cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp‎

Copy file name to clipboardExpand all lines: cpp/ql/test/query-tests/Best Practices/Likely Errors/CommaBeforeMisleadingIndentation/test.cpp
+13-2Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,26 @@ int test(int i, int j, int (*foo)(int), int (*bar)(int, int))
122122
i++
123123
), j++); // GOOD?
124124

125-
// Weird case:
125+
// Weird cases:
126126

127127
if (foo(j))
128128
return i++
129129
, i++ // GOOD(?) [FALSE POSITIVE] -- can't exclude w/o source code text :/
130130
? 1
131131
: 2;
132132

133-
return 0;
133+
struct {
134+
struct {
135+
void tutu() {}
136+
long toto() { return 42; }
137+
} titi;
138+
} *tata;
139+
140+
int quux =
141+
(tata->titi.tutu(),
142+
foo(tata->titi.toto())); // GOOD
143+
144+
return quux;
134145
}
135146

136147
// Comma in variadic template splice:

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.