[llvm-bugs] [Bug 35276] New: Incorrect formatting in presence of preprocessor directives surrounding a comment

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 10 03:26:26 PST 2017


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

            Bug ID: 35276
           Summary: Incorrect formatting in presence of preprocessor
                    directives surrounding a comment
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: artemiev.mikhail at gmail.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

The formatting goes wrong with the following example.

$ cat test.cpp
class A {
public:
  A(const A &a) : data_(a.data_) {
#ifdef FOO
    doStuff();
#endif
  }
  A(A && a) : data_(std::move(a.data_)) {
#ifdef FOO
  // placeholder
#endif
  }
  A(const A& a, int len) {
#ifdef FOO
    doOtherStuff();
#endif
  }
}

$ bin/clang-format -style=llvm test.cpp | tee test_fmt.cpp
class A {
public:
  A(const A &a) : data_(a.data_) {
#ifdef FOO
    doStuff();
#endif
  }
  A(A &&a)
      : data_(std::move(a.data_)){
#ifdef FOO
  // placeholder
#endif
        } A(const A &a, int len) {
#ifdef FOO
    doOtherStuff();
#endif
  }
}

$ diff -u test.cpp test_fmt.cpp
--- test.cpp
+++ test_fmt.cpp
@@ -5,12 +5,12 @@
     doStuff();
 #endif
   }
-  A(A && a) : data_(std::move(a.data_)) {
+  A(A &&a)
+      : data_(std::move(a.data_)){
 #ifdef FOO
   // placeholder
 #endif
-  }
-  A(const A& a, int len) {
+        } A(const A &a, int len) {
 #ifdef FOO
     doOtherStuff();
 #endif

-- 
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/20171110/d86fe247/attachment.html>


More information about the llvm-bugs mailing list