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

            Bug ID: 43947
           Summary: mis-indentation caused by macro/template instantiation
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangb...@nondot.org
          Reporter: s...@lukas-wirz.de
                CC: djas...@google.com, kli...@google.com,
                    llvm-bugs@lists.llvm.org

The problem I'm observing is not limited to clang-format-9 but also exists in 7
and 8 (I'm using the versions that are packaged in Debian/testing).

The .clang-format I'm using contains only "BasedOnStyle:  LLVM".

The file that gets misformatted is 
<<<<<<<
#define container_output(container)                                           
\
  template <typename T>                                                       
\
  ostream &operator<<(ostream &s, const container<T> &v) {                    
\
    s << "{";                                                                 
\
    for (typename container<T>::const_iterator x(v.begin()); x != v.end();) { 
\
      s << *x;                                                                
\
      if (++x != v.end())                                                     
\
        s << ",";                                                             
\
    }                                                                         
\
    s << "}";                                                                 
\
    return s;                                                                 
\
  }

container_output(vector)

int myfunc() {
  return 0;
}
>>>>>>>

where the macro definition is irrelevant and can be outcommented. 
Instantiating the template defined in the macro (correct without semicolon)
causes the following function to be indented as:

<<<<<<<
container_output(vector)

    int myfunc() {
  return 0;
}
>>>>>>>

which is clearly two indentation-levels too many in the first line.

cheers, Lukas Wirz

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to