[llvm-bugs] [Bug 46555] New: Clang-format does not de-duplicate indented #includes

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jul 2 06:10:44 PDT 2020


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

            Bug ID: 46555
           Summary: Clang-format does not de-duplicate indented #includes
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kyrylo.bohdanenko at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Usually, clang-format will de-duplicate #include directives.

However, on special inputs, it will not. This behavior is inconsistent.

STEPS TO REPRODUCE

1. Create a source:
cat >main.cpp <<__EOF__
#include <vector>
  #include <vector>

2. Run clang-format:
clang-format main.cpp

EXPECTED RESULTS

$ clang-format main.cpp
#include <vector>

ACTUAL RESULTS

$ clang-format main.cpp
#include <vector>
#include <vector>

ADDITIONAL INFORMATION

I am expecting headers to be de-duplicated, because the second pass actutally
eliminates duplicated includes:

$ clang-format main.cpp | clang-format --
#include <vector>

-- 
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/20200702/b3c33f20/attachment-0001.html>


More information about the llvm-bugs mailing list