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

Clang code model does not read "-include" compiler flag

    XMLWordPrintable

Details

    • 888ea6bbbb0f4c6bb6b5616046e600b9520e4faf (qt-creator/qt-creator/master)

    Description

      Summary
      If "-include" gets added to CMAKE_CXX_FLAGS in CMakeLists.txt, clang code model does not seem to use this flag, and subsequently reports incorrect errors caused by missing headers.

      Minimal example

      CMakeLists.txt

      cmake_minimum_required(VERSION 2.8)
      
      project(codeModelBug)
      
      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include ${CMAKE_SOURCE_DIR}/pch.h")
      
      add_executable(codeModelBug main.cpp)
      

      main.cpp

      int main()
      {
          // clang code model: error: use of undeclared identifier 'helloWorld'
          helloWorld();
          return 0;
      }
      

      pch.h

      #pragma once
      
      #include <iostream>
      
      inline void helloWorld()
      {
          std::cout << "Hello World!" << std::endl;
      }
      

       

      The example can also be found as .zip in the Downloads.

      The example compiles and executes fine. Just the clang code model and the syntax completion fail to find the helloWorld function.

      Attachments

        1. codeModelBug.zip
          1.0 kB
          Martin Stumpf

        Issue Links

          Activity

            People

              kandeler Christian Kandeler
              mstumpf Martin Stumpf
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: