[llvm-bugs] [Bug 43304] New: clang-format main include file is not chosen correctly

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Sep 13 00:47:36 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=43304

            Bug ID: 43304
           Summary: clang-format main include file is not chosen correctly
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: wojciech.gumula at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

When there is include file with the same name as desired *main-include* but
located in different directory, it can be mistakenly chosen as a *main-include*
if its include directive is defined before the desired include.

Example:

//file: .clang-format
---
IncludeBlocks: Regroup
Language: Cpp
SortIncludes: 'true'
...

//file: test.cpp

#include "a/asdf.hpp"
#include "a/test.hpp"
#include "test.hpp"

Formatted:
#include "a/test.hpp"

#include "a/asdf.hpp"
#include "test.hpp"

Given the "test.hpp" is ordered before "a/test.hpp", the *main-include* will be
correctly selected as *test.hpp*.

clang-format version 8.0.0 (tags/google/stable/2019-01-18)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190913/01ca97b1/attachment-0001.html>


More information about the llvm-bugs mailing list