Skip to content

C++: Rename predicates in FunctionInputsAndOutputs.qll and add QLDoc #1938

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

Merged
merged 3 commits into from
Sep 30, 2019

Conversation

dave-bartolomeo
Copy link
Contributor

No description provided.

Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

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

incompat


predicate isInQualifier() { none() }
predicate isQualifierAddress() { none() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the QLDoc should go on these predicates rather than the associated classes. It's these predicates that callers use and get autocomplete for.

I'll so so far as suggesting we deprecate the associated classes (InParameter, etc.). I've never needed them or their toString, so to me they just look like 70 lines of dead boiler-plate code. What's your take on that, @rdmarsh2?

Copy link

Choose a reason for hiding this comment

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

I've moved the QLDoc to the relevant predicates. However, I'd prefer not to deprecate the classes. If they didn't already exist, I probably wouldn't add them, but they could reasonably be used to filter a set of FunctionInputs or FunctionOutputs in an exists() without a separate condition.

/**
* The input value of a parameter to a function.
* Example:
* ```cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't believe QLDoc supports language identifiers after triple backticks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try a QLDoc build and see what happens.

Copy link

Choose a reason for hiding this comment

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

I've just removed these for now.

class FunctionInput extends TFunctionInput {
abstract string toString();

predicate isInParameter(ParameterIndex index) { none() }
predicate isParameter(ParameterIndex index) { none() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid we can't change these names without keeping the old names as deprecated synonyms. They're used by at least one customer: https://semmle.slack.com/archives/C7NS4H8HY/p1561548291277300

Copy link
Contributor

Choose a reason for hiding this comment

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

It also means we need to write a change note about this.

Copy link

Choose a reason for hiding this comment

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

Done and done.

Copy link
Contributor

@jbj jbj left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM.

}

class OutQualifier extends FunctionOutput, TOutQualifier {
class OutQualifierObject extends FunctionOutput, TOutQualifierObject {
override string toString() { result = "OutQualifier" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
override string toString() { result = "OutQualifier" }
override string toString() { result = "OutQualifierObject" }

Copy link
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 what's going on with the indentation in this edit suggestion. I didn't suggest any change of indentation.

Copy link

Choose a reason for hiding this comment

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

Fixed

predicate isReturnValueDeref() { none() }

/*
* Holds if this is the output value pointed to by the return value of a function, if the function
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment should have been a QLDoc.

Copy link

Choose a reason for hiding this comment

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

Fixed

/**
* Holds if this is the output value pointed to by the return value of a function, if the function
* returns a pointer, or the output value referred to by the return value of a function, if the
* function returns a reference.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some formatting accidents that are probably cause by the autoformatter acting on a comment that doesn't start with * on every line. Several predicates in this file are affected.

Copy link

Choose a reason for hiding this comment

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

Fixed.

* `isReturnValueDeref()` holds for the `FunctionOutput` that represents the value of
* `getReference()` (with type `float`).
* There is no `FunctionOutput` of `getInt()` for which `isReturnValueDeref()` holds because the
* return type of `getInt()` is neither a pointer nor a reference.
Copy link
Contributor

Choose a reason for hiding this comment

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

Outside of triple backticks, line breaks are not significant in QLDoc. I think this would read better as a bullet list so all three items don't get run together in a single paragraph. If you prefer them to be run together, I think it's better to reflect that in the source text by running them together there as well.

Copy link

Choose a reason for hiding this comment

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

Fixed.

@dave-bartolomeo
Copy link
Contributor Author

All feedback addressed. Ready for final review and merge.

@jbj jbj merged commit f417640 into github:master Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants