-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: A few IR QLDoc comments #3393
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
Conversation
private import internal.TempVariableTagInternal | ||
private import Imports::TempVariableTag | ||
|
||
/** | ||
* Describes the reason that a particular IR temporary variable was generated. For example, it could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QLDoc for a class is usually a singular noun phrase. I'm not clear on whether that's a style guide requirement or not. All the examples use the "An expression..." style, but it's not explicitly written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Describes the reason that a particular IR temporary variable was generated. For example, it could | |
* A reason that a particular IR temporary variable was generated. For example, it could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we use A/An. See https://wiki.semmle.com/pages/viewpage.action?pageId=74613282#QLDocStyleGuide-QLDocforclasses (linked from https://github.com/github/codeql-c-analysis-team/issues/40). That part of the style guide hasn't made it to the public repo yet,.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a whole bunch of suggestions that aim to make the text clearer. It's possible that I've not correctly understood the intention of some comments.
I stopped when I got to what appear to be duplicate entries.
* Gets the single instance of `GotoEdge`, representing the unconditional successor of an | ||
* `Instruction` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `GotoEdge`, representing the unconditional successor of an | |
* `Instruction` | |
* Gets the single instance of `GotoEdge` that represents the unconditional successor of an | |
* `Instruction`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would your suggestion still stand if I clarified that there is only a single GotoEdge
object in the entire library, and that that single instance is used in calls like:
exists(Instruction instruction, Instruction successor |
instruction.getSuccessor(gotoEdge()) = successor
)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, perhaps:
* Gets the single instance of `GotoEdge`, representing the unconditional successor of an | |
* `Instruction` | |
* Gets the single instance of `GotoEdge`. This instance represents the unconditional successor of an | |
* `Instruction`. |
But it's definitely at times like this where my lack of programming knowledge is a hinderance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a bit of discussion in Slack, I've moved these predicates into an EdgeKind
module (to match the EdgeKind
class with which they are associated), and shortened the QLDoc comments to just say "Gets the single instance of the FooEdge
class.". The documentation for the FooEdge
class itself explains what that is.
@@ -38,6 +43,10 @@ class TrueEdge extends EdgeKind, TTrueEdge { | |||
final override string toString() { result = "True" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `TrueEdge`, representing the successor of a conditional branch when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `TrueEdge`, representing the successor of a conditional branch when | |
* Gets the single instance of `TrueEdge` that represents the successor of a conditional branch when |
@@ -48,6 +57,10 @@ class FalseEdge extends EdgeKind, TFalseEdge { | |||
final override string toString() { result = "False" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `FalseEdge`, representing the successor of a conditional branch when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `FalseEdge`, representing the successor of a conditional branch when | |
* Gets the single instance of `FalseEdge` that represents the successor of a conditional branch when |
* Gets an integer representing the order in which this operand should appear in the operand list | ||
* of an instruction when printing the IR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure whether I've understood this correctly. Perhaps?
* Gets an integer representing the order in which this operand should appear in the operand list | |
* of an instruction when printing the IR. | |
* Gets an integer that represents where this operand will appear in the operand list | |
* of an instruction when the IR is printed. |
abstract int getSortOrder(); | ||
|
||
/** | ||
* Gets a label that will appear before the operand when printing the IR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets a label that will appear before the operand when printing the IR. | |
* Gets a label that will appear before the operand when the IR is printed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
* Gets the `CaseEdge` representing the successor of a `Switch` instruction corresponding to the | ||
* `case` label with the specified lower and upper bounds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what this means.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've expanded the text and included an example.
@@ -28,6 +29,10 @@ class GotoEdge extends EdgeKind, TGotoEdge { | |||
final override string toString() { result = "Goto" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `GotoEdge`, representing the unconditional successor of an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `GotoEdge`, representing the unconditional successor of an | |
* Gets the single instance of `GotoEdge` that represents the unconditional successor of an |
@@ -38,6 +43,10 @@ class TrueEdge extends EdgeKind, TTrueEdge { | |||
final override string toString() { result = "True" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `TrueEdge`, representing the successor of a conditional branch when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `TrueEdge`, representing the successor of a conditional branch when | |
* Gets the single instance of `TrueEdge` that represents the successor of a conditional branch when |
@@ -48,6 +57,10 @@ class FalseEdge extends EdgeKind, TFalseEdge { | |||
final override string toString() { result = "False" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `FalseEdge`, representing the successor of a conditional branch when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Gets the single instance of `FalseEdge`, representing the successor of a conditional branch when | |
* Gets the single instance of `FalseEdge` that represents the successor of a conditional branch when |
@@ -58,6 +71,10 @@ class ExceptionEdge extends EdgeKind, TExceptionEdge { | |||
final override string toString() { result = "Exception" } | |||
} | |||
|
|||
/** | |||
* Gets the single instance of `ExceptionEdge`, representing the successor of an instruction when | |||
* that instruction's evaluation throws an exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See cpp comment above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, sorry for all the duplicate code. It's an artifact of how we share the IR code with C#. We have a script and PR check that keeps them all in sync, so once I make the change in one place, it will be propagated to all the other duplicate copies as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry - it wasn't intended to be complaint - more an explanation of why I'd stopped commenting 😄
Note that the various predicates to access the singleton instances of the `EdgeKind` classes have been moved into a module named `EdgeKind`.
OK, I think this is ready for final review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes. 👍
It's nice to see a new example in the library comments 😄
@github/codeql-c-analysis Can I get an official approval? |
A small part of https://github.com/github/codeql-c-analysis-team/issues/40