<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 IndentPPDirectives shouldn't always indent pp directives"
   href="https://bugs.llvm.org/show_bug.cgi?id=48653">48653</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-format IndentPPDirectives shouldn't always indent pp directives
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>11.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>barry.revzin@gmail.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>The motivation for having IndentPPDirectives is to be able to take code like:

#if this
#if that
#define other
#endif
#endif

And layer it in a way that's actually readable (space before or after hash
based on user preference):

#if this
#    if that
#        define other
#    endif
#endif

But it doesn't really seem to apply as much to use of preprocessor directives
that aren't all contiguous like that. For instance, we have the following
example (which gets indented as shown):

#ifdef __cpp_deduction_guides
template <typename R, typename... Args>
function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;

#    ifdef __cpp_noexcept_function_type
template <typename R, typename... Args>
function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
#    endif
#endif


This is a weird intermediate layer of formatting. It seems like either nothing
should be indented here (i.e. don't indent preprocessor directives if they
follow code):

#ifdef __cpp_deduction_guides
template <typename R, typename... Args>
function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;

#ifdef __cpp_noexcept_function_type
template <typename R, typename... Args>
function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
#endif
#endif

Or everything should be indented (i.e. a preprocessor #if is just as much
indent-worthy as a language if):

#ifdef __cpp_deduction_guides
    template <typename R, typename... Args>
    function_ref(R (*)(Args...)) -> function_ref<R(Args...)>;

#   ifdef __cpp_noexcept_function_type
        template <typename R, typename... Args>
        function_ref(R (*)(Args...) noexcept) -> function_ref<R(Args...)>;
#   endif
#endif

I can't say which is better, but either seems better than status quo</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>