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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to