Skip to content

Commit 5f73f1f

Browse files
author
Dominik Helm
committed
Merge branch 'develop' into feature/TAC2BC
2 parents adb1b49 + b364d28 commit 5f73f1f

File tree

674 files changed

+25647
-11333
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

674 files changed

+25647
-11333
lines changed

.scalafmt.conf

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.7.17"
1+
version = "3.9.8"
22
maxColumn = 120
33
encoding = "UTF-8"
44
runner.dialect = scala213
@@ -12,21 +12,17 @@ docstrings {
1212
indent {
1313
main = 4
1414
callSite = 4
15+
infix.exemptScope = aloneEnclosed
1516
}
16-
indentOperator.exemptScope = aloneEnclosed
17-
18-
project.excludePaths = [
19-
"glob:**/DEVELOPING_OPAL/demos/src/main/scala/org/opalj/fpcf/analyses/InterProceduralEscapeAnalysisDemo.scala",
20-
"glob:**/DEVELOPING_OPAL/demos/src/main/scala/org/opalj/fpcf/analyses/SimpleEscapeAnalysisDemo.scala"
21-
]
2217

2318
newlines {
2419
source = keep
2520
afterCurlyLambdaParams = squash
26-
avoidForSimpleOverflow = [slc, tooLong, punct] # singe line comment, does not add newline if line would be too long after, punctuation
21+
avoidForSimpleOverflow = [slc, tooLong, punct] # single line comment, does not add newline if line would be too long after punctuation
2722
topLevelStatementBlankLines = [{ blanks { before = 1 }, maxNest = 0 }]
2823
sometimesBeforeColonInMethodReturnType = false
29-
ignoreInSyntax = false
24+
ignoreInSyntax = false,
25+
selectChains = keep
3026
}
3127

3228
binPack.parentConstructors = keep
@@ -66,6 +62,7 @@ rewrite {
6662
"org\\.scalatest\\..*",
6763
"org\\.scalatestplus\\..*"],
6864
["com\\.typesafe\\.config\\..*"],
65+
["org\\.rogach\\.scallop\\..*"],
6966
["org\\.opalj\\..*"],
7067
["scala\\.collection\\.parallel\\.CollectionConverters\\..*"]
7168
// Catch all
Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package org.opalj
33
package ai
44

5+
import java.io.File
56
import java.net.URL
67
import java.util.concurrent.ConcurrentLinkedQueue
78
import scala.jdk.CollectionConverters._
@@ -12,7 +13,8 @@ import org.opalj.br.MethodDescriptor.JustReturnsString
1213
import org.opalj.br.PCAndInstruction
1314
import org.opalj.br.analyses.BasicReport
1415
import org.opalj.br.analyses.Project
15-
import org.opalj.br.analyses.ProjectAnalysisApplication
16+
import org.opalj.br.analyses.ProjectsAnalysisApplication
17+
import org.opalj.br.fpcf.cli.MultiProjectAnalysisConfig
1618
import org.opalj.br.instructions.GETFIELD
1719
import org.opalj.br.instructions.INVOKEINTERFACE
1820
import org.opalj.br.instructions.INVOKESTATIC
@@ -28,11 +30,15 @@ import org.opalj.br.instructions.LoadString
2830
*
2931
* @author Michael Reif
3032
*/
31-
object CipherGetInstanceStringUsage extends ProjectAnalysisApplication {
33+
object CipherGetInstanceStrings extends ProjectsAnalysisApplication {
3234

33-
override def title: String = "input value analysis for Chipher.getInstance calls"
35+
protected class CipherInstanceConfig(args: Array[String]) extends MultiProjectAnalysisConfig(args) {
36+
val description = "Collects parameter values of Cipher.getInstance calls"
37+
}
38+
39+
protected type ConfigType = CipherInstanceConfig
3440

35-
override def description: String = "Analyzes the input values of Chipher.getInstance calls."
41+
protected def createConfig(args: Array[String]): CipherInstanceConfig = new CipherInstanceConfig(args)
3642

3743
// #################### CONSTANTS ####################
3844

@@ -42,11 +48,12 @@ object CipherGetInstanceStringUsage extends ProjectAnalysisApplication {
4248

4349
// #################### ANALYSIS ####################
4450

45-
override def doAnalyze(
46-
project: Project[URL],
47-
parameters: Seq[String],
48-
isInterrupted: () => Boolean
49-
): BasicReport = {
51+
override protected def analyze(
52+
cp: Iterable[File],
53+
analysisConfig: CipherInstanceConfig,
54+
execution: Int
55+
): (Project[URL], BasicReport) = {
56+
val (project, _) = analysisConfig.setupProject(cp)
5057

5158
val report = new ConcurrentLinkedQueue[String]
5259

@@ -71,6 +78,6 @@ object CipherGetInstanceStringUsage extends ProjectAnalysisApplication {
7178
}
7279
}
7380

74-
BasicReport(report.asScala.mkString("\n"))
81+
(project, BasicReport(report.asScala.mkString("\n")))
7582
}
7683
}
Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,35 @@
22
package org.opalj
33
package ai
44

5+
import java.io.File
56
import java.net.URL
67
import java.util.concurrent.ConcurrentLinkedQueue
78
import scala.jdk.CollectionConverters._
89

910
import org.opalj.br.Method
1011
import org.opalj.br.analyses.BasicReport
1112
import org.opalj.br.analyses.Project
12-
import org.opalj.br.analyses.ProjectAnalysisApplication
13+
import org.opalj.br.analyses.ProjectsAnalysisApplication
14+
import org.opalj.br.analyses.SomeProject
15+
import org.opalj.br.fpcf.cli.MultiProjectAnalysisConfig
1316
import org.opalj.br.instructions.IFICMPInstruction
1417

1518
/**
16-
* A shallow analysis that tries to identify useless computations; here, "ifs" where the condition
17-
* is constant.
19+
* A shallow analysis that tries to identify useless computations; here, "ifs" where the condition is constant.
1820
*
1921
* @author Michael Eichberg
2022
*/
21-
object UselessComputationsMinimal extends ProjectAnalysisApplication {
23+
object ConstantIfs extends ProjectsAnalysisApplication {
2224

23-
class AnalysisDomain(val project: Project[URL], val method: Method)
25+
protected class ConstantIfsConfig(args: Array[String]) extends MultiProjectAnalysisConfig(args) {
26+
val description = "Collects ifs where the condition is constant"
27+
}
28+
29+
protected type ConfigType = ConstantIfsConfig
30+
31+
protected def createConfig(args: Array[String]): ConstantIfsConfig = new ConstantIfsConfig(args)
32+
33+
class AnalysisDomain(val project: SomeProject, val method: Method)
2434
extends CorrelationalDomain
2535
with domain.DefaultSpecialDomainValuesBinding
2636
with domain.DefaultHandlingOfMethodResults
@@ -39,16 +49,17 @@ object UselessComputationsMinimal extends ProjectAnalysisApplication {
3949
with domain.TheProject
4050
with domain.TheMethod
4151

42-
def doAnalyze(
43-
theProject: Project[URL],
44-
parameters: Seq[String],
45-
isInterrupted: () => Boolean
46-
): BasicReport = {
52+
override protected def analyze(
53+
cp: Iterable[File],
54+
analysisConfig: ConstantIfsConfig,
55+
execution: Int
56+
): (Project[URL], BasicReport) = {
57+
val (project, _) = analysisConfig.setupProject(cp)
4758

4859
val results = new ConcurrentLinkedQueue[String]()
49-
theProject.parForeachMethodWithBody(isInterrupted) { m =>
60+
project.parForeachMethodWithBody() { m =>
5061
val method = m.method
51-
val result = BaseAI(method, new AnalysisDomain(theProject, method))
62+
val result = BaseAI(method, new AnalysisDomain(project, method))
5263
import result.domain.ConcreteIntegerValue
5364
collectPCWithOperands(result.domain)(method.body.get, result.operandsArray) {
5465
case (
@@ -62,6 +73,6 @@ object UselessComputationsMinimal extends ProjectAnalysisApplication {
6273
}
6374
}
6475

65-
BasicReport(results.asScala.mkString(s"${results.size} useless computations:\n", "\n", "\n"))
76+
(project, BasicReport(results.asScala.mkString(s"${results.size} useless computations:\n", "\n", "\n")))
6677
}
6778
}

DEVELOPING_OPAL/demos/src/main/scala/org/opalj/ai/ExceptionUsage.scala

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22
package org.opalj
33
package ai
44

5+
import java.io.File
56
import java.net.URL
67

7-
import org.opalj.br._
8-
import org.opalj.br.analyses._
9-
import org.opalj.br.instructions._
8+
import org.opalj.br.ClassHierarchy
9+
import org.opalj.br.ClassType
10+
import org.opalj.br.Method
11+
import org.opalj.br.MethodWithBody
12+
import org.opalj.br.PC
13+
import org.opalj.br.analyses.BasicReport
14+
import org.opalj.br.analyses.Project
15+
import org.opalj.br.analyses.ProjectsAnalysisApplication
16+
import org.opalj.br.analyses.SomeProject
17+
import org.opalj.br.fpcf.cli.MultiProjectAnalysisConfig
18+
import org.opalj.br.instructions.AASTORE
19+
import org.opalj.br.instructions.ARETURN
20+
import org.opalj.br.instructions.ATHROW
21+
import org.opalj.br.instructions.FieldWriteAccess
22+
import org.opalj.br.instructions.MethodInvocationInstruction
23+
import org.opalj.log.OPALLogger
1024

1125
import scala.collection.parallel.CollectionConverters.ImmutableIterableIsParallelizable
1226

@@ -15,32 +29,36 @@ import scala.collection.parallel.CollectionConverters.ImmutableIterableIsParalle
1529
*
1630
* @author Michael Eichberg
1731
*/
18-
object ExceptionUsage extends ProjectAnalysisApplication {
32+
object ExceptionUsage extends ProjectsAnalysisApplication {
1933

20-
override def title: String = "Intra-procedural Usage of Exceptions"
34+
protected class ExceptionUsageConfig(args: Array[String]) extends MultiProjectAnalysisConfig(args) {
35+
val description = "Collects intra-procedural usage of exceptions"
36+
}
37+
38+
protected type ConfigType = ExceptionUsageConfig
2139

22-
override def description: String = "Analyses the usage of exceptions."
40+
protected def createConfig(args: Array[String]): ExceptionUsageConfig = new ExceptionUsageConfig(args)
2341

24-
override def doAnalyze(
25-
theProject: Project[URL],
26-
parameters: Seq[String],
27-
isInterrupted: () => Boolean
28-
): BasicReport = {
42+
override protected def analyze(
43+
cp: Iterable[File],
44+
analysisConfig: ExceptionUsageConfig,
45+
execution: Int
46+
): (Project[URL], BasicReport) = {
47+
val (project, _) = analysisConfig.setupProject(cp)
2948

30-
implicit val ch: ClassHierarchy = theProject.classHierarchy
49+
implicit val ch: ClassHierarchy = project.classHierarchy
3150

32-
if (theProject.classFile(ClassType("java/lang/Object")).isEmpty) {
33-
Console.err.println(
34-
"[warn] It seems as if the JDK was not loaded" +
35-
"(use: -libcp=<PATH TO THE JRE>); " +
36-
"the results of the analysis might not be useful."
37-
)
51+
if (project.classFile(ClassType("java/lang/Object")).isEmpty) {
52+
OPALLogger.error(
53+
"analysis configuration",
54+
"It seems as if the JDK was not loaded; the results of the analysis might not be useful."
55+
)(project.logContext)
3856
}
3957

4058
val usages = (for {
41-
classFile <- theProject.allProjectClassFiles.par
59+
classFile <- project.allProjectClassFiles.par
4260
method @ MethodWithBody(body) <- classFile.methods
43-
result = BaseAI(method, new ExceptionUsageAnalysisDomain(theProject, method))
61+
result = BaseAI(method, new ExceptionUsageAnalysisDomain(project, method))
4462
} yield {
4563
import scala.collection.mutable._
4664

@@ -133,13 +151,13 @@ object ExceptionUsage extends ProjectAnalysisApplication {
133151
else {
134152
Some(usages)
135153
}
136-
}).filter(_.isDefined).map(_.get).flatten
154+
}).filter(_.isDefined).flatMap(_.get)
137155

138156
val (notUsed, used) = usages.toSeq.partition(_.usageInformation.isEmpty)
139157
var report = used.map(_.toString).toList.sorted.mkString("\nUsed\n", "\n", "\n")
140158
report += notUsed.map(_.toString).toList.sorted.mkString("\nNot Used\n", "\n", "\n")
141159

142-
BasicReport(report)
160+
(project, BasicReport(report))
143161
}
144162

145163
}
@@ -171,7 +189,7 @@ object UsageKind extends Enumeration {
171189
val StoredInField = UsageKind.Value
172190
}
173191

174-
class ExceptionUsageAnalysisDomain(val project: Project[java.net.URL], val method: Method)
192+
class ExceptionUsageAnalysisDomain(val project: SomeProject, val method: Method)
175193
extends CorrelationalDomain
176194
with domain.DefaultSpecialDomainValuesBinding
177195
with domain.l0.TypeLevelPrimitiveValuesConversions

DEVELOPING_OPAL/demos/src/main/scala/org/opalj/ai/InfiniteRecursions.scala

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package ai
44

55
import scala.language.existentials
66

7+
import java.io.File
78
import java.net.URL
89
import scala.Console.BLUE
910
import scala.Console.BOLD
@@ -12,8 +13,9 @@ import scala.Console.RESET
1213
import org.opalj.br.Method
1314
import org.opalj.br.analyses.BasicReport
1415
import org.opalj.br.analyses.Project
15-
import org.opalj.br.analyses.ProjectAnalysisApplication
16+
import org.opalj.br.analyses.ProjectsAnalysisApplication
1617
import org.opalj.br.analyses.SomeProject
18+
import org.opalj.br.fpcf.cli.MultiProjectAnalysisConfig
1719
import org.opalj.br.instructions.INVOKEINTERFACE
1820
import org.opalj.br.instructions.INVOKESPECIAL
1921
import org.opalj.br.instructions.INVOKESTATIC
@@ -28,19 +30,22 @@ import scala.collection.parallel.CollectionConverters.IterableIsParallelizable
2830
* @author Marco Jacobasch
2931
* @author Michael Eichberg
3032
*/
31-
object InfiniteRecursions extends ProjectAnalysisApplication {
33+
object InfiniteRecursions extends ProjectsAnalysisApplication {
3234

33-
override def title: String = "infinite recursions analysis"
34-
35-
override def description: String = {
36-
"identifies method which calls themselves using infinite recursion"
35+
protected class InfiniteRecursionConfig(args: Array[String]) extends MultiProjectAnalysisConfig(args) {
36+
val description = "Identifies method which calls themselves using infinite recursion"
3737
}
3838

39-
override def doAnalyze(
40-
project: Project[URL],
41-
parameters: Seq[String] = List.empty,
42-
isInterrupted: () => Boolean
43-
): BasicReport = {
39+
protected type ConfigType = InfiniteRecursionConfig
40+
41+
protected def createConfig(args: Array[String]): InfiniteRecursionConfig = new InfiniteRecursionConfig(args)
42+
43+
override protected def analyze(
44+
cp: Iterable[File],
45+
analysisConfig: InfiniteRecursionConfig,
46+
execution: Int
47+
): (Project[URL], BasicReport) = {
48+
val (project, _) = analysisConfig.setupProject(cp)
4449

4550
// In a real application we should take this from a parameter
4651
val maxRecursionDepth = 3
@@ -72,7 +77,7 @@ object InfiniteRecursions extends ProjectAnalysisApplication {
7277
result <- inifiniteRecursions(maxRecursionDepth, project, method, pcs)
7378
} yield { result }
7479

75-
BasicReport(result.map(_.toString).mkString("\n"))
80+
(project, BasicReport(result.map(_.toString).mkString("\n")))
7681
}
7782

7883
/**

0 commit comments

Comments
 (0)