]> granicus.if.org Git - clang/commit
[clang-format] Re-land: Fixup #include guard indents after parseFile()
authorMark Zeren <mzeren@vmware.com>
Mon, 5 Feb 2018 15:59:00 +0000 (15:59 +0000)
committerMark Zeren <mzeren@vmware.com>
Mon, 5 Feb 2018 15:59:00 +0000 (15:59 +0000)
commit8b74721557f9e345bf463e5fb25bf864feb53927
treeb09eb649f88fa206985b7d3130ea0a7ed102658e
parentdf40d20b431807c85c21bd77da2549e1ba925eed
[clang-format] Re-land: Fixup #include guard indents after parseFile()

Summary:
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.

Reviewers: krasimir, klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D42035

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@324246 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/UnwrappedLineParser.cpp
lib/Format/UnwrappedLineParser.h
unittests/Format/FormatTest.cpp