File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 1- import ql
2- private import codeql_ql.ast.internal.AstNodes as AstNodes
3-
4- query AstNode nonTotalGetParent ( ) {
5- exists ( AstNodes:: toQL ( result ) .getParent ( ) ) and
6- not exists ( result .getParent ( ) ) and
7- not result .getLocation ( ) .getStartColumn ( ) = 1 and // startcolumn = 1 <=> top level in file <=> fine to have no parent
8- not result instanceof YAML:: YAMLNode and // parents for YAML doens't work
9- not ( result instanceof QLDoc and result .getLocation ( ) .getFile ( ) .getExtension ( ) = "dbscheme" ) // qldoc in dbschemes are not hooked up
10- }
1+ private import codeql_ql.ast.internal.AstNodes:: AstConsistency
Original file line number Diff line number Diff line change @@ -209,3 +209,16 @@ class TTypeDeclaration = TClass or TNewType or TNewTypeBranch;
209209class TModuleDeclaration = TClasslessPredicate or TModule or TClass or TNewType ;
210210
211211class TVarDef = TVarDecl or TAsExpr ;
212+
213+ module AstConsistency {
214+ import ql
215+
216+ query predicate nonTotalGetParent ( AstNode node ) {
217+ exists ( toQL ( node ) .getParent ( ) ) and
218+ not exists ( node .getParent ( ) ) and
219+ not node .getLocation ( ) .getStartColumn ( ) = 1 and // startcolumn = 1 <=> top level in file <=> fine to have no parent
220+ exists ( node .toString ( ) ) and // <- there are a few parse errors in "global-data-flow-java-1.ql", this way we filter them out.
221+ not node instanceof YAML:: YAMLNode and // parents for YAML doens't work
222+ not ( node instanceof QLDoc and node .getLocation ( ) .getFile ( ) .getExtension ( ) = "dbscheme" ) // qldoc in dbschemes are not hooked up
223+ }
224+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import codeql_ql.ast.internal.Type::TyConsistency as TypeConsistency
1414import codeql_ql.ast.internal.Builtins:: BuildinsConsistency as BuildinsConsistency
1515import codeql_ql.ast.internal.Module:: ModConsistency as ModConsistency
1616import codeql_ql.ast.internal.Variable:: VarConsistency as VarConsistency
17+ import codeql_ql.ast.internal.AstNodes:: AstConsistency as AstConsistency
1718
1819from AstNode node , string msg
1920where
3031 TypeConsistency:: multiplePrimitivesExpr ( node , _, _) and
3132 msg = "TypeConsistency::multiplePrimitivesExpr"
3233 or
34+ AstConsistency:: nonTotalGetParent ( node ) and msg = "AstConsistency::nonTotalGetParent"
35+ or
3336 //or // has 1 result, but the CodeQL compiler also can't figure out that one. I suppoed the file is never imported.
3437 //TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve"
3538 //or // has 1 result, but the CodeQL compiler also can't figure out that one. Same file as above.
You can’t perform that action at this time.
0 commit comments