C++: add method qldoc for Comment.qll

This commit is contained in:
Robert Marsh
2020-04-13 14:39:51 -07:00
parent 7c5c9ea8ea
commit de29d93ede

View File

@@ -1,3 +1,5 @@
import semmle.code.cpp.Location
import semmle.code.cpp.Element
@@ -13,8 +15,20 @@ class Comment extends Locatable, @comment {
override Location getLocation() { comments(underlyingElement(this), _, result) }
/**
* Gets the text of this comment, including the opening `//` or `/*`, and the closing `*``/` if
* present.
*/
string getContents() { comments(underlyingElement(this), result, _) }
/**
* Gets the AST element this comment is associated with. For example, the comment in the
* following code is associated with the declaration of `j`.
* ```
* int i;
* int j; // Comment on j
* ```
*/
Element getCommentedElement() {
commentbinding(underlyingElement(this), unresolveElement(result))
}