From 54c12cd715230ca6936cc483fe4a4fcb06403f34 Mon Sep 17 00:00:00 2001 From: Mathias Vorreiter Pedersen Date: Wed, 7 Dec 2022 18:21:52 +0000 Subject: [PATCH] C++: Reintroduce 'StdBasicStringIterator'. --- .../cpp/models/implementations/StdString.qll | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cpp/ql/lib/semmle/code/cpp/models/implementations/StdString.qll b/cpp/ql/lib/semmle/code/cpp/models/implementations/StdString.qll index cf3ecb5e892..b1534a585a1 100644 --- a/cpp/ql/lib/semmle/code/cpp/models/implementations/StdString.qll +++ b/cpp/ql/lib/semmle/code/cpp/models/implementations/StdString.qll @@ -15,6 +15,24 @@ private class StdBasicString extends ClassTemplateInstantiation { StdBasicString() { this.hasQualifiedName(["std", "bsl"], "basic_string") } } +/** + * The `std::basic_string::iterator` declaration. + * + * Intuitively, this class shouldn't be necessary as it's already captured + * by the `StdIterator` class. However, this class ensures that the typedef inside the + * body of the `std::string` class is also seen as an iterator. + * + * Eventually, we should be consistent about which of the following should be recognized as iterators: + * 1. The typedef type. + * 2. The template class of the resolved type. + * 3. Any instantiation of the resolved type. + */ +private class StdBasicStringIterator extends Iterator, Type { + StdBasicStringIterator() { + this.getEnclosingElement() instanceof StdBasicString and this.hasName("iterator") + } +} + /** * A `std::string` function for which taint should be propagated. */