Skip to content

Commit 4b8ae2a

Browse files
committed
Merge branch 'main' into js/shared-dataflow-merge-main
2 parents 379952f + 4e3440a commit 4b8ae2a

File tree

60 files changed

+816
-677
lines changed

Some content is hidden

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

60 files changed

+816
-677
lines changed

.github/workflows/buildifier.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ jobs:
2424
extra_args: >
2525
buildifier --all-files 2>&1 ||
2626
(
27-
echo -e "In order to format all bazel files, please run:\n bazel run //misc/bazel:buildifier"; exit 1
27+
echo -e "In order to format all bazel files, please run:\n bazel run //misc/bazel/buildifier"; exit 1
2828
)

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ repos:
2626
name: Format bazel files
2727
files: \.(bazel|bzl)
2828
language: system
29-
entry: bazel run //misc/bazel:buildifier
29+
entry: bazel run //misc/bazel/buildifier
3030
pass_filenames: false
3131

3232
# DISABLED: can be enabled by copying this config and installing `pre-commit` with `--config` on the copy

cpp/ql/test/library-tests/dataflow/taint-tests/taint.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ void test_qualifiers()
450450
b.member = source();
451451
sink(b); // $ ir MISSING: ast
452452
sink(b.member); // $ ast,ir
453-
sink(b.getMember()); // $ ir MISSING: ast
453+
sink(b.getMember()); // $ MISSING: ir ast
454454

455455
c = new MyClass2(0);
456456

cpp/ql/test/library-tests/dataflow/taint-tests/vector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ void test_vector_swap() {
115115
v3.swap(v4);
116116

117117
sink(v1);
118-
sink(v2); // $ ir MISSING:ast
119-
sink(v3); // $ ir MISSING:ast
118+
sink(v2); // $ MISSING:ir ast
119+
sink(v3); // $ MISSING:ir ast
120120
sink(v4);
121121
}
122122

csharp/extractor/Semmle.Extraction.CSharp/Entities/Compilations/Compilation.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.IO;
44
using System.Linq;
55
using Microsoft.CodeAnalysis;
6+
using Semmle.Extraction.Entities;
67
using Semmle.Util;
78

89
namespace Semmle.Extraction.CSharp.Entities
@@ -89,13 +90,21 @@ public void PopulatePerformance(PerformanceMetrics p)
8990
trapFile.compilation_finished(this, (float)p.Total.Cpu.TotalSeconds, (float)p.Total.Elapsed.TotalSeconds);
9091
}
9192

93+
public void PopulateAggregatedMessages()
94+
{
95+
ExtractionMessage.groupedMessageCounts.ForEach(pair =>
96+
{
97+
Context.TrapWriter.Writer.compilation_info(this, $"Extractor message count for group '{pair.Key}'", pair.Value.ToString());
98+
});
99+
}
100+
92101
public override void WriteId(EscapingTextWriter trapFile)
93102
{
94103
trapFile.Write(hashCode);
95104
trapFile.Write(";compilation");
96105
}
97106

98-
public override Location ReportingLocation => throw new NotImplementedException();
107+
public override Microsoft.CodeAnalysis.Location ReportingLocation => throw new NotImplementedException();
99108

100109
public override bool NeedsPopulation => Context.IsAssemblyScope;
101110

csharp/extractor/Semmle.Extraction.CSharp/Entities/OrdinaryMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected OrdinaryMethod(Context cx, IMethodSymbol init)
2121
public override Microsoft.CodeAnalysis.Location ReportingLocation =>
2222
IsCompilerGeneratedDelegate()
2323
? Symbol.ContainingType.GetSymbolLocation()
24-
: Symbol.GetSymbolLocation();
24+
: BodyDeclaringSymbol.GetSymbolLocation();
2525

2626
public override bool NeedsPopulation => base.NeedsPopulation || IsCompilerGeneratedDelegate();
2727

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Analyser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ private void DoAnalyseCompilation()
250250

251251
public void LogPerformance(Entities.PerformanceMetrics p) => compilationEntity.PopulatePerformance(p);
252252

253+
public void ExtractAggregatedMessages() => compilationEntity.PopulateAggregatedMessages();
254+
253255
#nullable restore warnings
254256

255257
/// <summary>

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Extractor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ public static ExitCode Analyse(Stopwatch stopwatch, Analyser analyser, CommonOpt
458458

459459
sw.Restart();
460460
analyser.PerformExtraction(options.Threads);
461+
analyser.ExtractAggregatedMessages();
461462
sw.Stop();
462463
var cpuTime2 = currentProcess.TotalProcessorTime;
463464
var userTime2 = currentProcess.UserProcessorTime;

csharp/extractor/Semmle.Extraction/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ codeql_csharp_library(
2626
],
2727
"//conditions:default": [],
2828
}),
29+
internals_visible_to = ["Semmle.Extraction.CSharp"],
2930
visibility = ["//csharp:__subpackages__"],
3031
deps = [
3132
"//csharp/extractor/Semmle.Util",

csharp/extractor/Semmle.Extraction/Entities/ExtractionMessage.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.IO;
1+
using System.Collections.Concurrent;
2+
using System.IO;
23
using System.Threading;
34
using Semmle.Util;
45

@@ -7,6 +8,8 @@ namespace Semmle.Extraction.Entities
78
internal class ExtractionMessage : FreshEntity
89
{
910
private static readonly int limit = EnvironmentVariables.TryGetExtractorNumberOption<int>("MESSAGE_LIMIT") ?? 10000;
11+
12+
internal static readonly ConcurrentDictionary<string, int> groupedMessageCounts = [];
1013
private static int messageCount = 0;
1114

1215
private readonly Message msg;
@@ -25,6 +28,10 @@ private ExtractionMessage(Context cx, Message msg, bool bypassLimit) : base(cx)
2528

2629
protected override void Populate(TextWriter trapFile)
2730
{
31+
// For the time being we're counting the number of messages per severity, we could introduce other groupings in the future
32+
var key = msg.Severity.ToString();
33+
groupedMessageCounts.AddOrUpdate(key, 1, (_, c) => c + 1);
34+
2835
if (!bypassLimit)
2936
{
3037
var val = Interlocked.Increment(ref messageCount);

0 commit comments

Comments
 (0)