[llvm-bugs] [Bug 34552] New: clang-cpp incorrectly trims whitespace after include (breaking all indent sensitive languages).

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 11 05:03:45 PDT 2017


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

            Bug ID: 34552
           Summary: clang-cpp incorrectly trims whitespace after include
                    (breaking all indent sensitive languages).
           Product: clang
           Version: 5.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pantelis.antoniou at konsulko.com
                CC: llvm-bugs at lists.llvm.org

clang-cpp incorrectly trims whitespace after an include, which results in
brokeness in all environments that are indentation sensitive: YAML is such an
environment.

GCC's CPP behaves correctly.

--- x1.yaml ---
test:
  #include "x2.yaml"
  bar:
---

--- x2.yaml ---
  sub: true
---

GCC's cpp command line and output:
$ cpp -nostdinc -I.  -x assembler-with-cpp x1.yaml >x1.cpp-gcc.yaml

--- x1.cpp-gcc.yaml ---
# 1 "x1.yaml"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "x1.yaml"
test:
# 1 "x2.yaml" 1
  sub: true
# 3 "x1.yaml" 2
  bar:
---

Note that 'sub: true' is correctly indented.

Clang's cpp command line and output:

$ clang-cpp-5.0 -nostdinc -I.  -x assembler-with-cpp x1.yaml >x1.cpp-clang.yaml
--- x1.cpp-clang.yaml ---
# 1 "x1.yaml"
# 1 "<built-in>" 1
# 1 "x1.yaml" 2
test:

# 1 "./x2.yaml" 1
  sub: true
# 3 "x1.yaml" 2
 bar:
---

Note that 'bar' is incorrectly shifted left by one space (which completely
breaks YAML formatting).

There is extra white-space after 'test:' but that doesn't cause any problems.

-- 
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/20170911/a212f9b8/attachment-0001.html>


More information about the llvm-bugs mailing list