Skip to content

[analyzer] Analyzer reports duplicate warnings to console when using -analyzer-output=sarif-html #158103

@dbartol

Description

@dbartol

To repro:

int foo(int* p) {
    if (p != nullptr) {
        return 0;
    } else {
        return *p;
    }
}
clang --analyze -Xclang -analyzer-output=sarif-html

Actual result:

foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
    5 |         return *p;
      |                ^~
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
    5 |         return *p;
      |                ^~
foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
    5 |         return *p;
      |                ^~
3 warnings generated.

Expected result:

foo.cpp:5:16: warning: Dereference of null pointer (loaded from variable 'p') [core.NullDereference]
    5 |         return *p;
      |                ^~
1 warning generated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions