Bug 411440

Summary: Invalid/truncated values in YAML file generated by -export-fixes= with clang diagnostics
Product: [Developer tools] clazy Reporter: Nikolai Kosjar <nikolai.kosjar>
Component: generalAssignee: Sergio Martins <smartins>
Status: RESOLVED FIXED    
Severity: normal CC: chgans, smartins
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Nikolai Kosjar 2019-08-30 10:44:33 UTC
I'm on current clazy master, commit 7a3d9cc18d96d22f8f3613396fc21a03f7f023d4

-export-fixes in combination with e.g. -Weverything seems to produce wrong yaml files:


/tmp/test % cat clazy.clang-diagnostic.cpp 
void g()
{
    int *i;
    ++i;
}

/tmp/test % /d2/clazy/trunk/installs/Release/bin/clazy-standalone -export-fixes=/tmp/yaml.txt clazy.clang-diagnostic.cpp -- -Weverything
/tmp/test/clazy.clang-diagnostic.cpp:1:6: warning: no previous prototype for function 'g' [-Wmissing-prototypes]
void g()
     ^
/tmp/test/clazy.clang-diagnostic.cpp:4:7: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
    ++i;
      ^
/tmp/test/clazy.clang-diagnostic.cpp:3:11: note: initialize the variable 'i' to silence this warning
    int *i;
          ^
           = nullptr
2 warnings generated.

==> OK, output here looks fine



/tmp/test % cat /tmp/yaml.txt 
---
MainSourceFile:  '/tmp/test/clazy.clang-diagnostic.cpp'
Diagnostics:     
  - DiagnosticName:  ' previous prototype for function ''g'''
    Message:         'no previous prototype for function ''g'''
    FileOffset:      5
    FilePath:        '/tmp/test/clazy.clang-diagnostic.cpp'
    Replacements:    []
  - DiagnosticName:  'riable ''i'' is uninitialized when used here'
    Message:         'variable ''i'' is uninitialized when used here'
    FileOffset:      29
    FilePath:        '/tmp/test/clazy.clang-diagnostic.cpp'
    Replacements:    []
...

==> Ops, DiagnosticName should be a name, but it's a truncated version of the diagnostic message.
==> Ops, Message is also truncated.
Comment 1 Sergio Martins 2019-09-01 14:42:09 UTC
Git commit afc877b17297aedf9621bd61d850f60b34aece8f by Sergio Martins.
Committed on 01/09/2019 at 14:39.
Pushed by smartins into branch 'master'.

Fix exporting built-in warnings to yaml

The message didn't have the [checkName] tags

M  +16   -5    src/FixItExporter.cpp

https://commits.kde.org/clazy/afc877b17297aedf9621bd61d850f60b34aece8f