C++: Fix toString() predicates that don't hold

This commit is contained in:
Dave Bartolomeo
2019-12-13 17:06:05 -07:00
parent 9b6c394ac7
commit 914288d3c5
12 changed files with 19 additions and 1 deletions

View File

@@ -157,4 +157,6 @@ library class SpecialNameQualifyingElement extends NameQualifyingElement,
@specialnamequalifyingelement {
/** Gets the name of this special qualifying element. */
override string getName() { specialnamequalifyingelements(underlyingElement(this), result) }
override string toString() { result = getName() }
}

View File

@@ -214,7 +214,11 @@ class PreprocessorUndef extends PreprocessorDirective, @ppd_undef {
* A C/C++ preprocessor `#pragma` directive.
*/
class PreprocessorPragma extends PreprocessorDirective, @ppd_pragma {
override string toString() { result = "#pragma " + this.getHead() }
override string toString() {
if exists(this.getHead())
then result = "#pragma " + this.getHead()
else result = "#pragma"
}
}
/**

View File

@@ -26,6 +26,7 @@
| CPP-205.cpp:8:3:8:15 | return ... | |
| CPP-205.cpp:8:10:8:11 | call to fn | |
| CPP-205.cpp:8:13:8:13 | 0 | |
| file://:0:0:0:0 | __super | |
| file://:0:0:0:0 | __va_list_tag | |
| file://:0:0:0:0 | operator= | function __va_list_tag::operator=(__va_list_tag &&) -> __va_list_tag & |
| file://:0:0:0:0 | operator= | function __va_list_tag::operator=(const __va_list_tag &) -> __va_list_tag & |

View File

@@ -23,6 +23,8 @@
| clang_ms.cpp:11:5:11:13 | asm statement |
| clang_ms.cpp:12:1:12:1 | return ... |
| clang_ms.cpp:16:1:16:19 | // Test for CPP-184 |
| clang_ms.cpp:17:1:17:32 | #pragma |
| clang_ms.cpp:18:1:18:31 | #pragma |
| file://:0:0:0:0 | |
| file://:0:0:0:0 | (global namespace) |
| file://:0:0:0:0 | _Complex __float128 |
@@ -48,6 +50,7 @@
| file://:0:0:0:0 | __ptr32 |
| file://:0:0:0:0 | __ptr64 |
| file://:0:0:0:0 | __sptr |
| file://:0:0:0:0 | __super |
| file://:0:0:0:0 | __uptr |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |

View File

@@ -27,6 +27,7 @@
| file://:0:0:0:0 | __ptr32 |
| file://:0:0:0:0 | __ptr64 |
| file://:0:0:0:0 | __sptr |
| file://:0:0:0:0 | __super |
| file://:0:0:0:0 | __uptr |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |

View File

@@ -201,6 +201,7 @@
| file://:0:0:0:0 | ..(*)(..) |
| file://:0:0:0:0 | ..(*)(..) |
| file://:0:0:0:0 | ..(..) |
| file://:0:0:0:0 | __super |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |
| file://:0:0:0:0 | __va_list_tag && |

View File

@@ -1,3 +1,4 @@
| file://:0:0:0:0 | __super | false |
| file://:0:0:0:0 | __va_list_tag | false |
| file://:0:0:0:0 | operator= | false |
| file://:0:0:0:0 | operator= | false |

View File

@@ -1,4 +1,5 @@
import cpp
from Expr e
where exists(e.toString())
select e, e.getType()

View File

@@ -7,6 +7,7 @@
| file://:0:0:0:0 | X |
| file://:0:0:0:0 | X |
| file://:0:0:0:0 | Y |
| file://:0:0:0:0 | __super |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |
| file://:0:0:0:0 | __va_list_tag && |

View File

@@ -32,6 +32,7 @@
| file://:0:0:0:0 | __ptr32 |
| file://:0:0:0:0 | __ptr64 |
| file://:0:0:0:0 | __sptr |
| file://:0:0:0:0 | __super |
| file://:0:0:0:0 | __uptr |
| file://:0:0:0:0 | __va_list_tag |
| file://:0:0:0:0 | __va_list_tag & |

View File

@@ -24,6 +24,7 @@
| file://:0:0:0:0 | __ptr32 | Other |
| file://:0:0:0:0 | __ptr64 | Other |
| file://:0:0:0:0 | __sptr | Other |
| file://:0:0:0:0 | __super | Other |
| file://:0:0:0:0 | __uptr | Other |
| file://:0:0:0:0 | __va_list_tag | Other |
| file://:0:0:0:0 | abstract | Other |

View File

@@ -3,5 +3,6 @@ import cpp
from Element e, string s
where
not e instanceof Folder and
exists(e.toString()) and // Work around `VariableDeclarationEntry.toString()` not holding
if e instanceof VariableAccess then s = "Variable access" else s = "Other"
select e, s