Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-23889

Clang code model diagnostics are not properly reported for header files

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Not Evaluated
    • None
    • Qt Creator 4.11.1, Qt Creator 4.12.0-beta2
    • C/C++/Obj-C++ Support
    • None
    • (1) QtCreator 4.11.1 on Arch Linux (Kernel 5.5.9)
      (2) QtCreator 4.12.0-beta2 on Windows 10 (x64)
    • Linux/X11, Windows

    Description

      Hi folks,

      I'm facing a strange problem with the clang code model and the reporting/highlighting of diagnostic issues. I was searching the internet and this bug tracker for this issue but I haven't found anything...

      Good case: When I'm writing bad C++ code in a *.cpp file, the semantic issue is shown as line annotation and it is shown in the Issues pane at the bottom where all warnings and errors are displayed.

      Bad case: When I'm writing bad C++ code in *.h(pp) file, the semantic issue is neither shown as line annotation nor it is displayed in the issues pane. However, there is a yellow triangle at the corresponding line number which reports the semantic issue when hovering over it.

      Code example

      Here's a minimal example using Foo.h and Foo.cpp.

      // Foo.h
      #pragma once
      
      class Foo
      {
      public:
          void bar(int foo) {}    
      
          void baz(int foo);
      };
      
      // Foo.cpp
      #include "Foo.h"
      
      void Foo::baz(int foo)
      {
          // do nothing with foo
      }
      

      Diagnostic Configuration

      Tools --> Options --> C++ --> Code Model --> Diagnostic Configuration --> Manage 

      -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-global-constructors -Wno-old-style-cast -Wno-weak-vtables -Wno-switch-enum

      The option Use diagnostic flags from build system is disabled. 

      Annotations

      Tools --> Options --> Text Editor --> Display:

      • Line annotations are enabled
      • The option Next to editor content is selected

      Output

      Everything works fine for the *.cpp.

      For the *.h(pp) the behavior is different.

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kandeler Christian Kandeler
              monobr0w Uwe Kraft
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes