Repository: fraunhofer-aisec/cpg
Issue: Endless parsing for some files

Sometimes I try to get CPG for one file. But it looks like endless process. I haven't got any errors but the process takes more than 1 hour and I stop it. 

I can provide with such several files.

Changed files:
src/main/java/de/fraunhofer/aisec/cpg/graph/FunctionDeclaration.java, src/main/java/de/fraunhofer/aisec/cpg/graph/CompoundStatement.java, src/main/java/de/fraunhofer/aisec/cpg/graph/UnaryOperator.java, src/main/java/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.java, src/main/java/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.java, src/main/java/de/fraunhofer/aisec/cpg/sarif/PhysicalLocation.java, src/main/java/de/fraunhofer/aisec/cpg/graph/CallExpression.java

diff --git a/src/main/java/de/fraunhofer/aisec/cpg/graph/CallExpression.java b/src/main/java/de/fraunhofer/aisec/cpg/graph/CallExpression.java
index 70a48057a..f5fcfe019 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/graph/CallExpression.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/graph/CallExpression.java
@@ -146,8 +146,6 @@ public class CallExpression extends Expression implements TypeListener {
   public String toString() {
     return new ToStringBuilder(this, Node.TO_STRING_STYLE)
         .appendSuper(super.toString())
-        .append("arguments", arguments)
-        .append("invokes", invokes)
         .append("base", base)
         .toString();
   }
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/graph/CompoundStatement.java b/src/main/java/de/fraunhofer/aisec/cpg/graph/CompoundStatement.java
index fc5b268e5..98adbaa2f 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/graph/CompoundStatement.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/graph/CompoundStatement.java
@@ -53,10 +53,7 @@ public class CompoundStatement extends Statement {
 
   @Override
   public String toString() {
-    return new ToStringBuilder(this, Node.TO_STRING_STYLE)
-        .appendSuper(super.toString())
-        .append("statements", statements)
-        .toString();
+    return new ToStringBuilder(this, Node.TO_STRING_STYLE).appendSuper(super.toString()).toString();
   }
 
   @Override
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/graph/FunctionDeclaration.java b/src/main/java/de/fraunhofer/aisec/cpg/graph/FunctionDeclaration.java
index d8c214795..d0be77092 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/graph/FunctionDeclaration.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/graph/FunctionDeclaration.java
@@ -203,9 +203,8 @@ public class FunctionDeclaration extends ValueDeclaration {
   public String toString() {
     return new ToStringBuilder(this, Node.TO_STRING_STYLE)
         .appendSuper(super.toString())
-        .append("body", body)
         .append("type", type)
-        .append("parameters", parameters)
+        .append("parameters", parameters.stream().map(ParamVariableDeclaration::getName))
         .toString();
   }
 
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/graph/UnaryOperator.java b/src/main/java/de/fraunhofer/aisec/cpg/graph/UnaryOperator.java
index 0af8c2f27..b1f581542 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/graph/UnaryOperator.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/graph/UnaryOperator.java
@@ -185,7 +185,6 @@ public class UnaryOperator extends Expression implements TypeListener {
   public String toString() {
     return new ToStringBuilder(this, Node.TO_STRING_STYLE)
         .appendSuper(super.toString())
-        .append("input", input)
         .append("operatorCode", operatorCode)
         .append("postfix", postfix)
         .append("prefix", prefix)
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.java b/src/main/java/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.java
index 7a6d5ccd6..ea6a7dd26 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/helpers/SubgraphWalker.java
@@ -400,7 +400,7 @@ public class SubgraphWalker {
 
       if (current instanceof ValueDeclaration) {
 
-        LOGGER.debug("Adding variable {}", current.getCode());
+        LOGGER.trace("Adding variable {}", current.getCode());
         if (parentBlock == null) {
           LOGGER.warn("Parent block is empty during subgraph run");
         } else {
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.java b/src/main/java/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.java
index ff4563577..66abf9b1c 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/passes/EvaluationOrderGraphPass.java
@@ -690,20 +690,20 @@ public class EvaluationOrderGraphPass extends Pass {
   }
 
   public void setCurrentEOG(Node node) {
-    LOGGER.debug("Setting {} to EOG", node);
+    LOGGER.trace("Setting {} to EOG", node);
 
     this.currentEOG = new ArrayList<>();
     this.currentEOG.add(node);
   }
 
   public <T extends Node> void setCurrentEOGs(List<T> nodes) {
-    LOGGER.debug("Setting {} to EOGs", nodes);
+    LOGGER.trace("Setting {} to EOGs", nodes);
 
     this.currentEOG = new ArrayList<>(nodes);
   }
 
   public void addToCurrentEOG(List<Node> nodes) {
-    LOGGER.debug("Adding {} to current EOG", nodes);
+    LOGGER.trace("Adding {} to current EOG", nodes);
 
     this.currentEOG.addAll(nodes);
   }
diff --git a/src/main/java/de/fraunhofer/aisec/cpg/sarif/PhysicalLocation.java b/src/main/java/de/fraunhofer/aisec/cpg/sarif/PhysicalLocation.java
index 907796423..6251361d1 100644
--- a/src/main/java/de/fraunhofer/aisec/cpg/sarif/PhysicalLocation.java
+++ b/src/main/java/de/fraunhofer/aisec/cpg/sarif/PhysicalLocation.java
@@ -54,6 +54,11 @@ public class PhysicalLocation {
     public URI getUri() {
       return this.uri;
     }
+
+    @Override
+    public String toString() {
+      return this.uri.toASCIIString();
+    }
   }
 
   @NonNull private ArtifactLocation artifactLocation;
@@ -78,4 +83,9 @@ public class PhysicalLocation {
   public ArtifactLocation getArtifactLocation() {
     return this.artifactLocation;
   }
+
+  @Override
+  public String toString() {
+    return this.artifactLocation + ":" + this.region.toString();
+  }
 }