Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cpp/ql/src/semmle/code/cpp/XML.qll
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ abstract class XMLLocatable extends @xmllocatable {
* both of which can contain other elements.
*/
class XMLParent extends @xmlparent {
XMLParent() {
// explicitly restrict `this` to be either an `XMLElement` or an `XMLFile`;
// the type `@xmlparent` currently also includes non-XML files
this instanceof @xmlelement or xmlEncoding(this, _)
}

/**
* Gets a printable representation of this XML parent.
* (Intended to be overridden in subclasses.)
Expand Down
4 changes: 0 additions & 4 deletions cpp/ql/test/library-tests/files/FilePath.expected

This file was deleted.

5 changes: 0 additions & 5 deletions cpp/ql/test/library-tests/files/FilePath.ql

This file was deleted.

4 changes: 4 additions & 0 deletions cpp/ql/test/library-tests/files/Files.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
| c.c | library-tests/files/c.c | CFile, MetricFile | C | | |
| files1.cpp | library-tests/files/files1.cpp | CppFile, MetricFile | C++ | swap | t |
| files1.h | library-tests/files/files1.h | HeaderFile, MetricFile | | swap | |
| files2.cpp | library-tests/files/files2.cpp | CppFile, MetricFile | C++ | g | x, y |
18 changes: 18 additions & 0 deletions cpp/ql/test/library-tests/files/Files.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import cpp

string describe(File f) {
f.compiledAsC() and
result = "C"
or
f.compiledAsCpp() and
result = "C++"
or
f instanceof XMLParent and
result = "XMLParent" // regression tests a bug in the characteristic predicate of XMLParent
}

from File f
where f.toString() != ""
select f.toString(), f.getRelativePath(), concat(f.getAQlClass().toString(), ", "),
concat(describe(f), ", "), concat(f.getATopLevelDeclaration().toString(), ", "),
concat(LocalVariable v | f.getADeclaration() = v | v.toString(), ", ")
1 change: 0 additions & 1 deletion cpp/ql/test/library-tests/files/Files1.expected

This file was deleted.

4 changes: 0 additions & 4 deletions cpp/ql/test/library-tests/files/Files1.ql

This file was deleted.

8 changes: 0 additions & 8 deletions cpp/ql/test/library-tests/files/Files2.expected

This file was deleted.

11 changes: 0 additions & 11 deletions cpp/ql/test/library-tests/files/Files2.ql

This file was deleted.

3 changes: 0 additions & 3 deletions cpp/ql/test/library-tests/files/Files3.expected

This file was deleted.

7 changes: 0 additions & 7 deletions cpp/ql/test/library-tests/files/Files3.ql

This file was deleted.

3 changes: 0 additions & 3 deletions cpp/ql/test/library-tests/files/Files4.expected

This file was deleted.

5 changes: 0 additions & 5 deletions cpp/ql/test/library-tests/files/Files4.ql

This file was deleted.