Skip to content

Spelling cpp#10825

Merged
jketema merged 52 commits intogithub:mainfrom
jsoref:spelling-cpp
Oct 17, 2022
Merged

Spelling cpp#10825
jketema merged 52 commits intogithub:mainfrom
jsoref:spelling-cpp

Conversation

@jsoref
Copy link
Copy Markdown
Contributor

@jsoref jsoref commented Oct 13, 2022

follow-up to #10743

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
@jsoref jsoref requested a review from a team as a code owner October 13, 2022 23:59
* - `ConstantSignExpr`, for expressions with a compile-time constant value.
* - `FlowSignExpr`, for expressions whose sign can be computed from the signs of their operands.
* - `CustomsignExpr`, for expressions shose sign can be computed by a language-specific
* - `CustomsignExpr`, for expressions whose sign can be computed by a language-specific
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Google Sheets didn't guess this correction...

// not inside a template instantiation
not exists(Element other | this.isFromTemplateInstantiation(other)) or
// allow DeclarationEntrys of template specializations
// allow DeclarationEntries of template specializations
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeclarationEntry is probably a term. I left this change in to be able to hang this comment. I expect to drop this change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be something like

`DeclarationEntry`s

but I see already below that if we go down that route we should fix a bunch more formatting issues in this file, so this is probably better dealt with separately.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that

`DeclarationEntry`s

is preferable (rendered as DeclarationEntrys), the original is also OK.

Comment thread cpp/ql/lib/semmle/code/cpp/metrics/MetricFile.qll Outdated
Comment thread cpp/ql/lib/upgrades/initial/semmlecode.cpp.dbscheme Outdated
switch(c1){
...
dafault: // BAD: maybe it will be right `default`
default: // BAD: maybe it will be right `default`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This correction is probably wrong

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please revert. This shows we detect spelling mistakes in C/C++ code 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally, I encourage using things like default0, default_, or de_fault since they tend to be functionally equivalent in that they show that your tool catches spelling mistakes, while not actually upsetting spell checkers.

That said, I'm going to drop this and if there's interest, a change like that can be its own distinct PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on what the query actually checks for. I can have a look at that next week.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encourage using things like default0, default_, or de_fault since they tend to be functionally equivalent in that they show that your tool catches spelling mistakes

Unfortunately that's not going to work here, as the query looks for specific substitutions. This is the relevant query code:

      (
        lb.getName().charAt(0) = "d" or
        lb.getName().charAt(0) = "c"
      ) and
      (
        lb.getName().charAt(1) = "e" or
        lb.getName().charAt(1) = "a"
      ) and
      (
        lb.getName().charAt(2) = "f" or
        lb.getName().charAt(2) = "s"
      )

Note that the query is marked as experimental, so the bar on query quality is very low here.

Copy link
Copy Markdown
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few small comments but otherwise LGTM.

// not inside a template instantiation
not exists(Element other | this.isFromTemplateInstantiation(other)) or
// allow DeclarationEntrys of template specializations
// allow DeclarationEntries of template specializations
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should be something like

`DeclarationEntry`s

but I see already below that if we go down that route we should fix a bunch more formatting issues in this file, so this is probably better dealt with separately.

Comment thread cpp/ql/lib/semmle/code/cpp/metrics/MetricFile.qll Outdated
Comment thread cpp/ql/lib/upgrades/initial/semmlecode.cpp.dbscheme Outdated
switch(c1){
...
dafault: // BAD: maybe it will be right `default`
default: // BAD: maybe it will be right `default`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please revert. This shows we detect spelling mistakes in C/C++ code 😄

Copy link
Copy Markdown
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly horrified to see this amount of typos, missing characters and (incorrect) phonetic spellings that have accumulated in our code; and surely instyructions could only have been caused by a cosmic ray?

Thanks for fixing.

* The `security` tag has been added to the `cpp/return-stack-allocated-memory` query. As a result, its results will now appear by default.
* The "Uncontrolled data in arithmetic expression" (cpp/uncontrolled-arithmetic) query has been enhanced to reduce false positive results and its @precision increased to high.
* A new `cpp/very-likely-overruning-write` query has been added to the default query suite for C/C++. The query reports some results that were formerly flagged by `cpp/overruning-write`.
* A new `cpp/very-likely-overrunning-write` query has been added to the default query suite for C/C++. The query reports some results that were formerly flagged by `cpp/overrunning-write`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure editing a past release not will affect anything, though I suppose there's no harm in trying.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was also done in the case of some of the other spelling PRs. I'm guessing this is fine, these changes just not get included in the previous releases.

not ae instanceof ForStmtSideEffectExpr
select ae,
"AV Rule 160: An assignment expression shall be used only as the exprression in an expression statement."
"AV Rule 160: An assignment expression shall be used only as the expression in an expression statement."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit disappointed there are apparently no test cases for these two old queries (but I'm happy with the spelling fixes on them).


/** Holds if there are labels inside the block with names similar to `default` or `case`. */
predicate isWrongLableName(SwitchStmt swtmp) {
predicate isWrongLabelName(SwitchStmt swtmp) {

Check warning

Code scanning / CodeQL

Missing QLDoc for parameter

The QLDoc has no documentation for swtmp, but the QLDoc mentions case
Comment thread cpp/ql/src/definitions.ql
Comment thread cpp/ql/lib/semmle/code/cpp/metrics/MetricFile.qll Outdated
@jsoref
Copy link
Copy Markdown
Contributor Author

jsoref commented Oct 14, 2022

Ok, this PR and #10824 conceptually conflict in that they both will trigger a complaint akin to:
https://github.com/github/codeql/actions/runs/3246489164/jobs/5331736472

Run python config/sync-files.py
Loading file groups from ./config/identical-files.json
ERROR: config/sync-files.py:0 - Files from group 'IR Instruction' not in sync.
ERROR: config/sync-files.py:0 - Run this script with a file-name argument among the following to overwrite the remaining files with the contents of that file, or run with the --latest switch to update each group of files from the most recently modified file in the group.
ERROR: config/sync-files.py:0 -     ./cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/Instruction.qll
ERROR: config/sync-files.py:0 -     ./cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll
ERROR: config/sync-files.py:0 -     ./cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll
ERROR: config/sync-files.py:0 -     ./csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll
ERROR: config/sync-files.py:0 -     ./csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll
ERROR: config/sync-files.py:0 - Files from group 'IR SSA SSAConstruction' not in sync.
ERROR: config/sync-files.py:0 - Run this script with a file-name argument among the following to overwrite the remaining files with the contents of that file, or run with the --latest switch to update each group of files from the most recently modified file in the group.
ERROR: config/sync-files.py:0 -     ./cpp/ql/lib/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll
ERROR: config/sync-files.py:0 -     ./cpp/ql/lib/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll
ERROR: config/sync-files.py:0 -     ./csharp/ql/src/experimental/ir/implementation/unaliased_ssa/internal/SSAConstruction.qll
Error: Process completed with exit code 1.
for a in cpp csharp; do echo $a; git log --oneline --graph main..spelling-$a -- ./cpp/ql/lib/semmle/code/cpp/ir/implementation ./csharp/ql/src/experimental/ir/implementation ; done
cpp
* 991067cb20 spelling: instructions
* ab88b3f56d spelling: hypothetical
* e2f8d7e1ab spelling: exploit
* b244d01a37 spelling: dynamic
* 87d1a8b02a spelling: different
* ad192497ba spelling: circuit
* d3802b378e spelling: aliased
csharp
* 3afbdf7f1b spelling: opposed
* b61e02cc17 spelling: known
* a3f1affff7 spelling: instructions
* 0e09910601 spelling: hypothetical
* 9383e1f549 spelling: dynamic
* bf7011612c spelling: different

I'll need to pull some changes into one of these two and drop them from the other (or kick them into a third). I've done each and have no particular preference.

@jsoref jsoref requested a review from a team as a code owner October 14, 2022 14:50
@github-actions github-actions Bot added the C# label Oct 14, 2022
Copy link
Copy Markdown
Contributor Author

@jsoref jsoref left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've synced over the cpp/csharp shared unit bits using something equivalent to this:

while [ -e .git/rebase-merge/git-rebase-todo ] ; do
  python3 config/sync-files.py --latest
  git add -u
  GIT_EDITOR=true git rebase --continue
done

* containing the `ExitFunction` instruction for that function.
*
* There are two differet return instructions: `ReturnValueInstruction`, for returning a value from
* There are two different return instructions: `ReturnValueInstruction`, for returning a value from
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* If the operand holds a null address, the result is a null address.
*
* This instruction is used to represent `dyanmic_cast<void*>` in C++, which returns the pointer to
* This instruction is used to represent `dynamic_cast<void*>` in C++, which returns the pointer to
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* If the operand holds a null address, the result is a null address.
*
* This instruction is used to represent `dyanmic_cast<void*>` in C++, which returns the pointer to
* This instruction is used to represent `dynamic_cast<void*>` in C++, which returns the pointer to
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instr = reusedPhiInstruction(_) and
// Check that the phi instruction is *not* degenerate, but we can't use
// getDegeneratePhiOperand in the first stage with phi instyructions
// getDegeneratePhiOperand in the first stage with phi instructions
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/**
* Gets the rank index of a hyphothetical use one instruction past the end of
* Gets the rank index of a hypothetical use one instruction past the end of
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jketema
Copy link
Copy Markdown
Contributor

jketema commented Oct 14, 2022

Yeah, so all changes related to "IR" (see directory name), are indeed best dealt with on the C++ side, moving the related C# changes to this PR is the correct thing to do.

jsoref added 14 commits October 14, 2022 15:08
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
jsoref added 23 commits October 14, 2022 15:08
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@jketema jketema merged commit 720efd6 into github:main Oct 17, 2022
@jketema
Copy link
Copy Markdown
Contributor

jketema commented Oct 17, 2022

@jsoref Thanks for these fixes

@jsoref jsoref deleted the spelling-cpp branch October 18, 2022 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants