[PATCH] D42035: [clang-format] Fixup #include guard indents after parseFile()

Mark Zeren via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 14 07:29:41 PST 2018


mzeren-vmw created this revision.
mzeren-vmw added reviewers: euhlmann, krasimir, klimek.
Herald added a subscriber: cfe-commits.

When a preprocessor indent closes after the last line of normal code we do not
correctly fixup include guard indents. For example:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #  define A 0
  #endif
  #endif

incorrectly reformats to:

  #ifndef HEADER_H
  #define HEADER_H
  #if 1
  int i;
  #    define A 0
  #  endif
  #endif

To resolve this issue we must fixup levels after parseFile(). Delaying
the fixup introduces a new state, so consolidate include guard search
state into an enum.


Repository:
  rC Clang

https://reviews.llvm.org/D42035

Files:
  lib/Format/UnwrappedLineParser.cpp
  lib/Format/UnwrappedLineParser.h
  unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42035.129776.patch
Type: text/x-patch
Size: 6770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180114/b36c6ed8/attachment-0001.bin>


More information about the cfe-commits mailing list