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

Incorrect header resolving for headers with identical names

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • Qt Creator 4.6.0
    • C/C++/Obj-C++ Support
    • None

    Description

      When project with multiple subprojects contains multiple headers with the same name header lookup during initial parsing after opening the project incorrectly chooses which copy of header was included. Precompiled headers usually have the name in each subproject making it quite common. This is causing problems for other functionality like autotest/google test plugin which relies on correctly resolved includes to decide if a source file includes unit test framework and thus could contain unit tests.

      I did some debugging and it seems that the same instance of CppSourcePreprocessor gets reused for analyzing all source files. It contains m_fileNameCache for caching header lookups. The cache doesn't expect include directories to change resulting in incorrectly resolved headers. To confirm my theory I tried commenting out cache usage in CppSourceProcessor::resolveFile and it helped but this obviously isn't a proper fix.

       

      To reproduce problem:

      1) open the project in attachment, but do not open any source files

      2) configure the project and wait until source files are parsed

      3) open tools/C+/C+ code model inspector

      4) observe that it incorrectly indicates that both proja/sub/a.cpp and projb/sub/b.cpp include the same common.h instead of common.h from corresponding subproject

      Attachments

        1. header_testcase.zip
          3 kB
          Kārlis Seņko

        Issue Links

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

          Activity

            People

              kandeler Christian Kandeler
              karliss Kārlis Seņko
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes