@@ -55,10 +55,18 @@ class Macro extends PreprocessorDirective, @ppd_define {
5555}
5656
5757/**
58- * A macro access (macro expansion or other macro access).
58+ * A macro access. For example:
59+ * ```
60+ * #ifdef MACRO1 // this line contains a MacroAccess
61+ * int x = MACRO2; // this line contains a MacroAccess
62+ * #endif
63+ * ```
64+ *
65+ * See also `MacroInvocation`, which represents only macro accesses
66+ * that are expanded (such as in the second line of the example above).
5967 */
6068class MacroAccess extends Locatable , @macroinvocation {
61- /** Gets the macro being invoked . */
69+ /** Gets the macro that is being accessed . */
6270 Macro getMacro ( ) { macroinvocations ( underlyingElement ( this ) , unresolveElement ( result ) , _, _) }
6371
6472 /**
@@ -73,7 +81,7 @@ class MacroAccess extends Locatable, @macroinvocation {
7381 }
7482
7583 /**
76- * Gets the location of this macro invocation . For a nested invocation , where
84+ * Gets the location of this macro access . For a nested access , where
7785 * `exists(this.getParentInvocation())`, this yields a location either inside
7886 * a `#define` directive or inside an argument to another macro.
7987 */
@@ -126,14 +134,22 @@ class MacroAccess extends Locatable, @macroinvocation {
126134
127135 override string toString ( ) { result = this .getMacro ( ) .getHead ( ) }
128136
129- /** Gets the name of the invoked macro. */
137+ /** Gets the name of the accessed macro. */
130138 string getMacroName ( ) {
131139 result = getMacro ( ) .getName ( )
132140 }
133141}
134142
135143/**
136- * A macro invocation (macro expansion).
144+ * A macro invocation (macro access that is expanded). For example:
145+ * ```
146+ * #ifdef MACRO1
147+ * int x = MACRO2; // this line contains a MacroInvocation
148+ * #endif
149+ * ```
150+ *
151+ * See also `MacroAccess`, which also represents macro accesses where the macro
152+ * is checked but not expanded (such as in the first line of the example above).
137153 */
138154class MacroInvocation extends MacroAccess {
139155 MacroInvocation ( ) {
@@ -174,7 +190,7 @@ class MacroInvocation extends MacroAccess {
174190 /**
175191 * Gets the top-level expression associated with this macro invocation,
176192 * if any. Note that this predicate will fail if the top-level expanded
177- * element is a statement rather than an expression .
193+ * element is not an expression (for example if it is a statement) .
178194 */
179195 Expr getExpr ( ) {
180196 result = getAnExpandedElement ( ) and
@@ -185,7 +201,7 @@ class MacroInvocation extends MacroAccess {
185201 /**
186202 * Gets the top-level statement associated with this macro invocation, if
187203 * any. Note that this predicate will fail if the top-level expanded
188- * element is an expression rather than a statement .
204+ * element is not a statement (for example if it is an expression) .
189205 */
190206 Stmt getStmt ( ) {
191207 result = getAnExpandedElement ( ) and
0 commit comments