Skip to content

Commit b322892

Browse files
committed
C++: Add support for getting referenced literals in using declarations
1 parent 5df50c0 commit b322892

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

cpp/ql/lib/semmle/code/cpp/Namespace.qll

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,23 @@ class UsingDeclarationEntry extends UsingEntry {
174174
*/
175175
Declaration getDeclaration() { usings(underlyingElement(this), unresolveElement(result), _, _) }
176176

177-
override string toString() { result = "using " + this.getDeclaration().getDescription() }
177+
/**
178+
* Returns the member referenced by this `using` declaration in a templated base class.
179+
*
180+
* For example:
181+
* ```
182+
* template <typename T>
183+
* class A : public T {
184+
* using T::foo; // `foo` is the member referenced by this using declaration
185+
* };
186+
* ```
187+
*/
188+
Element getReferencedMember() { usings(underlyingElement(this), unresolveElement(result), _, _) }
189+
190+
override string toString() {
191+
result = "using " + this.getDeclaration().getDescription() or
192+
result = "using " + this.getReferencedMember()
193+
}
178194
}
179195

180196
/**

0 commit comments

Comments
 (0)