]> granicus.if.org Git - clang/commit
[refactor][extract] insert semicolons into extracted/inserted code
authorAlex Lorenz <arphaman@gmail.com>
Fri, 3 Nov 2017 18:11:22 +0000 (18:11 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 3 Nov 2017 18:11:22 +0000 (18:11 +0000)
commit92684aa6d4f1860a13ae9ea702b711afaaa94168
tree6213b48cf64cb85aefb332aa1a348066a19115bb
parentc7e8e8e2edf48ee98341a80e713e2947a4861a55
[refactor][extract] insert semicolons into extracted/inserted code
when needed

This commit implements the semicolon insertion logic into the extract
refactoring. The following rules are used:

- extracting expression: add terminating ';' to the extracted function.
- extracting statements that don't require terminating ';' (e.g. switch): add
  terminating ';' to the callee.
- extracting statements with ';':  move (if possible) the original ';' from the
  callee and add terminating ';'.
- otherwise, add ';' to both places.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@317343 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Lex/Lexer.h
lib/Lex/Lexer.cpp
lib/Tooling/Refactoring/CMakeLists.txt
lib/Tooling/Refactoring/Extract.cpp
lib/Tooling/Refactoring/Extract/SourceExtraction.cpp [new file with mode: 0644]
lib/Tooling/Refactoring/Extract/SourceExtraction.h [new file with mode: 0644]
test/Refactor/Extract/ExtractExprIntoFunction.cpp
test/Refactor/Extract/ExtractionSemicolonPolicy.cpp [new file with mode: 0644]
test/Refactor/Extract/ExtractionSemicolonPolicy.m [new file with mode: 0644]