Skip to content

Commit f990634

Browse files
committed
C++: Fix the XMLParent Constructor.
1 parent a6407f0 commit f990634

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

cpp/ql/src/semmle/code/cpp/XML.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ abstract class XMLLocatable extends @xmllocatable {
3131
* both of which can contain other elements.
3232
*/
3333
class XMLParent extends @xmlparent {
34+
XMLParent() {
35+
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
36+
// the type `@xmlparent` currently also includes non-XML files
37+
this instanceof @xmlelement or xmlEncoding(this, _)
38+
}
39+
3440
/**
3541
* Gets a printable representation of this XML parent.
3642
* (Intended to be overridden in subclasses.)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| c.c | library-tests/files/c.c | CFile, MetricFile | C, XMLParent | | |
2-
| files1.cpp | library-tests/files/files1.cpp | CppFile, MetricFile | C++, XMLParent | swap | t |
3-
| files1.h | library-tests/files/files1.h | HeaderFile, MetricFile | XMLParent | swap | |
4-
| files2.cpp | library-tests/files/files2.cpp | CppFile, MetricFile | C++, XMLParent | g | x, y |
1+
| c.c | library-tests/files/c.c | CFile, MetricFile | C | | |
2+
| files1.cpp | library-tests/files/files1.cpp | CppFile, MetricFile | C++ | swap | t |
3+
| files1.h | library-tests/files/files1.h | HeaderFile, MetricFile | | swap | |
4+
| files2.cpp | library-tests/files/files2.cpp | CppFile, MetricFile | C++ | g | x, y |

0 commit comments

Comments
 (0)