[llvm-bugs] [Bug 48227] New: clang-format confused by stringizing # in a macro

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 19 01:20:58 PST 2020


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

            Bug ID: 48227
           Summary: clang-format confused by stringizing # in a macro
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: labath at google.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

This is extracted from some (hairy) code in lldb. It looks like the tool
mistakes #x for a preprocessor directive.
=====
$ cat a.cc 
#define FOO(x) { #x, asodgoasigosiangoisdangoisandgion,
sagoingsodingsoisnoisgnogsiansg, asgdoingsoadiisgadnosgidnsgioa }
#define FOO(x) { x, asodgoasigosiangoisdangoisandgion,
sagoingsodingsoisnoisgnogsiansg, asgdoingsoadiisgadnosgidnsgioa }
$ clang-format /tmp/a.cc 
#define FOO(x)                                                                
\
  {                                                                           
\
#x, asodgoasigosiangoisdangoisandgion, sagoingsodingsoisnoisgnogsiansg,    \
        asgdoingsoadiisgadnosgidnsgioa                                        
\
  }
#define FOO(x)                                                                
\
  {                                                                           
\
    x, asodgoasigosiangoisdangoisandgion, sagoingsodingsoisnoisgnogsiansg,    
\
        asgdoingsoadiisgadnosgidnsgioa                                        
\
  }
=====
The second macro also looks suboptimal (I would've expected the second line to
be aligned to the same column as "x"), but at least it's valid code...

-- 
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/20201119/f22b1ffc/attachment.html>


More information about the llvm-bugs mailing list