File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
cpp/ql/src/semmle/code/cpp Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes for working with name qualifiers such as the `N::` in
3
+ * `N::f()`.
4
+ */
5
+
1
6
import cpp
2
7
3
8
/**
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides classes for modelling namespaces, `using` directives and `using` declarations.
3
+ */
4
+
1
5
import semmle.code.cpp.Element
2
6
import semmle.code.cpp.Type
3
7
import semmle.code.cpp.metrics.MetricNamespace
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Provides a class for reasoning about nested field accesses, for example
3
+ * the access `myLine.start.x`.
4
+ */
5
+
1
6
import cpp
2
7
3
8
/**
@@ -25,7 +30,7 @@ private Expr getUltimateQualifier(FieldAccess fa) {
25
30
}
26
31
27
32
/**
28
- * Accesses to nested fields .
33
+ * A nested field access, for example the access `myLine.start.x` .
29
34
*/
30
35
class NestedFieldAccess extends FieldAccess {
31
36
Expr ultimateQualifier ;
@@ -35,6 +40,30 @@ class NestedFieldAccess extends FieldAccess {
35
40
getTarget ( ) = getANestedField ( ultimateQualifier .getType ( ) .stripType ( ) )
36
41
}
37
42
38
- /** Gets the ultimate qualifier of this nested field access. */
43
+ /**
44
+ * Gets the outermost qualifier of this nested field access. In the
45
+ * following example, the access to `myLine.start.x` has outermost qualifier
46
+ * `myLine`:
47
+ * ```
48
+ * struct Point
49
+ * {
50
+ * float x, y;
51
+ * };
52
+ *
53
+ * struct Line
54
+ * {
55
+ * Point start, end;
56
+ * };
57
+ *
58
+ * void init()
59
+ * {
60
+ * Line myLine;
61
+ *
62
+ * myLine.start.x = 0.0f;
63
+ *
64
+ * // ...
65
+ * }
66
+ * ```
67
+ */
39
68
Expr getUltimateQualifier ( ) { result = ultimateQualifier }
40
69
}
You can’t perform that action at this time.
0 commit comments