<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang-format breaks stringized macro argument"
   href="https://bugs.llvm.org/show_bug.cgi?id=46383">46383</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format breaks stringized macro argument
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chris.hamilton@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23627" name="attach_23627" title="sample source that is mishandled by clang-format">attachment 23627</a> <a href="attachment.cgi?id=23627&action=edit" title="sample source that is mishandled by clang-format">[details]</a></span>
sample source that is mishandled by clang-format

clang-format breaks a stringized macro argument into tokens, which changes the
output of the formatted code.  Here's an example:

  [flextools-llvm/clang-tools-extra/clang-tidy]$ $builddir/bin/clang --version
  clang version 11.0.0  (xxxxxxxxx)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /repo/eahcmrh/flextools-llvm/build-debug/bin

  [flextools-llvm/clang-tools-extra/clang-tidy]$ cat trythis.c 
  #include <stdio.h>

  #define WRITETHIS(a,b)  do { printf(a, "TAG:" #b); } while (0)

  int main(void)
  {
    WRITETHIS("Output: %s\n\n", String-ized&Messy+But:  :Still=Intentional);
  }

  [flextools-llvm/clang-tools-extra/clang-tidy]$ $builddir/bin/clang trythis.c
-o trythis

  [flextools-llvm/clang-tools-extra/clang-tidy]$ ./trythis 
  Output: TAG:String-ized&Messy+But: :Still=Intentional


  [flextools-llvm/clang-tools-extra/clang-tidy]$ $builddir/bin/clang-format
trythis.c > formatted.c

  [flextools-llvm/clang-tools-extra/clang-tidy]$ cat formatted.c 
  #include <stdio.h>

  #define WRITETHIS(a, b)                                                      
 \
    do {                                                                       
 \
      printf(a, "TAG:" #b);                                                    
 \
    } while (0)

  int main(void) {
    WRITETHIS("Output: %s\n\n", String - ized &Messy + But
              :
              : Still = Intentional);
  }

  [flextools-llvm/clang-tools-extra/clang-tidy]$ $builddir/bin/clang
formatted.c -o formatted

  [flextools-llvm/clang-tools-extra/clang-tidy]$ ./formatted 
  Output: TAG:String - ized &Messy + But : : Still = Intentional

This functional difference in clang-formatted code is incorrect.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>