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

clang diagnostic hints do not seem to work correctly with precompiled headers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • Qt Creator 4.2.0-rc1
    • Qt Creator 3.6.0
    • C/C++/Obj-C++ Support
    • None
    • Windows 7, Visual C++ 2015

    Description

      clang diagnostic hints do not seem to work correctly with precompiled headers

      at least with Visual C++ 2015 compiler and some style of writing

      For project files ...

      // stdafx.h
      #include <string>

      // stdafx.cpp
      #include "stdafx.h"
      using std::string;

      // thing.h
      class thing

      { string name_; }

      ;

      // thing.cpp
      #include "stdafx.h"
      #include "thing.h"

      // ...

      ... build works normally, no errors or warnings, therefore, apart from style, this is okay for compiler.

      In QtCreator, however, with thing.h file open in editor, it shows an error: unknown type name 'string', which looks like the precompiled header is ignored.

      THERE SHOULD NOT BE A DIFFERENCE BETWEEN WHAT COMPILER CAN DIGEST AND WHAT ANALYZER IS SAYING ABOUT IT.

      By definition of precompiled header in MSVC, everything what is above #include "stdafx.h" is ignored, then the content of precompiled header is pasted in. (simplified explanation)

      Also it seems to me like thing.h is analyzed on it's own, separately from everything, neglecting thing.cpp, although the compilation unit, AFAIK, is a source file, not a separate header file.

      Should thing.h be analyzed as a part of source file, then, before inclusion of thing.h, stdafx.h is included and everything used in thing.h is declared and defined.

      I tried to force include by -include stdafx.h in Options/.../clang code model, with either relative or absolute path, but with no luck, my header files are flooded by dozens of red marks and there is no way to turn it off. Which is unusable.

      And, of course, I have a precompiled header clause in my project file, being it either qmake or qbs.

      I found a reference on an internet to some "new page in projects mode related to clang code model" but did not find it in my QtCreator 3.6.0, so I assume this was applicable to some older version.

      Attachments

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

        Activity

          People

            kosjar Nikolai Kosjar
            prismacolor prisma color
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes