• Home
  • History
  • Annotate
  • only in /external/clang/unittests/
History log of /external/clang/unittests/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
ef8225444452a1486bd721f3285301fe84643b00 21-Jul-2014 Stephen Hines <srhines@google.com> Update Clang for rebase to r212749.

This also fixes a small issue with arm_neon.h not being generated always.

Includes a cherry-pick of:
r213450 - fixes mac-specific header issue
r213126 - removes a default -Bsymbolic on Android

Change-Id: I2a790a0f5d3b2aab11de596fc3a74e7cbc99081d
ST/ASTVectorTest.cpp
ST/CMakeLists.txt
ST/CommentParser.cpp
ST/NamedDeclPrinterTest.cpp
ST/SourceLocationTest.cpp
ST/StmtPrinterTest.cpp
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
STMatchers/Dynamic/RegistryTest.cpp
asic/FileManagerTest.cpp
asic/SourceManagerTest.cpp
asic/VirtualFileSystemTest.cpp
ormat/FormatTest.cpp
ormat/FormatTestJS.cpp
ormat/FormatTestProto.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
ema/ExternalSemaSourceTest.cpp
ooling/CommentHandlerTest.cpp
ooling/CompilationDatabaseTest.cpp
ooling/RecursiveASTVisitorTest.cpp
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
ooling/TestVisitor.h
ooling/ToolingTest.cpp
ibclang/LibclangTest.cpp
6bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89 29-May-2014 Stephen Hines <srhines@google.com> Update Clang for 3.5 rebase (r209713).

Change-Id: I8c9133b0f8f776dc915f270b60f94962e771bc83
ST/CommentLexer.cpp
ST/CommentParser.cpp
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
asic/SourceManagerTest.cpp
ormat/FormatTest.cpp
ormat/FormatTestJS.cpp
ormat/FormatTestProto.cpp
ex/CMakeLists.txt
ex/LexerTest.cpp
ex/Makefile
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
ooling/RecursiveASTVisitorTest.cpp
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
ooling/ToolingTest.cpp
ibclang/LibclangTest.cpp
651f13cea278ec967336033dd032faef0e9fc2ec 24-Apr-2014 Stephen Hines <srhines@google.com> Updated to Clang 3.5a.

Change-Id: I8127eb568f674c2e72635b639a3295381fe8af82
ST/ASTContextParentMapTest.cpp
ST/ASTTypeTraitsTest.cpp
ST/CMakeLists.txt
ST/CommentParser.cpp
ST/DeclPrinterTest.cpp
ST/DeclTest.cpp
ST/EvaluateAsRValueTest.cpp
ST/ExternalASTSourceTest.cpp
ST/MatchVerifier.h
ST/SourceLocationTest.cpp
ST/StmtPrinterTest.cpp
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
STMatchers/CMakeLists.txt
STMatchers/Dynamic/CMakeLists.txt
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
asic/CMakeLists.txt
asic/FileManagerTest.cpp
asic/VirtualFileSystemTest.cpp
MakeLists.txt
river/CMakeLists.txt
river/Makefile
river/MultilibTest.cpp
ormat/CMakeLists.txt
ormat/FormatTest.cpp
ormat/FormatTestJS.cpp
ormat/FormatTestProto.cpp
ormat/FormatTestUtils.h
rontend/CMakeLists.txt
rontend/FrontendActionTest.cpp
ex/CMakeLists.txt
ex/PPCallbacksTest.cpp
akefile
ema/CMakeLists.txt
ema/ExternalSemaSourceTest.cpp
ooling/CMakeLists.txt
ooling/CompilationDatabaseTest.cpp
ooling/RecursiveASTVisitorTest.cpp
ooling/RefactoringCallbacksTest.cpp
ooling/ToolingTest.cpp
ibclang/CMakeLists.txt
ibclang/LibclangTest.cpp
ibclang/Makefile
6c1dc7870f457803a9b256ed868da82532be820b 18-Nov-2013 Samuel Benzaquen <sbenza@google.com> Add partial support for the hasDeclaration() matcher in the dynamic layer.

Summary:
Add partial support for the hasDeclaration() matcher in the dynamic layer.
This matcher has some special logic to allow any type that has a getDecl() method. We do not support this right now.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1889

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195013 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
c8f03423e23d4e093d8149fd924e6fef26a15e94 17-Nov-2013 Edwin Vane <revane@gmail.com> Relax some preconditions for using FixedCompilationDatabase.

FixedCompilationDatabase (FCD) requires that the arguments it consumes after
'--' must not include positional parameters or the argv[0] of the tool. This
patch relaxes those restrictions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194968 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
a9f280942e3129a3d9e051bcf1bb5616243f212c 13-Nov-2013 Alexander Kornienko <alexfh@google.com> Correctly mark first token in the presence of UTF-8 BOM.

Summary: Fixes http://llvm.org/PR17753

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2159

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194576 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2ab056f31b83b8f1751d54614138f2e57e480c77 13-Nov-2013 NAKAMURA Takumi <geek4civic@gmail.com> unittests/Tooling/ToolingTest.cpp: Suppress new tests on win32, due to handling of virtual file, such "/a.cc".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194534 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
cb5a9ecef48756841652f00311215814746e1e3f 12-Nov-2013 Manuel Klimek <klimek@google.com> Add test for injecting diagnostic consumers into a ClangTool.

As suggested by pcc on 194226.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194494 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
a7462b8ce22a3f754bf51eeeb01adafc42b32cea 12-Nov-2013 Alexander Kornienko <alexfh@google.com> Remove extra whitespace instead of breaking the line in comments when possible.

Summary: Solves the problem described in http://llvm.org/PR17756

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2131

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194493 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5486a421a47a8922337aa83ac3b0fbb098dc1fe4 12-Nov-2013 Alexander Kornienko <alexfh@google.com> Do not insert backslashes, when breaking line comments after preprocessor directives.

Summary: This solves http://llvm.org/PR17536

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D2142

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194491 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a7856d021a1f318f9319c0a3028f0d76e38b6ca1 09-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Fix alignment of ObjC string literals.

This used to interfere with AlwaysBreakBeforeMultilineStrings.

This fixes llvm.org/PR17856.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194310 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0ce1c9ade71a2ed56dafddcd5d95e4e75fd91255 09-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve clang-format's detection about comment binding.

Before, existing code in the form of:

int a; // this is a.
// This is
// b.
int b;

Got turned into:

int a; // this is a.
// This is
// b.
int b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194294 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8b156e2a040d7a652e821878b68822041f65d71a 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of operators forced to new lines.

Before:
unsigned ContentSize =
sizeof(int16_t) // DWARF ARange version number
+
sizeof(int32_t) // Offset of CU in the .debug_info section
+
sizeof(int8_t) // Pointer Size (in bytes)
+
sizeof(int8_t); // Segment Size (in bytes)

After:
unsigned ContentSize =
sizeof(int16_t) // DWARF ARange version number
+ sizeof(int32_t) // Offset of CU in the .debug_info section
+ sizeof(int8_t) // Pointer Size (in bytes)
+ sizeof(int8_t); // Segment Size (in bytes)

This fixes llvm.org/PR17687.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194276 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c2e0329c8b84b16252184db4dd575c9e9fb93efe 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Don't auto-break short macros in WebKit style.

This fixes llvm.org/PR17842.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194268 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
deb61c5169531895a3cfa02d77b4d8f315f5e64b 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve linebreaking and indentation for ObjC calls.

Before:
popup_wdow_.reset([[RenderWidgetPopupWindow alloc]
iniithContentRect:
NSMakRet(origin_global.x, origin_global.y, pos.width(), pos.height())
syeMask:NSBorderlessWindowMask
bking:NSBackingStoreBuffered
der:NO]);
[self param:function( //
parameter)]

After:
popup_wdow_.reset([[RenderWidgetPopupWindow alloc]
iniithContentRect:NSMakRet(origin_global.x, origin_global.y, pos.width(),
pos.height())
syeMask:NSBorderlessWindowMask
bking:NSBackingStoreBuffered
der:NO]);
[self param:function( //
parameter)]

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194267 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
072ac6cfde19fb395d434b2bbcb66e210607cf1e 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Properly indent ObjC calls wrapped before first selector

Before:
[self // break
a:a
aa:aa
aaaaa:aaa];

After:
[self // break
a:a
aa:aa
aaaaa:aaa];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194241 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1a896a5a72d9af0259afe636535254c95dc6b355 08-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Make breaking before ternary operators configurable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194229 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fa8e7d344fc6ac9bf464419cc9cc2743b5036047 08-Nov-2013 Manuel Klimek <klimek@google.com> Adds the ability to inject a DiagnosticConsumer into ClangTools.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194226 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
51fcdf84a794a01601c7c78889efa21fbfc1db08 07-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Introduce MatchFinder::matchAST.

Differential Revision: http://llvm-reviews.chandlerc.com/D2115

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194223 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
d2bd58907f77e1c1b68a6fa8fc72e1c5b057a5b1 07-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Re-introduce MatchFinder::addDynamicMatcher.

Differential Revision: http://llvm-reviews.chandlerc.com/D2114

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194222 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
f9504aa0c3fc7169d137b32d311f6c8102471cb1 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve binary operator detection in macros.

Before:
#define M(NAME) assert(!Context.Verifying &&#NAME);

After:
#define M(NAME) assert(!Context.Verifying && #NAME);

This fixes llvm.org/PR16156.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194216 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
966e6d3a174856ff3fe3d6cfe294ebae832f6c09 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve ObjC variadic and binary expression parameters.

Before:
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];

After:
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa |
aaaaaaaaaaaaaaa | aaaaaaaaaaaaaaa];
[self aaaaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];

This addresses llvm.org/PR15349 and llvm.org/PR16185.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194214 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dbfb5f37f4d003ae6935b87a103b7827d5069690 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of constructor initializers.

Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa,
aaaa)) {}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaa(aaaa, aaaa)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194210 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
59875ac81b97de87ac6c4c7cb256ab71b75114f2 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Remove old hack that mainly made incorrect tests pass.

As a side-effect, constructors definitions will correctly be recognized
and formatted as function declarations. Tests will be added in a
follow-up patch actually using the correct recognition.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194209 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
16a8b0e7c53ce57fab033ad59f45c619564ff1ef 07-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case for brace alignment.

Before:
Constructor::Constructor()
: some_value{ //
aaaaaaa //
} {}

After:
Constructor::Constructor()
: some_value{ //
aaaaaaa //
} {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194204 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ca94634d8b243a1559a7f33135d89c3b4658c5f0 07-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Disable a tooling test on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194178 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
8051db16aa9513333062ab3145f038429f66780f 06-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Introduce ClangTool::buildASTs, and buildASTFromCode.

These allow clients to retrieve persistent AST objects (ASTUnits) which
can be used in an ad-hoc manner after parsing.

To accommodate this change, the code for processing a CompilerInvocation
using a FrontendAction has been factored out to FrontendActionFactory, and
a new base class, ToolAction, has been introduced, allowing the tool to do
arbitrary things with each CompilerInvocation. This change was necessary
because ASTUnit does not use the FrontendAction interface directly.

This change also causes the FileManager in ClangTool to use shared ownership.
This will become necessary because ASTUnit takes shared ownership of
FileManager (ClangTool's FileManager is currently unused by ASTUnit; this
is a FIXME). As shown in the tests, any client of ToolInvocation will
need to be modified to use shared ownership for FileManager.

Differential Revision: http://llvm-reviews.chandlerc.com/D2097

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194164 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
00841f5d6273d9088cfe308bacf6f5a80470c829 06-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Introduce DynTypedNode::print, dump and getSourceRange.

These functions can generally be applied to multiple kinds of AST node,
so it makes sense to add them to DynTypedNode.

Differential Revision: http://llvm-reviews.chandlerc.com/D2096

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194113 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTTypeTraitsTest.cpp
ST/MatchVerifier.h
3f0e0402d8cd40b428f975f1a3607dbbd94d2ca6 06-Nov-2013 Peter Collingbourne <peter@pcc.me.uk> Introduce BoundNodes::getMap.

The purpose of this function is to allow clients of the dynamic AST matcher
to enumerate each binding.

Differential Revision: http://llvm-reviews.chandlerc.com/D2095

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194112 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
2a80ad6fe7aa506b1df2bb638bc367d9e760f707 05-Nov-2013 Daniel Jasper <djasper@google.com> clang-format: Allow line merging and partial formatting of nested blocks

Before, clang-format would always format entire nested blocks, which
can be unwanted e.g. for long DEBUG({...}) statements. Also
clang-format would not allow to merge lines in nested blocks (e.g. to
put "if (a) return;" on one line in Google style).

This is the first step of several refactorings mostly focussing on the
additional functionality (by reusing the "format many lines" code to
format the children of a nested block). The next steps are:
* Pull out the line merging into its own class.
* Seperate the formatting of many lines from the formatting of a single
line (and the analysis of the solution space).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194090 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dc837b1722d8e071d9ec0434aea487dbdfd57853 30-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix indenting corner case with comment and else.

Before:
if (a) {
f();
}
// or else ..
else {
g();
}

After:
if (a) {
f();
}
// or else ..
else {
g();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193684 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8437957c9da906c24d4e385869c05d8e601c664d 30-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix whitespaces in include directives.

Before (clang-format wouldn't change):
#include "a.h"
#include<a>

After:
#include "a.h"
#include <a>

This fixes llvm.org/PR16151.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193683 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
74b7363bcfc502dec34092af434da787cf9d5b9f 30-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: fix for \r\r\n produced in multiline block comments

Patch by Christopher Olsen. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193678 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d8ee5c1c8709c5fc060a48b598112f6eadb35d96 29-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Option to control spacing in template argument lists.

Same as SpacesInParentheses, this option allows adding a space inside
the '<' and '>' of a template parameter list.

Patch by Christopher Olsen.

This fixes llvm.org/PR17301.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193614 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b7488d77414b000ce2506b520a6b29f845fb3950 29-Oct-2013 Samuel Benzaquen <sbenza@google.com> Resubmit "Refactor DynTypedMatcher into a value type class, just like Matcher<T>."

Summary: This resubmits r193100, plus a fix for a breakage with MSVC.

Reviewers: klimek, rnk

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D2005

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193613 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
52af94453e30d2e9d0f4b6a208c8d4c3ff7c85a9 29-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix overloaded operator for global-scoped conversions.

Before:
operator::A();

After:
operator ::A();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193605 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8f54d881723ca7058807eee871913c812618bfda 26-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix ObjC method exprs with variadic parameters.

Before:
_versionLabel.text = [
NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]
];

After:
_versionLabel.text =
[NSString stringWithFormat:NSLocalizedString(@"version: %@", @"Label"),
[NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]];

This fixed llvm.org/PR17695.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193475 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
47066e46b9ce4f830ead3c7b9a4cb5bf0ac2c857 25-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Adapt line break penalties for LLVM style.

Specifically make clang-format less eager to break after the opening
parenthesis of a function call.

Before:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Apparently that is preferable. This penalties are adapted
conservatively, we might have to increase them a little bit further.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193410 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
852bce4ba3c59669a80d4755f07782a3c28c606b 24-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Properly reset nested AnnotatedLine structure.

This fixes llvm.org/PR17682.

Without this patch, the following code leads to invalid reads/writes:
DEBUG({
return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;
});
#if a
#else
#endif

Because of the #if-#else structure, the code is formatted and annotated
twice and becauce of the nested block, the annotated lines form a
hierarchical structure. This structure was not properly reset between
runs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193352 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
74317e4d3a6e662412cdd971df57da326229fedb 24-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Be more conservative about column layout formatting.

Specifically, if a braced list has at least one nested braced list,
format it either all on one line or in one column (i.e. one item per
line).

This seems in general to be an improvement as the structure of nested
braced lists can make a tightly packed outer braced list hard to read.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193345 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3c6aea7ac63265c769b5fe09e213ab1c4cee111e 24-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Cleanup array initializer and dict initializer formatting.

Significant changes:
- Also recognize these literals with missing "@" for robustness.
- Reorganize tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193325 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ee0cd37fe4a9f4e2ee73ae34cf93c410cb299a82 24-Oct-2013 Manuel Klimek <klimek@google.com> Use the same SourceManager for ModuleMaps and compilations.

This allows using virtual file mappings on the original SourceManager to
map in virtual module.map files. Without this patch, the ModuleMap
search will find a module.map file (as the FileEntry exists in the
FileManager), but will be unable to get the content from the
SourceManager (as ModuleMap previously created its own SourceManager).

Two problems needed to be fixed which this patch exposed:

1. Storing the inferred module map
When writing out a module, the ASTWriter stores the names of the files
in the main source manager; when loading the AST again, the ASTReader
errs out if such a file is found missing, unless it is overridden.
Previously CompilerInstance's compileModule method would store the
inferred module map to a temporary file; the problem with this approach
is that now that the module map is handled by the main source manager,
the ASTWriter stores the name of the temporary module map as source to
the compilation; later, when the module is loaded, the temporary file
has already been deleted, which leads to a compilation error. This patch
changes the inferred module map to instead inject a virtual file into
the source manager. This both saves some disk IO, and works with how the
ASTWriter/ASTReader handle overridden source files.

2. Changing test input in test/Modules/Inputs/*
Now that the module map file is handled by the main source manager, the
VerifyDiagnosticConsumer will not ignore diagnostics created while
parsing the module map file. The module test test/Modules/renamed.m uses
-I test/Modules/Inputs and triggers recursive loading of all module maps
in test/Modules/Inputs, some of which had conflicting names, thus
leading errors while parsing the module maps. Those diagnostics already
occur on trunk, but before this patch they would not break the test, as
they were ignored by the VerifyDiagnosticConsumer. This patch thus
changes the module maps that have been recently introduced which broke
the invariant of compatible modules maps in test/Modules/Inputs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193314 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
ooling/ToolingTest.cpp
c96894305223479789b990522b2877e766979f17 22-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix ObjC literal indentation in Google style.

Style guide demands a two-space indent.

Before:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];

After:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193168 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a07aa665a12ab23bef7aa4aedfe113dd8b13da57 22-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of ObjC array literals.

Before:
NSArray *arguments =
@[ kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets", @"--productid", @"com.google.Chrome" ];
After:
NSArray *arguments = @[
kind == kUserTicket ? @"--user-store" : @"--system-store",
@"--print-tickets",
@"--productid",
@"com.google.Chrome"
];

This fixes llvm.org/PR15231.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193167 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
45206cac6339a675348a5675b5744148d3aba2f4 22-Oct-2013 Manuel Klimek <klimek@google.com> Remove incorrect assert.

If we run into the second preprocessor branch chain, the first branch
chain might have already set the maximum branch count on that level to
something > 0.

Fixes PR17645.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193153 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c30bf45115860b8de8628295f0d9cd86998841de 22-Oct-2013 Reid Kleckner <reid@kleckner.net> Revert "Refactor DynTypedMatcher into a value type class, just like Matcher<T>."

This reverts commit r193100.

It was failing to compile with MSVC 2012 while instantiating
llvm::Optional<DynTypedMatcher>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193123 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
341b5df7f859e640c2ea2f35c0fff553ec55ada4 21-Oct-2013 Samuel Benzaquen <sbenza@google.com> Refactor DynTypedMatcher into a value type class, just like Matcher<T>.

Summary:
Refactor DynTypedMatcher into a value type class, just like Matcher<T>.
This simplifies its usage and removes the virtual hierarchy from Matcher<T>.
It also enables planned changes to replace MatcherInteface<T>.
Too many instantiaions of this class hierarchy has been causing Registry.cpp.o to bloat in size and number of symbols.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1661

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193100 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
d186f0b4c15d4c63e0ae7fbe6ca3207871ba2eb9 21-Oct-2013 Manuel Klimek <klimek@google.com> Fixes PR17617: Crash on joining short if statements.

Now that we iterate on the formatting multiple times when we
have chains of preprocessor branches, we need to correctly reset
the token's previous and next pointer for the first / last token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193071 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
363193b1bd4d9e0f07d361113157b9d4f229f212 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Better understand Lambda poarameters.

Before:
auto PointerBinding = [](const char * S) {};

After:
auto PointerBinding = [](const char *S) {};

This fixes llvm.org/PR17618.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193054 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
15eef85d4f918834ab83cfb941663463b573d6bf 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix formatting of nested blocks after comment.

Before:
DEBUG({ // Comment that used to confuse clang-format.
fdafas();
});
Before:
DEBUG({ // Comments are now fine.
fdafas();
});

This fixed llvm.org/PR17619.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193051 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b3c887dcb70220eced72935725cd94d7e8325912 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Support case ranges.

Before (note the missing space before "..." which can lead to compile
errors):
switch (x) {
case 'A'... 'Z':
case 1... 5:
break;
}

After:
switch (x) {
case 'A' ... 'Z':
case 1 ... 5:
break;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193050 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a53bbae476f8f20d18250effb4cc3f110c9b8030 20-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of ObjC dict literals.

Before:
NSDictionary *d = @{ @"nam" : NSUserNam(), @"dte" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};

After:
NSDictionary *d = @{
@"nam" : NSUserNam(),
@"dte" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193049 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
19b60a524c53ada17a31b5c9a96c7885ca48c825 18-Oct-2013 Ariel J. Bernal <ariel.j.bernal@intel.com> Reverted r192992 broke windows and freebsd builds.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192997 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
044d01f6844536aa548c3e6611c377fe28a2082f 18-Oct-2013 Ariel J. Bernal <ariel.j.bernal@intel.com> This patch fixes replacements that are not applied when relative paths are
specified.

In particular it makes sure that relative paths for non-virtual files aren't
made absolute.
Added unittest.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192992 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
0baf33b73e2bd6657ee202e2016daf010b8b58b9 18-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Be more aggressive on incorrect code.

Before, clang-format would not adjust leading indents if it found a
structural error (e.g. unmatched {}). It seems, however, that
clang-format has gotten good enough at parsing the code structure that
this hurts in almost all cases. Commonly, while writing code, it is
very useful to be able to correclty indent incomplete if statements or
for loops.

In case this leads to errors that we don't anticipate, we need to find
out and fix those.

This fixed llvm.org/PR17594.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192988 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
49c77b2e702b02a0fbac7b817ccb73e7c128f9d9 18-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Don't force linebreak between return and multiline string.

This looks ugly and leads to llvm.org/PR17590.

Before (with AlwaysBreakBeforeMultilineStrings):
return
"aaaa"
"bbbb";

After:
return "aaaa"
"bbbb";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192984 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
53eb05ac6a00b95baf5680d9378ae8819dd09471 18-Oct-2013 Daniel Jasper <djasper@google.com> Make clang-format slightly more willing to break before trailing annotations.

Specifically, prefer breaking before trailing annotations over breaking
before the first parameter.

Before:
void ffffffffffffffffffffffff(
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;

After:
void ffffffffffffffffffffffff(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192983 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9b3cb44cd2052aa7236c38b0ccb291221aab08f9 18-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of templated builder-type calls.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa().has<
bbbbbbbbbbbbbbbbbbbbb>();

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaa()
.aaaaaaaaaaaaaaaaaaaaaaaaaa()
.has<bbbbbbbbbbbbbbbbbbbbb>();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192981 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c2827ec708b1611f2b0717bebc423b17a857631e 18-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Make continuation indent width configurable.

Patch by Kim Gräsman. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192964 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
74ecbd5babae58907e6338a5f79ec4eb4401c0dc 14-Oct-2013 Alexey Samsonov <samsonov@google.com> Fix use-after-free in PPCallbacksTest detected by ASan bootstrap bot

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192572 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PPCallbacksTest.cpp
f0fc89c358cdd0717c0e12eb4a90e4a6ce956e98 14-Oct-2013 Alexander Kornienko <alexfh@google.com> Keep track of indentation levels in static initializers for correct indentation with tabs.

Summary:
Store IndentationLevel in ParentState and use it instead of the
Line::Level when indening.
Also fixed incorrect indentation level calculation in formatFirstToken.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1797

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192563 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aabfb2712e180bb11e5dfc4f2a273890a6c5da66 13-Oct-2013 Manuel Klimek <klimek@google.com> Automatically munch semicolons after blocks.

While it is mostly a user error to have the extra semicolon,
formatting it graciously will correctly format in the cases
where we do not fully understand the code (macros).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192543 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ac4d0181928e3e22fa3929ca1b24ae7f14fb7628 12-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix assertion on unterminated #ifs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192535 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a0950e83cae5df77c00d02d7f77a166979cd2b8b 12-Oct-2013 Pekka Jaaskelainen <pekka.jaaskelainen@tut.fi> Callback support for OpenCL extension pragmas.

Patch from Rami Ylimäki and Mikael Lepistö!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192531 91177308-0d34-0410-b5e6-96231b3b80d8
ex/CMakeLists.txt
ex/Makefile
ex/PPCallbacksTest.cpp
78a4e619e775b0dbaa10c9feaea0adf1d3dfe507 12-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: No space in "<::" in C++11 mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192524 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b18c258390f794d8803ef5ebbb56fb77bfea7ba4 11-Oct-2013 Alexander Kornienko <alexfh@google.com> Don't break string literals inside preprocessor directives.

Summary:
This way we avoid breaking code which uses unknown preprocessor
directives with long string literals. The specific use case in
http://llvm.org/PR17035 isn't very common, but it seems to be a good idea to
avoid this kind of problem anyway.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1813

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192507 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ae76f7f850a9101a20191b10241ca72c23dc40dd 11-Oct-2013 Manuel Klimek <klimek@google.com> Support formatting of preprocessor branches.

We now correctly format:
void SomeFunction(int param1,
#ifdef X
NoTemplate param2,
#else
template <
#ifdef A
MyType<Some> >
#else
Type1, Type2>
#endif
param2,
#endif
param3) {
f();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192503 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1d82b1a33bcfe85f4834fb6920517ed07e9355d3 11-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Don't remove 'unknown' tokens.

In certain macros or incorrect string literals, the token stream can
contain 'unknown' tokens, e.g. a single backslash or a set of empty
ticks. clang-format simply treated them as whitespace and removed them
prior to this patch.

This fixes llvm.org/PR17215

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192490 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
01fe9f9f320dd4342664376f24eb1a0d004d03c8 10-Oct-2013 Alexander Kornienko <alexfh@google.com> Correctly detect colon in bit fields. Fixes PR17333.

Summary: Colon was incorrectly detected as a start of inheritance list. Fixed.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1884

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192349 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d4099c3348589e845f9f4666fb0b8ef9b7a4a796 09-Oct-2013 Ariel J. Bernal <ariel.j.bernal@intel.com> Revert commit r192299 until find a way to account for simlinks in OS X.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192313 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
b71aa7af7f4f9140c7bbcccca30aeecc671d767f 09-Oct-2013 Ariel J. Bernal <ariel.j.bernal@intel.com> This patch fixes replacements that are not applied when relative paths are
specified.

In particular it makes sure that relative paths for non-virtual files aren't
made absolute.
Added unittest test.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192299 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
6e7f1934f489b48a53b8c9af314921c0e55ee5b5 09-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Fix template declaration line breaking with comment.

Before, clang-format would always insert a linebreak before the comment
in code like:
template <typename T> // T can be A, B or C.
struct S {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192297 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cea014bd8d280070caeb27e4e6e33e5723b4226f 08-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve indentation when deriving from templated classes.

Before:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa<
aaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa> {};

After:
struct aaaaaaaaaaaaa : public aaaaaaaaaaaaaaaaaaa< //
aaaaaaaaaaaaaaaa> {};
struct aaaaaaaaaaaaaaaaaaaa
: public aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa> {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192187 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
19ccb1227f5dc338d4b2d9dbbaeaa973c293f8d0 08-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Improve constructor initializer linewrapping.

Specifically make ConstructorInitializerAllOnOneLineOrOnePerLine work
nicely with BreakConstructorInitializersBeforeComma.

This fixes llvm.org/PR17395.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192168 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3d712898fcabf5747db25dac497747572d506c7a 07-Oct-2013 Manuel Klimek <klimek@google.com> Fix incorrect detection of class definitions with alignas specification.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192094 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
63cfb89cf75300b62f3aa1debaa44a4a1ce83b45 06-Oct-2013 Daniel Jasper <djasper@google.com> clang-format: Remove empty lines after visibility modifiers.

Formatting:
class C {
public:

f();
};

Now leads to:
class C {
public:
f();
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192062 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f78bf4a0132a3ea366ba3baadd9d6af26c617d11 30-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve alignment after 'return'.

Previously, comments, could totally confuse it.

Before:
return
// true if code is one of a or b.
code == a ||
code == b;

After:
return
// true if code is one of a or b.
code == a || code == b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191654 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
20376989402fb187c0bc48209f46560b9e402ea2 29-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix assertion on incomplete string literals.

Before, this could would lead to an assert:
llvm::errs() << "
<< a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191639 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6967e786df73e9bdd3f1413a37f7266fae7c482e 27-Sep-2013 Alexander Kornienko <alexfh@google.com> Added a comment and another test for the UT_ForIndentation option

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191530 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3d9ffcf3aa0ed84fa297e3c461bb84e48221aa2d 27-Sep-2013 Alexander Kornienko <alexfh@google.com> Implemented tab usage only for indentation (http://llvm.org/PR17363)

Summary:
Changed UseTab to be a enum with three options: Never, Always,
ForIndentation (true/false are still supported when reading .clang-format).
IndentLevel should currently be propagated correctly for all tokens, except for
block comments. Please take a look at the general idea before I start dealing
with block comments.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1770

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191527 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
acf8e90b22cfea07ba2edeaa5101160eda8dc82c 27-Sep-2013 Alexander Kornienko <alexfh@google.com> Correctly indent with tabs when whitespace starts from the column not divisible by TabWidth.

Summary:
The width of the first inserted tab character depends on the initial
column, so we need to handle the first tab in a special manner.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1763

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191497 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6b3ff8c4caaa6782289a780e096fe56ad6434bb7 27-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of functions with multiple trailing tokens.

Before:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override
final;

After:
void SomeFunction(aaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa) override final;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191494 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
48c099f45400e37ec1cde7de5eaee5cce65dbd42 27-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix formatting bug with comment in weird place.

Before:
template <typename T>
// T should be one of {A, B}.
void f() {}

After:
template <typename T>
// T should be one of {A, B}.
void f() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191492 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9b4de85e2f47a01974f451d21fed0276ff912e32 25-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Option to removing the space before assignment operators.

Patch contributed by Aaron Wishnick. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191375 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
65da8e952da32730202356290bb889c8839bbef5 21-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Improve address-of-operator detection

Before:
size = sizeof * a;

After:
size = sizeof *a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191139 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ebaa1719fdd180e6dd9b4e6471e83500471a2f16 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Don't accidentally move tokens into preprocessor directive.

This fixes llvm.org/PR17265.

Before:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif {
}

After:
Foo::Foo()
#ifdef BAR
: baz(0)
#endif
{
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190861 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
42ff263c42f0f181e76fcb8c8ebb129e8070d09a 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Add comment to tests explaining their grouping.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190858 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e63a48a21cb3416edc6bc75d4d24f3bcf23532d4 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix line breaking bug after empty ifs.

Before:
if () {
}
else {
}

After:
if () {
} else {
}

This fixed llvm.org/PR17262.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190855 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
26356ccf00f813cf358d420b55939fc737eb2cfa 17-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Don't split a >>-operator.

Before (with column limit 60):
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
> aaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);

(Not sure how that could have stayed in that long without being
detected..)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190854 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2c2f729d10cb10324bf2e7871867f7bbc19ad358 16-Sep-2013 Alexander Kornienko <alexfh@google.com> When in pre-c++11 mode, treat _T("xxx") as a single string literal, repeat the _T() part around each fragment. This addresses http://llvm.org/PR17122

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek, rsmith

Differential Revision: http://llvm-reviews.chandlerc.com/D1640

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190804 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d3d9e0f4a107e97b493e1d4c7c5b5dc15e7e137a 14-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in style option AlwaysBreakTemplateDeclarations.

Before:
template <template <typename>
class Fooooooo, template <typename>
class Baaaaaaar>
struct C {};

After:
template <template <typename> class Fooooooo,
template <typename> class Baaaaaaar>
struct C {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190747 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ac885cd60267afbe67c9ed61515be3816032bba2 13-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Detect braced lists in subscript expressions.

Before (even with Style.Cpp11BracedListStyle):
f(MyMap[{ composite, key }]);

After:
f(MyMap[{composite, key}]);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190678 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5798120bc015360951d13a06e17501b909ecd21d 13-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix incorrect enum parsing / layouting.

Before:
enum {
Bar = Foo < int,
int > ::value
};

After:
enum {
Bar = Foo<int, int>::value
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190674 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0bb3ca348517516a92579526b7f878279f33f32e 12-Sep-2013 Michael Han <fragmentshaders@gmail.com> Add a test case to test RAV visits parameters of implicit copy constructor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190632 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
7e27400c90e9e295bcf5857eebf2d60c4b32106e 11-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in pointer detection

Before:
for (int i = 0; i* 2 < z; i *= 2) {}
After:
for (int i = 0; i * 2 < z; i *= 2) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190546 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4b6730d40e7c603bd0e223d3fa8b56a0c88a324a 11-Sep-2013 Michael Han <fragmentshaders@gmail.com> Teach RAV to visit parameter variable declarations of implicit functions. Fixes PR16182.

Normally RAV visits parameter variable declarations of a function by traversing the TypeLoc of
the parameter declarations. However, for implicit functions, their parameters don't have any
TypeLoc, because they are implicit.

So for implicit functions, we visit their parameter variable declarations by traversing them through
the function declaration, and visit them accordingly.

Reviewed by Richard Smith and Manuel Klimek.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190528 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
ooling/RecursiveASTVisitorTest.cpp
ooling/TestVisitor.h
73d845cbe26df2fb188e30853efb8ce4b0556afe 11-Sep-2013 Alexander Kornienko <alexfh@google.com> Support for CR LF newlines.

Summary:
reformat() tries to determine the newline style used in the input
(either LF or CR LF), and uses it for the output. Maybe not every single case is
supported, but at least the bug described in http://llvm.org/PR17182 should be
resolved.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1643

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190519 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f365bb2896bf9ea7813cb608186d2d6017d658a3 11-Sep-2013 Rui Ueyama <ruiu@google.com> Do not quote YAML plain string myself. Let YAMLIO do that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190486 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ReplacementsYamlTest.cpp
daa07e9ee76d438efa3c7e2c54b4d3d3ed19ea27 10-Sep-2013 Alexander Kornienko <alexfh@google.com> Don't divide L and #x in macro definitions. Fixes http://llvm.org/PR17144

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1639

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190408 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6f6154c5f5976e3e57f34f6a755bdfa95b7ff745 10-Sep-2013 Alexander Kornienko <alexfh@google.com> Correctly calculate OriginalColumn after multi-line tokens.

Summary: This also unifies the handling of escaped newlines for all tokens.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1638

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190405 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
db8afe424991b34884afb13ecf97ac458e41da9e 10-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Understand function type typedefs with typeof.

Before:
typedef typeof(int(int, int)) * MyFunc;
After:
typedef typeof(int(int, int)) *MyFunc;

This fixes llvm.org/PR17178.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190401 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
83a7dcdf5fce1bdf74ce985419d77a41a51abfa2 10-Sep-2013 Alexander Kornienko <alexfh@google.com> Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.

Summary:
This fixes various issues with mixed tabs and spaces handling, e.g.
when realigning block comments.

Reviewers: klimek, djasper

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1608

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190395 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
14e25c0477bf9f51e980fdc23b7f0bff800f3ae7 08-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Keep empty lines and format 1-line nested blocks.

Let clang-format consistently keep up to one empty line (configured via
FormatStyle::MaxEmptyLinesToKeep) in nested blocks, e.g. lambdas. Also,
actually format single statements in nested blocks.

Before:
DEBUG({ int i; });
DEBUG({
int i;
// an empty line here would just be removed.
int j;
});

After:
DEBUG({ int i; });
DEBUG({
int i;

int j;
});

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190278 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1245a54ca6e9c5b14196461dc3f84b24ea6594b1 07-Sep-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fix missing source location in CXXTemporaryObjectExpr nodes.
For clarity, renamed (get/set)ParenRange as (get/set)ParenOrBraceRange
in CXXConstructExpr nodes.
Added testcase.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190239 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
00e0f4315064734255171f013b534c6e32086d7a 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix regression introduced by r190038.

Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190209 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e27dc5d8ab967912b9a3d792ad32cad63981a974 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Format typed enums with nested names.

The explicit type specified for an enum can actually have a nested name
specifier.

This fixes llvm.org/PR17125.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190208 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
520cca87e38185872212849562951906be5068e9 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Don't confuse operator[] with lambdas.

Before:
double &operator[](int i) { return 0; } int i;

After:
double &operator[](int i) { return 0; }
int i;

This fixes llvm.org/PR17134.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190207 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
51bb5d967d445613b9f08f6705491966f8616a2a 06-Sep-2013 Alexander Kornienko <alexfh@google.com> Don't remove trailing escaped newline from line comments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190175 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2f0a020d29286805e48b74b127fbf153af2c4ce7 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix regression introduced by r189353.

Before:
FirstToken->WhitespaceRange.getBegin()
.getLocWithOffset(First->LastNewlineOffset);

After:
FirstToken->WhitespaceRange.getBegin().getLocWithOffset(
First->LastNewlineOffset);

Re-add logic to prevent breaking after an empty set of parentheses.
Basically it seems that calling a function without parameters is more
like navigating along the same object than it is a separate step of a
builder-type call.

We might need to extends this in future to allow "short" parameters that
e.g. are an index accessing a specific element.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190126 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
db4813a3997fcf3864d1190f8021ef68e42cc057 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix regression introduced by r189337.

Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) == 5) ...

After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
== 5) ...

Also precompute startsBinaryExpression() to improve performance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190124 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b77d741691a2775b5c31e29f021203cc659c26df 06-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix comment formatting bugs in nested blocks.

This fixes two issues:
1) The indent of a line comment was not adapted to the subsequent
statement as it would be outside of a nested block.
2) A missing DryRun flag caused actualy breaks to be inserted in
overly long comments while trying to come up with the best line
breaking decisions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190123 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e3efec20260ea7a0071e2ae6eedf3c2865e476d3 05-Sep-2013 James Dennett <jdennett@google.com> Mark lambda closure classes as being implicitly-generated.

Summary: Closure classes for C++ lambdas are always compiler-generated. This one-line change calls setImplicit(true) on them at creation time, such that a default RecursiveASTVisitor (or any for which shouldVisitImplicitCode returns false) will skip them.

Reviewers: rsmith, dblaikie

Reviewed By: dblaikie

CC: klimek, revane, cfe-commits, jordan_rose

Differential Revision: http://llvm-reviews.chandlerc.com/D1593

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190073 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
e11e45f624bf848315cf7b1862b69baf76cd5a38 05-Sep-2013 Manuel Klimek <klimek@google.com> Fixes PR 17106 (explicitly typed enums are formatted differently).

Before:
enum X : int { A, B, C };

After:
enum X : int {
A,
B,
C
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190054 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0b62cc30c9aa462184de0435dc083d944a41d67f 05-Sep-2013 Alexander Kornienko <alexfh@google.com> Handle zero-width and double-width characters in string literals and comments.

Summary:
Count column width instead of the number of code points. This also
includes correct handling of tabs inside string literals and comments (with an
exception of multiline string literals/comments, where tabs are present before
the first escaped newline).

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1601

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190052 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2d65705ed0a72ab57b8a062c44c9caa377f9fd2a 05-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Quickfix for braced init lists detected as lambdas.

Before:
constexpr char hello [] { "hello" };

After:
constexpr char hello[]{ "hello" };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190046 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ac2c974bc64d3767ad5e39451a874c50b3004b3a 05-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix parsing and indenting lambdas.

Before:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}

After:
void f() {
other(x.begin(), x.end(), //
[&](int, int) { return 1; });
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190039 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
567dcf95424d69657f75e4bfd028967ca1f9eb8d 05-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Enable formatting of nested blocks.

Among other things, this enables (better) formatting lambdas and
constructs like:
MACRO({
long_statement();
long_statement_2();
},
{
long_statement();
long_statement_2();
},
{ short_statement(); }, "");

This fixes llvm.org/PR15381.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190038 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9321e8700275847458de753933689e30a3412fe2 04-Sep-2013 Alexander Kornienko <alexfh@google.com> Handle 'Cpp03' and 'Cpp11' strings in LanguageStandard serialization for
consistency of serialized form with the actual enum member names without
a prefix.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189936 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
753a5114f9076c545c33cf3ced0d76e27bc0a2d5 04-Sep-2013 Manuel Klimek <klimek@google.com> Implement parsing of blocks (^{ ... }) in the unwrapped line parser.

This patch makes sure we produce the right number of unwrapped lines,
a follow-up patch will make the whitespace formatting consistent.

Before:
void f() {
int i = {[operation setCompletionBlock : ^{ [self onOperationDone];
}]
}
;
}

After:
void f() {
int i = {[operation setCompletionBlock : ^{
[self onOperationDone];
}] };
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189932 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9e512bc935318be794bad8ff1bcd14222b6006fc 04-Sep-2013 Manuel Klimek <klimek@google.com> More lambda formatting tests; update test comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189928 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
31e44f7a5d50ab8f7f623a7d2e18d5d877ef400d 04-Sep-2013 Manuel Klimek <klimek@google.com> Fix layout of lambda captures.

Before:
int c = [ &, &a, a]{
[ =, c, &d]{
return b++;
}();
}();

After:
int c = [&, &a, a] {
[=, c, &d] {
return b++;
}();
}();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189924 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b61a8afba4120f5f1f1af4c7d2a6646a65bd8020 03-Sep-2013 Manuel Klimek <klimek@google.com> First step towards correctly formatting lambdas.

Implements parsing of lambdas in the UnwrappedLineParser.
This introduces the correct line breaks; the formatting of
lambda captures are still incorrect, and the braces are also
still formatted as if they were braced init lists instead of
blocks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189818 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
174f60f005167984d00682d1d38a2927b9c04684 02-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix segfault in overloaded operator parsing.

Before, constructs like:
using A::operator+;

caused a segfault. This fixes llvm.org/PR17050.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189749 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
67cf1dbdd2e1e167a34b849386916450649564cb 02-Sep-2013 Daniel Jasper <djasper@google.com> clang-format: Fix case-indentation in macros.

Before:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name

After:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189743 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4e899d9b0b5aa31b0a3704374d245fc345c19fa8 30-Aug-2013 Samuel Benzaquen <sbenza@google.com> Reduce the number of symbols by changing how templates are instantiated per function bound in the registry.

Summary:
Reduce the number of symbols by changing how templates are instantiated per function bound in the registry.
This change reduces the number of sections in Registry.cpp.o by a little over 10%.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1557

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189676 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/VariantValueTest.cpp
ec17226e82979592c16c7815d2368240201d18fe 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Enable formatting of protocol buffer definitions.

Almost by accident, clang-format seems to be able to format protocol
buffer definitions (https://code.google.com/p/protobuf/).

The only change is that a space is required between numeric constants
and opening square brackets (for default values). While this might in
theory be used for array subscripts (int val = 4[MyArray]), I have not
seen this pattern in practice much. If this is wrong, we can make this
smarter in the future.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189663 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4b434cf0c913a853cb5fd5011a631447836563b2 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve recovery from enums with errors.

Before:
namespace n {
enum Type {
One,
Two, // missing };
int i;
} void g() {
}

After:
namespace n {
enum Type {
One,
Two, // missing };
int i;
}
void g() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189662 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
13d2aa5c8fbb62abf8531bc6e1b7aa89c60fba4f 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix incorrect indentation.

Before:
aaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));

After:
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(
dddddddddddddddddddddddddddddd));
aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(
dddddddddddddddddddddddddddddd));

This was overlooked when interducing the new builder-type call
detection in r189337. Also, some minor reorganization of a test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189658 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
290824530199d9d3728edfbaeb5ccedb798d4498 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Don't indent builders relative to "return".

While this looks kind of nice, it wastes horizontal space and does not
seem to be common in the LLVM codebase.

Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);

After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189657 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
eb331832830c51322a225a3de480189c7d6d7503 30-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in builder-type calls.

Before:
aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()->aaaaaaaaaaaaaae(
0)->aaaaaaaaaaaaaaa();

After:
aaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaa()
->aaaaaaaaaaaaaae(0)
->aaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189655 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dcc0c5bb7ce9a731ecbc0b8e8477979cd9e730c0 29-Aug-2013 Alexander Kornienko <alexfh@google.com> Better support for multiline string literals (including C++11 raw string literals).

Summary:
Calculate characters in the first and the last line correctly so that
we only break before the literal when needed.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1544

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189595 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b80aad8d30340cdd47ecb6a5bafe46cf5e47cfe9 29-Aug-2013 Samuel Benzaquen <sbenza@google.com> Fix tests to be more specific.
The environments can inject some declaration in every translation unit,
which can match very generic matchers, thus failing the tests.

Summary:
Fix tests to be more specific.
The environments can inject some declaration in every translation unit,
which can match very generic matchers, thus failing the tests.

Reviewers: aaron.ballman

CC: klimek, cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1541

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189587 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
c41e8198dc1f24a1c6d35046fc4d478546761648 29-Aug-2013 Manuel Klimek <klimek@google.com> Fixes various problems with accounting for tabs in the original code.

We now count the original token's column directly when lexing the
tokens, where we already have all knowledge about where lines start.

Before this patch, formatting:
void f() {
\tg();
\th();
}
would incorrectly count the \t's as 1 character if only the line
containing h() was reformatted, and thus indent h() at offset 1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189585 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a735090449197f1edcdc85a6080eebc0304a31dd 28-Aug-2013 Samuel Benzaquen <sbenza@google.com> Add support for eachOf/allOf/anyOf variadic matchers in the dynamic layer.

Summary:
Add support for eachOf/allOf/anyOf variadic matchers in the dynamic layer.
These function require some late binding behavior for the type conversions, thus changes in VariadicValue's MatcherList.
Second try. This time with a fix for C++11 builds.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1536

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189500 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
f54617858a0df936746b7f521a8ffb032289d02f 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve token breaking behavior.

Two changes:
* Don't add an extra penalty on breaking the same token multiple times.
Generally, we should prefer not to break, but once we break, the
normal line breaking penalties apply.
* Slightly increase the penalty for breaking comments. In general, the
author has put some thought into how to break the comment and we
should not overwrite this unnecessarily.

With a 40-column column limit, formatting
aaaaaa("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa");

Leads to:
Before:
aaaaaa(
"aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa");

After:
aaaaaa("aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaa");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189466 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7143a21706d951ad53b5167a4dcd750f5997d208 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix segfault in 'incomplete' macros.

The code leading to a segfault was:
#pragma omp threadprivate(y)), // long comment leading to a line break

This fixes llvm.org/PR16513.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189460 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c9346c996c9d5de130541c84206c4a4d5bba24e9 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix infinite loop in macro special case.

If escaped newlines are aligned right
(FormatStyle.AlignEscapedNewlinesLeft == false), and a line contained
too many characters to fit into the column limit, this would result in
a (virtually) endless loop creating a negative number of spaces.

Instead, allow the escaped newlines to be pushed past the column limit
in this case.

This fixes llvm.org/PR16515.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189459 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a4dd982805e89a37a080350bf8de9069135c5a60 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Don't insert space in __has_include

Before:
#if __has_include( <strstream>)
#include <strstream>
#endif

After:
#if __has_include(<strstream>)
#include <strstream>
#endif

This fixes llvm.org/PR16516.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189455 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7186ccc86ee5802c33886d6dd4c5386c7e9fd1aa 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in ObjC interface definitions.

In
@implementation ObjcClass
- (void)method;
{
}
@end
the ObjC compiler seems to accept the superfluous comma after "method",
but clang-format used to assert on the subsequent "{".

This fixes llvm.org/PR16604.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189453 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f439dcb4ecb444df538c42b3284c093886fc7ab1 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve braced init list detection:

Before:
std::this_thread::sleep_for(std::chrono::nanoseconds{
std::chrono::seconds { 1 }
} /
5);

After:
std::this_thread::sleep_for(
std::chrono::nanoseconds{ std::chrono::seconds{ 1 } } / 5);

This fixes llvm.org/PR16554.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189451 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c476ea976badd316e3afd0f34afe1f030a710117 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in overloaded operator definitions.

Before:
SomeLoooooooooooooooooooooooooogType operator>
>(const SomeLooooooooooooooooooooooooogType &other);
SomeLoooooooooooooooooooooooooogType // break
operator>>(const SomeLooooooooooooooooooooooooogType &other);

After:
SomeLoooooooooooooooooooooooooogType
operator>>(const SomeLooooooooooooooooooooooooogType &other);
SomeLoooooooooooooooooooooooooogType // break
operator>>(const SomeLooooooooooooooooooooooooogType &other);

This fixes llvm.org/PR16328.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189450 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
081fc17374baf55cc6a6069a9f5a1596fb378ef3 28-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix space in decltype-constexprs.

Before:
static constexpr bool Bar = decltype(bar()) ::value;

After:
static constexpr bool Bar = decltype(bar())::value;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189449 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
99e0df4ab60c5fa4afd2bf63b896fd4f88792127 27-Aug-2013 Samuel Benzaquen <sbenza@google.com> Revert "Add support for eachOf/allOf/anyOf variadic matchers in the dynamic layer."

Summary:
This reverts commit 3b082a3c72324aa3363b5184731740534c6b9a2b.

It breaks the build in c++11 mode.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1533

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189368 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
3b082a3c72324aa3363b5184731740534c6b9a2b 27-Aug-2013 Samuel Benzaquen <sbenza@google.com> Add support for eachOf/allOf/anyOf variadic matchers in the dynamic layer.

Summary:
Add support for eachOf/allOf/anyOf variadic matchers in the dynamic layer.
These function require some late binding behavior for the type conversions, thus changes in VariadicValue's MatcherList.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1531

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189362 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
a778cde0ddf4c47a63786fb1067f25c1fbfcf19d 27-Aug-2013 Edwin Vane <edwin.vane@intel.com> Adding a vector version of clang::tooling::shiftedCodePosition().

During the transition of clang::tooling::Replacements from std::set to
std::vector, functions such as clang::tooling::applyAllReplacements() have been
duplicated to take a std::vector<Replacement>. Applying this same temporary
duplication to clang::tooling::shiftedCodePosition().



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189358 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
d3fef0fe26da19685bdec6a1bd844505f604d593 27-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Format segments of builder-type calls one per line.

This fixes llvm.org/PR14818.

Before:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);

After:
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT)
.StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH)
.Default(ORDER_TEXT);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189353 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d489f8ceb735458b0e1f814e3f952b154f49c025 27-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Revamp builder-type call formatting.

Previously builder-type calls were only correctly recognized in
top-level calls.

This fixes llvm.org/PR16981.
Before:
someobj->Add((new util::filetools::Handler(dir))->OnEvent1(
NewPermanentCallback(this, &HandlerHolderClass::EventHandlerCBA))
->OnEvent2(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBB))
->OnEvent3(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBC))
->OnEvent5(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBD))
->OnEvent6(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBE)));

After:
someobj->Add((new util::filetools::Handler(dir))
->OnEvent1(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBA))
->OnEvent2(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBB))
->OnEvent3(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBC))
->OnEvent5(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBD))
->OnEvent6(NewPermanentCallback(
this, &HandlerHolderClass::EventHandlerCBE)));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189337 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
451f1e0e5040db6a114217e7bd9767bf751d5bd3 27-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in column layout.

Before (with 60 character limit in Google style):
return {
{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa},
{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}};
After:
return {{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa},
{aaaaaaaaaaaaaaaaaaaaaaaaa}, {aaaaaaaaaaaaaaaaa}};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189327 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
332c67703f63fafd26cf88fc31faeb80c1523725 26-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug in column-layout formatting.

Specific arrangements of comments after trailing commas could confuse
the column width calculation, e.g. in:

vector<int> x = { a, b,
/* some */ /* comment */ };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189211 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2b429358a9849e2e48520a03065fa385a02dc115 23-Aug-2013 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: fix a bug where a line with whitespace between two paragraphs
would cause us to concatenate these paragraphs into a single one.

The no-op whitespace churn in test/Index test happened because these tests
don't use the correct approach for testing and are more strict than required
for they are testing.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189126 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
3618e6fae8b734ad94221d941417c12d4bd1e3a8 23-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix indentation relative to unary expressions.

This should be done, only if we are still in the unary expression's
scope.

Before:
bool aaaa = !aaaaaaaa( // break
aaaaaaaaaaa);
*aaaaaa = aaaaaaa( // break
aaaaaaaaaaaaaaaa);

After:
bool aaaa = !aaaaaaaa( // break
aaaaaaaaaaa); // <- (unchanged)
*aaaaaa = aaaaaaa( // break
aaaaaaaaaaaaaaaa); // <- (no longer indented relative to "*")

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189108 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4df1ff96262b8bde75c6801ef42659f352aa2422 23-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case for string splitting ..

.. in conjunction with Style.AlwaysBreakBeforeMultilineStrings. Also,
simplify the implementation by handling newly split strings and already
split strings by the same code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189102 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ed51c02f4c87ddb2d2f45193e4041921ac363f76 23-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Handle trailing commas in column layout of braced list.

Before, this was causing errors.

Also exit early in breakProtrudingToken() (before the expensive call to
SourceManager::getSpellingColumnNumber()). This makes formatting huge
(100k+-item) braced lists possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189094 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e638503d0dba2c02ab5254fe40d4e5385c3bf2a9 22-Aug-2013 Jordan Rose <jordan_rose@apple.com> Fix dependencies now that the ARC migrator depends on the static analyzer.

Thanks for pointing this out, Stephen. I think this is right now -- I
attempted to try all four valid combinations with both the autoconf and
CMake builds.

See also LLVM changes to the configure script.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189027 91177308-0d34-0410-b5e6-96231b3b80d8
akefile
d4a03dbb0bdbd4908375306283cb61813bd8f454 22-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Add column layout formatting for braced lists

With this patch, braced lists (with more than 3 elements are formatted in a
column layout if possible). E.g.:

static const uint16_t CallerSavedRegs64Bit[] = {
X86::RAX, X86::RDX, X86::RCX, X86::RSI, X86::RDI,
X86::R8, X86::R9, X86::R10, X86::R11, 0
};

Required other changes:
- FormatTokens can now have a special role that contains extra data and can do
special formattings. A comma separated list is currently the only
implementation.
- Move penalty calculation entirely into ContinuationIndenter (there was a last
piece still in UnwrappedLineFormatter).

Review: http://llvm-reviews.chandlerc.com/D1457

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189018 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
34f3d05d0ee625dfcac951e2851f212c4c1a8b83 21-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Indent relative to unary operators.

Before:
if (!aaaaaaaaaa( // break
aaaaa)) {
}

After:
if (!aaaaaaaaaa( // break
aaaaa)) {
}

Also cleaned up formatting using clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188891 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5321e94281f4944d05ab5f90208933afc1e7cae8 20-Aug-2013 Edwin Vane <edwin.vane@intel.com> Adding Replacement serialization support

Adding a new data structure for storing the Replacements generated for a single
translation unit. Structure contains a vector of Replacements as well a field
indicating the main source file of the translation unit. An optional 'Context'
field allows for tools to provide any information they want about the context
the Replacements were generated in. This context is printed, for example, when
detecting conflicts during Replacement deduplication.

YAML serialization for this data structure is implemented in this patch. Tests
are included.

Differential Revision: http://llvm-reviews.chandlerc.com/D1422



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188818 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CMakeLists.txt
ooling/ReplacementsYamlTest.cpp
cbeb1c6f337f73fe7d1135b379e45fbda0c4766d 20-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Format enum struct/class like enum.

Patch by Joe Hermaszewski. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188794 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7df56bfcf7186f73c99564cd54216f07a8db7352 20-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Additional options for spaces around parentheses.

This patch adds four new options to control:
- Spaces after control keyworks (if(..) vs if (..))
- Spaces in empty parentheses (f( ) vs f())
- Spaces in c-style casts (( int )1.0 vs (int)1.0)
- Spaces in other parentheses (f(a) vs f( a ))

Patch by Joe Hermaszewski. Thank you for working on this!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188793 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
92495a8032d8624495a0ce769d5a6cdeba2dc8d8 19-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix return type line break decision.

This accidentally introduced by r186077, as function names were not
correctly recognized in templated declarations.

Before:
template <class TemplateIt>
SomeReturnType
SomeFunction(TemplateIt begin, TemplateIt end, TemplateIt* stop) {}

After:
template <class TemplateIt>
SomeReturnType SomeFunction(TemplateIt begin, TemplateIt end,
TemplateIt* stop) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188665 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f758bc7125d59bca12bb6c5f1d3c9025f395710e 13-Aug-2013 Edwin Vane <edwin.vane@intel.com> Have Range::overlapsWith use positive logic

Improved test to catch missing case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188304 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
b58cfd93c49727c1d471ce71901502df824556c7 13-Aug-2013 Edwin Vane <edwin.vane@intel.com> Adding a vector version of tooling::applyAllReplacements

One day soon, tooling::Replacements will be changed from being implemented as
an std::set to being implemented as an std::vector. Until then, some new code
using vectors of Replacements would enjoy having a version of
applyAllReplacements that takes a vector.

Differential Revision: http://llvm-reviews.chandlerc.com/D1380



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188295 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
95f0766c1942c8cdc9f913a083ad2bfc4c0c27c9 13-Aug-2013 Edwin Vane <edwin.vane@intel.com> Fixing a conflict detection bug in tooling::deduplicate

If a Replacment is contained within the conflict range being built, the
conflict range would be erroneously shortened. Now fixed. Tests updated to
catch this case.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188287 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
9d02807c3ea9782442b98201df68294cd7cd7313 13-Aug-2013 Samuel Benzaquen <sbenza@google.com> Refactor "MatcherList" into "VariantMatcher" and abstract the notion of a list of matchers for the polymorphic case.

Summary:
Refactor "MatcherList" into "VariantMatcher" and abstract the notion of a list of matchers for the polymorphic case.
This work is to support future changes needed for eachOf/allOf/anyOf matchers. We will add a new type on VariantMatcher.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1365

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188272 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
6315fec908431be8f11d9e3c29caadc77c748702 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Add option for the offset of constructor initializers.

Some coding styles use a different indent for constructor initializers.

Patch by Klemens Baum. Thank you.
Review: http://llvm-reviews.chandlerc.com/D1360

Post review changes: Changed data type to unsigned as a negative indent
width does not make sense and added test for configuration parsing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188260 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b644dd68d3d7261ceb8823595290439dc65530b1 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve boolean expression formatting in macros.

Before:
#define IF(a, b, c) if (a&&(b == c))

After:
#define IF(a, b, c) if (a && (b == c))

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188256 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b5a151d3eec8993d6b24896bb134bcda2bdf9f16 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Activate WebKit-style tests for MS compilers.

They were accidentally placed in the #if.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188255 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e60084d1e8a62716b80872f10e9828fbbb3cadfc 13-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Slightly adapt line break penalties.

Before:
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaa());
After:
aaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaaa());

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188253 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5d937b3fe7832f8ffa0a258d1b037c64708e97c1 13-Aug-2013 Kaelyn Uhrain <rikka@google.com> Add hooks to ExternalSemaSource for after-the-fact diagnosis of
incomplete types, courtesy of Luke Zarko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188212 91177308-0d34-0410-b5e6-96231b3b80d8
ema/ExternalSemaSourceTest.cpp
4432bf007abb40cdbe2679dd94ec5b11c5795355 12-Aug-2013 Kaelyn Uhrain <rikka@google.com> Forgot to add unittests/Sema/ before committing r188196 :(

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188197 91177308-0d34-0410-b5e6-96231b3b80d8
ema/CMakeLists.txt
ema/ExternalSemaSourceTest.cpp
ema/Makefile
70571f43ab9ae399cd005eaee02f4ca1ecbc3a81 12-Aug-2013 Kaelyn Uhrain <rikka@google.com> Add hooks for typo correction to ExternalSemaSource, courtesy of Luke Zarko.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188196 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
akefile
b349a78c9705a63a352d7b9210cafb2e9d27047c 12-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve stream-formatting.

Before:
CHECK(controller->WriteProto(FLAGS_row_key, FLAGS_proto)) << "\""
<< FLAGS_proto
<< "\"";

After:
SemaRef.Diag(Loc, diag::note_for_range_begin_end)
<< BEF << IsTemplate << Description << E->getType();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188175 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
53352600b7370b1d33b9fde1adda207fd9d7dcd1 12-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Correctly format alias declarations.

Before:
template <class CallbackClass>
using MyCallback = void(CallbackClass::*)(SomeObject * Data);");

After:
template <class CallbackClass>
using MyCallback = void (CallbackClass::*)(SomeObject *Data);");

Also fix three wrong indentations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188172 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2530fd5a235c1e57f8ebef2eae9b365042501009 12-Aug-2013 Manuel Klimek <klimek@google.com> This change fixes the formatting of statements such as catch (E& e).

Previously these were formatting as catch (E & e) because the inner parenthesis
was being marked as an expression.

Patch by Thomas Gibson-Robinson.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188153 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f68af647dda5cca00b49be27d24f62b0a7fff986 10-Aug-2013 James Dennett <jdennett@google.com> Expose LambdaIntroducer::DefaultLoc in the AST's LambdaExpr.

Summary:
Source-centric tools need access to the location of a C++11
lambda expression's capture-default ('&' or '=') when it's present.
It's possible for them to find it by re-lexing and re-implementing
rules that Clang's parser has already applied, but the cost of storing
the SourceLocation and making it available to them is 32 bits per
LambdaExpr (a small delta, proportionally), and the simplification in
client code is significant.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits, klimek, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1192

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188121 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
d5692dbfeb97ed2e7ff11bca26059fa735e1b308 08-Aug-2013 Edwin Vane <edwin.vane@intel.com> Introduce Replacement deduplication and conflict detection function

Summary:
This patch adds tooling::deduplicate() which removes duplicates from and
looks for conflicts in a vector of Replacements.

Differential Revision: http://llvm-reviews.chandlerc.com/D1314



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187979 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
2519d56d558eb40a23ede9bbba154514d0ec7ee2 08-Aug-2013 Arnold Schwaighofer <aschwaighofer@apple.com> Revert r187935 "Support for double width characters."

It broke a public build bot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187957 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
712b7473f9de7cc1979c3754d03e15a2f492349e 08-Aug-2013 Alexander Kornienko <alexfh@google.com> Support for double width characters.

Summary: Only works for UTF-8-encoded files.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1311

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187935 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d3a247cc4e136af6b71dc5968ca6190e6c68f4c5 07-Aug-2013 Manuel Klimek <klimek@google.com> Fixes a couple of bugs with the Allman brace breaking.

In particular, left braces after an enum declaration now occur on their
own line. Further, when short ifs/whiles are allowed these no longer
cause the left brace to be on the same line as the if/while when a
brace is included.

Patch by Thomas Gibson-Robinson.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187901 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1dc6f745eb19c94527503012d798dc9b9b5ba6da 07-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix corner case in OpenMP pragma formatting.

Before:
#pragma omp reduction( | : var)
After:
#pragma omp reduction(| : var)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187892 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
efed68700e6352f50d120b246041054e76b0c6b9 07-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve formatting of builder-type calls.

This removes a formatting choice that was added at one point, but is
not generally liked by users. Specifically, in builder-type calls, do
(easily) break if the object before the ./-> is either a field or a
parameter-less function call. I.e., don't break after "aa.aa.aa" or
"aa.aa.aa()". In general, these sequences in builder-type calls are
seen as a single entity and thus breaking them up is a bad idea.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187865 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e490705e6678a2e830cecacbe8142d9b369d8341 02-Aug-2013 Manuel Klimek <klimek@google.com> Implement Allman style.

Patch by Frank Miller.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187678 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b56da8c0e648d3bfd9bfe82266b9fea6a8df8a00 02-Aug-2013 Manuel Klimek <klimek@google.com> Fix crash when encountering alias templates in isDerivedFrom matches.

- pull out function to drill to the CXXRecordDecl from the type,
to allow recursive resolution
- make the analysis more robust by rather skipping values we don't
understand

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187676 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
75e58bb0bde79d18ed4436769f017b5496745009 02-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Fix string breaking after "<<".

Before, clang-format would not break overly long string literals
following a "<<" with FormatStyle::AlwaysBreakBeforeMultilineStrings
being set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187650 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1eaa99779a254411600d77a715c761d9d84ec8bd 02-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Operator precendence in ObjC method exprs.

Patch (mostly) by Adam Strzelecki. Thanks!

Before:
[self aaaaaa:bbbbbbbbbbbbb
aaaaaaaaaa:bbbbbbbbbbbbbbbbb
aaaaa:bbbbbbbbbbb +
bbbbbbbbbbbb aaaa:bbb];

After:
[self aaaaaa:bbbbbbbbbbbbb
aaaaaaaaaa:bbbbbbbbbbbbbbbbb
aaaaa:bbbbbbbbbbb + bbbbbbbbbbbb
aaaa:bbb];

This fixes llvm.org/PR16150.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187631 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ab3ce592d027e3a10fb21e703cab1507f8d9bb03 02-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Don't break empty 2nd operand of ternary expr.

Before:
some_quite_long_variable_name_ptr
?
: argv[9] ? ptr : argv[8] ? : argv[7] ? ptr : argv[6];
After:
some_quite_long_variable_name_ptr
?: argv[9] ? ptr : argv[8] ?: argv[7] ? ptr : argv[6];

Patch by Adam Strzelecki, thank you!!

This fixed llvm.org/PR16758.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187622 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0fda0f75f053ad9afdb2bb8d4ea72c5e6a49d657 01-Aug-2013 Rafael Espindola <rafael.espindola@gmail.com> Use llvm::sys::fs::UniqueID for windows and unix.

This unifies the unix and windows versions of FileManager::UniqueDirContainer
and FileManager::UniqueFileContainer by using UniqueID.

We cannot just replace "struct stat" with llvm::sys::fs::file_status, since we
want to be able to construct fake ones, and file_status has different members
on unix and windows.

What the patch does is:

* Record only the information that clang is actually using.
* Use llvm::sys::fs::status instead of stat and fstat.
* Use llvm::sys::fs::UniqueID
* Delete the old windows versions of UniqueDirContainer and
UniqueFileContainer since the "unix" one now works on windows too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187619 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
b7000ca629da16164f0073f5a7f9459ddf5ba281 01-Aug-2013 Daniel Jasper <djasper@google.com> Teach clang-format to understand static_asserts better.

Before:
template <bool B, bool C>
class A {
static_assert(B &&C, "Something is wrong");
};

After:
template <bool B, bool C>
class A {
static_assert(B && C, "Something is wrong");
};

(Note the spacing around '&&'). Also change the identifier table to always
understand all C++11 keywords (which seems like the right thing to do).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187589 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aa9e7b18a88d715b63e7b65d1b26a1759decc177 01-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Improve line breaks in @property.

Before:
@property(nonatomic, assign,
readonly) NSString *looooooooooooooooooooooooooooongName;

After:
@property(nonatomic, assign, readonly)
NSString *looooooooooooooooooooooooooooongName;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187577 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
893ea8d0a6420591d966fa0e7135e510b1523b57 01-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Make alignment of trailing comments optional ..

.. in order to support WebKit style properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187549 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
eff18b9b6f1218a6bbe4869989b08867823a4e75 01-Aug-2013 Daniel Jasper <djasper@google.com> clang-format: Add more options to namespace indentation.

With this patch, clang-format can be configured to:
* not indent in namespace at all (former behavior).
* indent in namespace as in other blocks.
* indent only in inner namespaces (as required by WebKit style).

Also fix alignment of access specifiers in WebKit style.

Patch started by Marek Kurdej. Thank you!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187540 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0236dd09c040f2e6124654d620dde94a595c5ab0 31-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve detection of templates.

Before:
template <typename... Types>
typename enable_if < 0<sizeof...(Types)>::type Foo() {}
After:
template <typename... Types>
typename enable_if<0 < sizeof...(Types)>::type Foo() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187458 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
146d57fd5135a134bcdaaf402157c070cde9e4a1 29-Jul-2013 Rafael Espindola <rafael.espindola@gmail.com> Fix handling of "clang c:foo"

On windows, c:foo is a valid file path, but stat fails on just "c:". This
causes a problem for clang since its file manager wants to cache data about
the parent directory.

There are refactorings to be done in here, but this gives clang the correct
behavior and testing first.

Patch by Yunzhong Gao!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187359 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
c5ae717c2b774bfce6bce4bb51072f664b2d54aa 26-Jul-2013 Daniel Jasper <djasper@google.com> Add matcher for float literals.

Patch by Chris Gray! Thanks!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187232 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
e8b10d3d5b90efaf60ad89e96f6500f971ceec41 26-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Add two new style options to support WebKit style.

New options:
* Break before the commas of constructor initializers and align
the commas with the colon.
* Break before binary operators

Additionally, for styles without column limit, don't just accept
linebreaks done by the user, but instead remove 'invalid' (according
to the current style) linebreaks and add 'required' ones.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187210 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e865cc5e183a25983bc79aca2c9bc9a6fb775ab2 25-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Fix switch/case interaction with macros.

Before:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name

switch (OpCode) {
CASE(Add);
CASE(Subtract);
default:
return operations::Unknown;
}

After:
#define OPERATION_CASE(name) \
case OP_name: \
return operations::Operation##name;

switch (OpCode) {
CASE(Add);
CASE(Subtract);
default:
return operations::Unknown;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187118 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6de440e1989ee7932c942dcba85e862c31bf4604 24-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add support for Adaptative matchers on the dynamic registry.

Summary:
Add support for Adaptative matchers on the dynamic registry.
Each adaptative matcher is created with a function template. We instantiate the function N times, one for each possible From type and apply the techniques used on argument overloaded and polymorphic matchers to add them to the registry.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1201

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187044 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
e05dc6d1b5eb12d47c8d3cb5120452ceef720568 24-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Initial (incomplete) support for the WebKit coding style.

This is far from implementing all the rules given by
http://www.webkit.org/coding/coding-style.html

The important new feature is the support for styles that don't have a
column limit. For such styles, clang-format will (at the moment) simply
respect the input's formatting decisions within statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187033 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0e1896a753845deee5206b28cdbde1640abb9cac 22-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add support for overloaded matchers. ie different matcher function signatures with the same name.

Summary:
Add support for overloaded matchers.
This composes with other features, like supporting polymorphic matchers.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1188

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186836 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
2f5a23103f691b1bf7522494fabeaa8f7bd7122b 19-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add support for raw_ostream on the printing methods of Diagnostics.

Summary:
Add printToStream*(llvm::raw_ostream&) methods to Diagnostics, and reimplement everything based on streams instead of concatenating strings.
Also, fix some functions to start with lowercase to match the style guide.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1187

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186715 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
de9ed71c696bee936a21323f61548164de0eda13 19-Jul-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fix source range of implicitly instantiated friend declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186702 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
46fa4c355bd45197dff580b63240494a53b16c1d 19-Jul-2013 Manuel Klimek <klimek@google.com> Adds overlapsWith and contains predicates on tooling::Range.

Patch by Guillaume Papin.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186670 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
06963013d1972f1f7a58875bb40976b60522700b 19-Jul-2013 Manuel Klimek <klimek@google.com> Adds ctorInitializer and forEachConstructorInitializer matchers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186668 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
5e2169f94fca20bbfda317c222b156751a431c13 18-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bad line break with pointers to members.

Before:
void f() {
(a->*
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(aaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
}

After:
void f() {
(a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
}

Also add missing test case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186583 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e0fa4c55a4bc6d2bbe0d9d657287c037158d5357 17-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Add space in corner case.

Before:
SomeType s __attribute__((unused))(InitValue);
After:
SomeType s __attribute__((unused)) (InitValue);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186535 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d4de59d3e54421ef88316d650e35802ba9c572cf 17-Jul-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fixed source range of C++03 access declarations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186522 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
215c57ff4a75388913dc392d03d84ec8c4c3ee1e 17-Jul-2013 Daniel Jasper <djasper@google.com> Improve line breaking before multi-line strings.

The AlwaysBreakBeforeMultilineStrings rule does not really make sense
if it does not a column gain.

Before (in Google style):
f(
"aaaa"
"bbbb");

After:
f("aaaa"
"bbbb");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186515 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
671840a66f63f55705175e51fb44f77a55e0e3b6 17-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add TemplateArgument related matchers to the registry.

Summary:
Continue adding more matchers to the dynamic registry.
This time, we add TemplateArgument matchers.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1166

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186514 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
86e4d744eaa44f7e674e41074913d8ed61f1d433 17-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add CXXCtorInitializer related matchers to the dynamic matcher registry.

Summary: Now that CXXCtorInitializer is already supported in ASTNodeKind, add CXXCtorInitializer matchers to the dynamic matcher registry.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1158

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186508 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
b4b4a52f1c3b768473169bc7cb450d406e1b495c 17-Jul-2013 Alexander Kornienko <alexfh@google.com> Avoid breaking non-trailing block comments.

Motivating example:
// column limit ------------------->
void ffffffffffff(int aaaaaa /* test */);

Formatting before the patch:
void ffffffffffff(int aaaaaa /* test
*/);

Formatting after the patch:
void
ffffffffffff(int aaaaaa /* test */);



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186471 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
10c26b2e974f97c75fc3aaa302ca750f422cbce1 16-Jul-2013 Alexander Kornienko <alexfh@google.com> Don't break line comments with escaped newlines.

Summary:
These can appear when comments contain command lines with quoted line
breaks. As the text (including escaped newlines and '//' from consecutive lines)
is a single line comment, we used to break it even when it didn't exceed column
limit. This is a temporary solution, in the future we may want to support this
case completely - at least adjust leading whitespace when changing indentation
of the first line.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1146

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186456 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
561211d35b5a2825fba6d0c017044f6896b204fd 16-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve handling of unterminated string literals.

Before, clang-format would simply eat these as they were recognized as
whitespace. With this patch, they are mostly left alone.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186454 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b5dc3f4f53981b681a565cdf1d49f18e817541ff 16-Jul-2013 Daniel Jasper <djasper@google.com> Revamp the formatting of C++11 braced init lists.

The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.

This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186433 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e7d3bff31e3ef4fea1e2a5a7cd5441b6b0752e3f 16-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve detection of function types.

This fixes an incorrect detection that led to a formatting error.
Before:
some_var = function (*some_pointer_var)[0];
After:
some_var = function(*some_pointer_var)[0];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186402 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3f84bb341bfb1312842b09db71d76bc3898ba247 15-Jul-2013 Samuel Benzaquen <sbenza@google.com> Add support for type traversal matchers.

Summary:
Fixup the type traversal macros/matchers to specify the supported types.
Make the marshallers a little more generic to support any variadic function.
Update the doc script.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1023

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186340 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
0c368787d9d1f92a3408b71b3f074a06edaa6bde 15-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve c-style cast detection.

Before:
#define x ((int) - 1)
#define p(q) ((int *) & q)
After:
#define x ((int)-1)
#define p(q) ((int *)&q)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186324 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9637dda705e39110bfff66742542a58dd2470ad2 15-Jul-2013 Daniel Jasper <djasper@google.com> Improvement of change r186320.

Fixed a test that by now passed for the wrong reason.

Before:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Also reformatted Format.cpp with the latest changes (1 formatting fix
and 1 layout change of a <<-chain).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186322 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3e12e87f98538c55c1eab79df79e5a00df6de8ec 15-Jul-2013 Daniel Jasper <djasper@google.com> Improve formatting of operator<< chains.

Before:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

After:
llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
<< "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186320 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f475bf83a45435a211edb4e0ef6ac3481ce7b3fe 13-Jul-2013 David Blaikie <dblaikie@gmail.com> Revert "Revert "PR16540: ASTVector::insert(Context, Iter, Element) doesn't compile""

This reverts commit b18b043a5a37f76803d89467e46bcac286c0ecae.

Reapply with fix for the configure+make build (missing include of
ASTContext.h).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186257 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTVectorTest.cpp
ST/CMakeLists.txt
65732a200987cb4b007fbb3015a8bae175ddb832 13-Jul-2013 David Blaikie <dblaikie@gmail.com> Revert "PR16540: ASTVector::insert(Context, Iter, Element) doesn't compile"

This reverts commit r186253.

This is failing to link under Configure+Make on the buildbots for
reasons I don't immediately understand.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186255 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTVectorTest.cpp
ST/CMakeLists.txt
a995630ca94ca2543678b201d90cf6f07d41a8df 13-Jul-2013 David Blaikie <dblaikie@gmail.com> PR16540: ASTVector::insert(Context, Iter, Element) doesn't compile

Fix some uninstantiable code in ASTVector::insert. I've added a
cheap-and-dirty compile test for this, because I don't have the time to
figure out a nice way to get a real ASTContext to implement executable
tests - but we probably should have them for this ADT.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186253 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTVectorTest.cpp
ST/CMakeLists.txt
a0740f5ddf143d59b8e55d2cb6e39ed5059575b4 12-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Improve <<-formatting.

This fixes a regression caused by r186115.

Before:
Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbb) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<< aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186164 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0fde9504af582459c93c43363db2680bcd726126 12-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Fix string literal breaking.

Before this patch, it did not cooperate with
Style::AlwaysBreakBeforeMultilineStrings. Thus, it would turn

aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

into:

aaaaaaaaaaaa(aaaaaaaaaaaaa, "aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

and only a second format step would lead to the desired (with that
option):

aaaaaaaaaaaa(aaaaaaaaaaaaa,
"aaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa "
"aaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaa");

This could even lead to clang-format breaking the string at a different
character and thus leading to a completely different end result.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186154 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
011c35dabb4c8abcb7389d8fbc6316f8f23576ab 12-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Break before/between array subscript expressions.

clang-format used to treat array subscript expressions much like
function call (just replacing () with []). However, this is not really
appropriate especially for expressions with multiple subscripts.

Although it might seem counter-intuitive, the most consistent solution
seems to be to always (if necessary) break before a square bracket,
never after it. Also, multiple subscripts of the same expression should
be aligned if they are on subsequent lines.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa][
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

After:
aaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbb] = c;
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa]
[bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = ccccccccccc;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186153 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
15ec3a871d5ae8a8d4c29ca2681532a9894898b6 11-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Fix bug concerning the alignment of "}".

Before:
int i; // indented 2 space more than clang-format would use.
SomeReturnType // clang-format invoked on this line.
SomeFunctionMakingLBraceEndInColumn80() {
} // This is the indent clang-format would prefer.

After:
int i; // indented 2 space more than clang-format would use.
SomeReturnType // clang-format invoked on this line.
SomeFunctionMakingLBraceEndInColumn80() {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186120 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
20a0f8cff96505abb65233a2eaf3af3cd8536cd2 11-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Break before trailing annotations.

(if they are not function-like).

Before:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaa)
OVERRIDE;

After:
SomeFunction(aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaa) OVERRIDE;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186117 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
faec47bcbadf462b3ac82618dcfca6ae3b8ce5d9 11-Jul-2013 Daniel Jasper <djasper@google.com> clang-format: Avoid line breaks before the first <<.

This puts a slight penalty on the linebreak before the first "<<", so
that clang-format generally tries to keep things on the first line.

User feedback has shown that this is generally desirable.

Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =" << aaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ="
<< aaaaaaaaaaaaaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186115 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3262f4c10520cf11acea4cf590cfbf055924a41e 11-Jul-2013 Daniel Jasper <djasper@google.com> Improve detection of trailing return types.

Trailing return types can only occur in declaration contexts.

Before:
void f() { auto a = b -> c(); }

After:
void f() { auto a = b->c(); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186087 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e1f9a8e27f553dcb359dfd96a3fe3065de7c4dad 11-Jul-2013 Daniel Jasper <djasper@google.com> Fix indentation problem for comments in call chains

Before:
SomeObject
// Calling someFunction on SomeObject
.someFunction();

After:
SomeObject
// Calling someFunction on SomeObject
.someFunction();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186085 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c18cff311118fc6a30929468fc82b2b35cbd7fbf 11-Jul-2013 Daniel Jasper <djasper@google.com> Keep trailing annotations close to their argument.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa GUARDED_BY(
aaaaaaaaaaaa);

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
GUARDED_BY(aaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186077 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
49007d7561212c0ae168702c1af1404c01ef43ff 10-Jul-2013 James Dennett <jdennett@google.com> Add a hook RecursiveASTVisitor::TraverseLambdaBody, to enable visitors to
use/maintain additional state from the LambdaExpr while visiting the body
of a LambdaExpr.

One use for this arises because Clang's AST currently holds lambda bodies
in a form prior to their adjustment to refer to captured copies of local
variables, and so some clients will need access to the lambda's closure
type in order to query how to map VarDecl*s to the FieldDecls of their
by-copy captures. This hook is sufficient for at least one such client;
to do this without such a hook would require the client to re-implement
the whole of TraverseLambdaExpr, which is non-trivial and would likely be
more brittle.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186024 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
c7bd68f9edcbca95e882d0ab18d09371f0bdb82c 10-Jul-2013 Daniel Jasper <djasper@google.com> Add experimental flag for adaptive parameter bin-packing.

This is not activated for any style, might change or go away
completely.

For those that want to play around with it, set
ExperimentalAutoDetectBinPacking to true.

clang-format will then:
Look at whether function calls/declarations/definitions are currently
formatted with one parameter per line (on a case-by-case basis). If so,
clang-format will avoid bin-packing the parameters. If all parameters
are on one line (thus that line is "inconclusive"), clang-format will
make the choice dependent on whether there are other bin-packed
calls/declarations in the same file.

The reason for this change is that bin-packing in some situations can be
really bad and an author might opt to put one parameter on each line. If
the author does that, he might want clang-format not to mess with that.
If the author is unhappy with the one-per-line formatting, clang-format
can easily be convinced to bin-pack by putting any two parameters on the
same line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186003 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2ca3741a962ded08866596577aaee2f4ab74c955 09-Jul-2013 Daniel Jasper <djasper@google.com> Initial support for formatting trailing return types.

This fixes llvm.org/PR15170.

For now, the basic formatting rules are (based on the C++11 standard):
* Surround the "->" with spaces.
* Break before "->".

Also fix typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185938 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b1491798353b26c07b065c6975a91ff6214b8ff6 09-Jul-2013 Daniel Jasper <djasper@google.com> Avoid confusing indentations for chained function calls.

Basically treat a function with a trailing call similar to a function
with multiple parameters.

Before:
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa))
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();

After:
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa))
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();

Also fix typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185930 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0de1c4d152b5fbf0b383e9fa8396e334f029c716 09-Jul-2013 Daniel Jasper <djasper@google.com> Fix alignment of closing brace in braced initializers.

Before:
someFunction(OtherParam, BracedList{
// comment 1 (Forcing intersting break)
param1, param2,
// comment 2
param3, param4
});
After:
someFunction(OtherParam, BracedList{
// comment 1 (Forcing intersting break)
param1, param2,
// comment 2
param3, param4
});

To do so, the UnwrappedLineParser now stores the information about the
kind of brace in the FormatToken.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185914 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6561f6a13b79ed752748ede590792191edf78ce8 09-Jul-2013 Daniel Jasper <djasper@google.com> Format overloaded operators like other functions.

This fixes llvm.org/PR16328 (at least partially).

Before:
SomeLoooooooooooooooooooooooooooooogType operator<<(
const SomeLooooooooogType &a, const SomeLooooooooogType &b);

After:
SomeLoooooooooooooooooooooooooooooogType
operator<<(const SomeLooooooooogType &a, const SomeLooooooooogType &b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185908 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
526df0f3a8d436e9084bd12118a2e119aa0bd724 08-Jul-2013 Daniel Jasper <djasper@google.com> Fix incorrect incorrect cast identification in clang-format.

This fixes llvm.org/PR16534.

Before:
aaaaa& operator+(const aaaaa&)LLVM_DELETED_FUNCTION;
After:
aaaaa& operator+(const aaaaa&) LLVM_DELETED_FUNCTION;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185828 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
51da1426b5ec43b6ac42777b2f28f89e3d3b3dca 08-Jul-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fixed testcase failing under MS by adding "-fno-delayed-template-parsing",
as suggested by Takumi. To this end, added a MatchVerifier::match()
overload accepting a vector of invocation arguments.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185827 91177308-0d34-0410-b5e6-96231b3b80d8
ST/MatchVerifier.h
ST/SourceLocationTest.cpp
88cc562ad2d3e75280d453f824e89380622f4c9c 08-Jul-2013 Daniel Jasper <djasper@google.com> Prefer similar line breaks.

This adds a penalty for clang-format for each break that occurs in
a set of parentheses (including fake parenthesis that determine
the range of certain operator precendences) that have not yet been
broken. Thereby, clang-format prefers similar line breaks.

This fixes llvm.org/PR15506.

Before:
const int kTrackingOptions =
NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited |
NSTrackingActiveAlways;

After:
const int kTrackingOptions = NSTrackingMouseMoved |
NSTrackingMouseEnteredAndExited |
NSTrackingActiveAlways;

Also removed ParenState::ForFakeParenthesis which has become unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185822 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1659dedac63858de50ee60175a88c42ff974e61b 08-Jul-2013 Alexander Kornienko <alexfh@google.com> Fix for corner cases in code handling leading "* " decorations in block comments

Summary:
Fixes problems that lead to incorrect formatting of these and similar snippets:
/*
**
*/

/*
**/

/*
* */

/*
*test
*/

Clang-format used to think that all the cases above use "* " decoration, and
failed to calculate insertion position properly. It also used to remove leading
"* " in the last line.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1113

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185818 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1fb09dfa19b7e4515347106ff5dd279f2021c9c4 08-Jul-2013 NAKAMURA Takumi <geek4civic@gmail.com> AST/SourceLocationTest.cpp: Appease MS hosts to suppress CXXUnresolvedConstructExpr.SourceRange, for now.

FIXME: It could pass if MS-compatible mode were disabled with Args.push_back("-fno-delayed-template-parsing").

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185795 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
bd9cbd22b832ce65a085801259cf2d3df77830e4 07-Jul-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fixed source range for functional cast and unresolved construct expr nodes.
Added testcases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185773 91177308-0d34-0410-b5e6-96231b3b80d8
ST/MatchVerifier.h
ST/SourceLocationTest.cpp
2d77634e839880704d51656bebd1d2daff661d4e 06-Jul-2013 Enea Zaffanella <zaffanella@cs.unipr.it> Fixed source location info for UnaryTransformTypeLoc nodes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185765 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
1ec4a86a867fc04f35d13bc9e33b04cf2171fe41 05-Jul-2013 Rafael Espindola <rafael.espindola@gmail.com> Use llvm::sys::fs::createTemporaryFile.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185717 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
d6104f6c34639ebe66f83d955c5f32ea4a50c266 05-Jul-2013 Daniel Jasper <djasper@google.com> Fix formatting for allocation of new pointer variables.

Before:
T **t = new T * ;
T **q = new T * ();

After:
T **t = new T *;
T **q = new T *();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185699 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
07ca5477461dc1f3efa76ef9cf6f9dbaf66ddb98 05-Jul-2013 Daniel Jasper <djasper@google.com> Improve detection for preventing certain kind of formatting patterns.

This is a better implementation of r183097. The main purpose is to
prevent certain constructs to be formatted "like a block of text".

Before:
aaaaaaaaaaaaa<
aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa = new aaaaaaaaaaaaa<
aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(bbbbbbbbbbbbbbbbbbbbbbbb);
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] = (*cccccccccccccccc)[
dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];

After:
aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>* aaaa =
new aaaaaaaaaaaaa<aaaaaaaaaa, aaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>(
bbbbbbbbbbbbbbbbbbbbbbbb);
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb] =
(*cccccccccccccccc)[
dddddddddddddddddddddddddddddddddddddddddddddddddddddddd];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185687 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
198c8bfee0b33ab0ed0c54224f460868f1c18e95 05-Jul-2013 Daniel Jasper <djasper@google.com> Don't break after a "(" following a binary operator.

Additionally, allow breaking after c-style casts, but with a high
penalty.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (
aaaaaaaaaaaaaaaaa *)bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *foo = (aaaaaaaaaaaaaaaaa *)
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

This fixes llvm.org/PR16049.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185685 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
56312023bf62cb40d2e33ea5e14d55c1e42303a7 04-Jul-2013 Alexander Kornienko <alexfh@google.com> Added AlwaysBreakBeforeMultilineStrings option.

Summary:
Always breaking before multiline strings can help format complex
expressions containing multiline strings more consistently, and avoid consuming
too much horizontal space.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1097

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185622 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6df7a2db6d74d41c4150b2c46b9a9e4e2db6c1dc 03-Jul-2013 Daniel Jasper <djasper@google.com> Don't insert confusing line breaks in comparisons.

In general, clang-format breaks after an operator if the LHS spans
multiple lines. Otherwise, this can lead to confusing effects and
effectively hide the operator precendence, e.g. in

if (aaaaaaaaaaaaaa ==
bbbbbbbbbbbbbb && c) { ...

This patch removes this rule for comparisons, if the LHS is not a binary
expression itself as many users were wondering why clang-format inserts
an unnecessary linebreak.

Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) >
5) { ...

After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) > 5) { ...

In the long run, we might:
- Want to do this for other binary expressions as well.
- Do this only if the RHS is short or even only if it is a literal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185530 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6ac431c7bae27a42351d2c2ad03dddd5b005ffd5 02-Jul-2013 Daniel Jasper <djasper@google.com> Fix formatting of long declarations with const type.

Before (exceeding the column limit):
LoooooooooooooooooooooooooooooooooooooooongType const LoooooooooooooooooooooooooooooooooooooooongVariable;

After:
LoooooooooooooooooooooooooooooooooooooooongType const
LoooooooooooooooooooooooooooooooooooooooongVariable;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185418 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f50dbfae1c5801d72d57fe5af90ad58871cea321 01-Jul-2013 Daniel Jasper <djasper@google.com> Fix incorrect token counting introduced by r185319.

This lead to weird formatting.
Before:
DoSomethingWithVector({ {} /* No data */ }, {
{ 1, 2 }
});
After:
DoSomethingWithVector({ {} /* No data */ }, { { 1, 2 } });

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185346 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d446f737f0c4840f25a371bfc9ebedab69e4027d 01-Jul-2013 Alexander Kornienko <alexfh@google.com> Avoid column limit violation in block comments in certain cases.

Summary:
Add penalty when an excessively long line in a block comment can not be
broken on a leading whitespace. Lack of this addition can lead to severe column
width violations when they can be easily avoided.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1071

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185337 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cbe86cc538b9e1af9f36b8a9c57ea51119306689 01-Jul-2013 Daniel Jasper <djasper@google.com> Don't align "} // namespace" comments.

This is not all bad, but people are often surprised by it.

Before:
namespace {
int SomeVariable = 0; // comment
} // namespace

After:
namespace {
int SomeVariable = 0; // comment
} // namespace

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185327 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c47d7f1237b022eabbbdcebf77506e8a81aa54bd 01-Jul-2013 Daniel Jasper <djasper@google.com> Don't add an extra space before ellipsis after pointers.

Before (for styles where the pointer binds to the type):
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts* ... ts) {}
After:
template <class... Ts> void Foo(Ts... ts) {}
template <class... Ts> void Foo(Ts*... ts) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185321 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3a1847e0a1810a0b1b963182abc59114cc5ff53d 01-Jul-2013 Daniel Jasper <djasper@google.com> Keep space between pointer and block comment.

Before: void f(int */* unused */) {}
After: void f(int * /* unused */) {}

The previous version seems to be valid C++ code but confuses many syntax
highlighters.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185320 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
02eacc2cf85fe11577bf6ff20f6c203e87147c57 01-Jul-2013 Daniel Jasper <djasper@google.com> Fix braced-list detection in lieu of trailing comments.

Before:
DoSomethingWithVector({
} /* No data */);
After:
DoSomethingWithVector({} /* No data */);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185319 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
89faf86c6e23ed62519dfe369f8ea408df1cb02e 30-Jun-2013 James Dennett <jdennett@google.com> Bug fix: Make RecursiveASTVisitor<T>::TraverseLambdaExpr call
WalkUpFromLambdaExpr, so that the Visit* functions are called
on that AST node.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185277 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
17aa33f34e15ed6317590cfbd3bd31bb634ba4f3 30-Jun-2013 James Dennett <jdennett@google.com> Add enumerators to TestVisitor::Language to allow visitor tests to
explicitly specify use of C++98 or C++11. Lang_CXX is preserved as
an alias for Lang_CXX98.

This does not add Lang_CXX1Y or Lang_C11, on the assumption that it's
better to add them if/when they are needed.

(This is a prerequisite for a test in a later patch for RecursiveASTVisitor.)

Reviewed by Richard Smith.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185276 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/TestVisitor.h
a1753f4be12737f36ce9c6eccccddd3be1ec514b 28-Jun-2013 Alexander Kornienko <alexfh@google.com> Use lexing mode based on FormatStyle.Standard.

Summary:
Some valid pre-C++11 constructs change meaning when lexed in C++11
mode, e.g.
#define x(_a) printf("foo"_a);
(example from http://llvm.org/bugs/show_bug.cgi?id=16342). "foo"_a is treated as
a user-defined string literal when parsed in C++11 mode.
In order to deal with this correctly, we need to set lexing mode according to
which standard the code conforms to. We already have a configuration value for
this (FormatStyle.Standard), which seems to be appropriate to use in this case
as well.

Reviewers: klimek

CC: cfe-commits, gribozavr

Differential Revision: http://llvm-reviews.chandlerc.com/D1028

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185149 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5bb5f6a84ef98e410fdc89d82f4b7565fb5616e5 26-Jun-2013 Rafael Espindola <rafael.espindola@gmail.com> Sync file handling logic in RewriterTestContext.h and RefactoringTest.cpp.

They are mostly duplicated and got out of sync during the PathV1 removal. We
should factor the code somewhere, but for now a FIXME will do.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185019 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
902a86385361d5d0a3ae731c89a5b62e470dd875 26-Jun-2013 Rafael Espindola <rafael.espindola@gmail.com> Remove last use of PathV1.h from clang.

Instead of creating a temporary directory, remember the set of temporary files
we create.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184951 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
861576b8019392f15c803ac14a4bc31fbd93aab2 26-Jun-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Don't put a space after parameter-naming block comments.

Before: f(a, b, /*doFoo=*/ false);
Now: f(a, b, /*doFoo=*/false);

This style is a lot more common:
$ ack -H '=\*\/\w' lib | wc -l
1281
$ ack -H '=\*\/ \w' lib | wc -l
70



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184894 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
465e8615a153ebd70eb27785af79f7e82e4a81d4 25-Jun-2013 Nico Weber <nicolasweber@gmx.de> Formatter/ObjC: Correctly format casts in objc message send expressions.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184804 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
10fc2c66ca3a383dfec903c39ba88c16e04f3c87 25-Jun-2013 Nico Weber <nicolasweber@gmx.de> Formatter/Objc: Add a test that checks that @import is formatted correctly.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184796 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e05481991929c83ea8de8e66dee9e59bd31bfb3d 24-Jun-2013 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests/ASTMatchers/Dynamic/RegistryTest.cpp: Suppress unexpected failures on MS hosts.

FIXME: A couple of tests have been suppressed.
I know it'd be bad with _MSC_VER here, though.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184727 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/RegistryTest.cpp
c1c76254adc08f9f512b60ac91d79a164a5a397b 22-Jun-2013 Alexander Kornienko <alexfh@google.com> Fixed typo.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184625 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a9a7f108a4a10da1f08fd4538a15f441bfee72c1 21-Jun-2013 Manuel Klimek <klimek@google.com> Add an option to not indent declarations when breaking after the type.

Make that option the default for LLVM style.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184563 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ef7eb024397a6a9d1455b31bc7b10288a817ac3b 21-Jun-2013 Samuel Benzaquen <sbenza@google.com> Add support for polymorphic matchers. Use runtime type checking to determine the right polymorphic overload to use.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184558 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
8711da1b6ba7d2bb94fa579f7d58b4d3e45825ac 21-Jun-2013 Reid Kleckner <reid@kleckner.net> Disable an assertion death test when using MSVC's assert()

MSVC's debug runtime prints assertion failures in wide characters, which
gtest doesn't understand.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184544 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/VariantValueTest.cpp
76c2f92c4b4ab7e02857661a05e53ba4b501d87a 20-Jun-2013 Samuel Benzaquen <sbenza@google.com> Enhancements for the DynTypedMatcher system.
- Added conversion routines and checks in Matcher<T> that take a DynTypedMatcher.
- Added type information on the error messages for the marshallers.
- Allows future work on Polymorphic/overloaded matchers. We should be
able to disambiguate at runtime and choose the appropriate overload.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184429 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.h
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
cf52ca6bb6dd76a1bd967bc422287fafafa1e45a 20-Jun-2013 Manuel Klimek <klimek@google.com> Adds the equalsBoundNode matcher.

Most of the tests contributed by Edwin Vane.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184427 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8afa39b271d94969891dba014e0fc545b4873479 20-Jun-2013 Alexander Kornienko <alexfh@google.com> Use the same set of whitespace characters for all operations in BreakableToken.

Summary:
Fixes a problem where \t,\v or \f could lead to a crash when placed as
a first character in a line comment. The cause is that rtrim and ltrim handle
these characters, but our code didn't, so some invariants could be broken.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1013

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184425 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1a68afd5bbecd05a3bb22854954aa4e5448c4470 20-Jun-2013 Manuel Klimek <klimek@google.com> Implements declaratorDecl, parmVarDecl and hassTypeLoc matchers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184419 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
c36c5c247f53b0517b141ae5ae93f4580e9452ba 19-Jun-2013 Alexander Kornienko <alexfh@google.com> Fixed long-standing issue with incorrect length calculation of multi-line comments.

Summary:
A trailing block comment having multiple lines would cause extremely
high penalties if the summary length of its lines is more than the column limit.
Fixed by always considering only the last line of a multi-line block comment.
Removed a long-standing FIXME from relevant tests and added a motivating test
modelled after problem cases from real code.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1010

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184340 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d5fbb2910fe934a61176b94503b0cf495f129253 19-Jun-2013 Samuel Benzaquen <sbenza@google.com> Enhancements for the DynTypedNode

Added ASTNodeKind as a standalone way to represent node kinds and their hierarchy.
This change is to support ongoing work on D815.

Reviewers: klimek

CC: cfe-commits

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184331 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTTypeTraitsTest.cpp
ST/CMakeLists.txt
054d049174eb1ec8e93a4a0831c0d8caac00cb3a 19-Jun-2013 Manuel Klimek <klimek@google.com> Completely revamp node binding for AST matchers.

This is in preparation for the backwards references to bound
nodes, which will expose a lot more about how matches occur. Main
changes:
- instead of building the tree of bound nodes, we build a "set" of bound
nodes and explode all possible match combinations while running
through the matchers; this will allow us to also implement matchers
that filter down the current set of matches, like "equalsBoundNode"
- take the set of bound nodes at the start of the match into
consideration when doing memoization; as part of that, reevaluated
that memoization gives us benefits that are large enough (it still
does - the effect on common match patterns is up to an order of
magnitude)
- reset the bound nodes when a node does not match, thus never leaking
information from partial sub-matcher matches for failing matchers

Effects:
- we can now correctly "explode" combinatorial matches, for example:
allOf(forEachDescendant(...bind("a")),
forEachDescendant(...bind("b"))) will now trigger matches for all
combinations of matching "a" and "b"s.
- we now never expose bound nodes from partial matches in matchers that
did not match in the end - this fixes a long-standing issue

FIXMEs:
- rename BoundNodesTreeBuilder to BoundNodesBuilder or
BoundNodesSetBuilder, as we don't build a tree any more; this is out
of scope for this change, though
- we're seeing some performance regressions (around 10%), but I expect
some performance tuning will get that back, and it's easily worth
the increase in expressiveness for now

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184313 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
f2b2c7da1f3bfed9b0bb194ff00d6e1e43d68d5c 19-Jun-2013 Alexander Kornienko <alexfh@google.com> Split long strings on word boundaries.

Summary: Split strings at word boundaries, when there are no spaces and slashes.

Reviewers: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1003

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184304 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6e40c9544a0215c3e632e1fb79d5161adc464101 18-Jun-2013 Eli Friedman <eli.friedman@gmail.com> Fix source range of CXXNewExpr with parentheses around the type. PR15569.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184139 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
d71b15badeecdc049440103ef044f9cdf5e1359c 17-Jun-2013 Alexander Kornienko <alexfh@google.com> Fix a problem in ExpressionParser leading to trailing comments affecting indentation of an expression after a line break.

Summary:
E.g. the second line in

return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b; //

is indented 4 characters more than in

return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
b;

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D984

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184078 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
22d0e2985d00010ed1d56168985ca34adc75b80a 17-Jun-2013 Alexander Kornienko <alexfh@google.com> Fixes incorrect indentation of line comments after break and re-alignment.

Summary:
Selectively propagate the information about token kind in
WhitespaceManager::replaceWhitespaceInToken.For correct alignment of new
segments of line comments in order to align them correctly. Don't set
BreakBeforeParameter in breakProtrudingToken for line comments, as it introduces
a break after the _next_ parameter. Added tests for related functions.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D980

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184076 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b1e25a1bc03292dc538d336573e0be1490223171 14-Jun-2013 Reid Kleckner <reid@kleckner.net> [Driver] Refactor clang driver to use LLVM's Option library

The big changes are:
- Deleting Driver/(Arg|Opt)*
- Rewriting includes to llvm/Option/ and re-sorting
- 'using namespace llvm::opt' in clang::driver
- Fixing the autoconf build by adding option everywhere

As discussed in the review, this change includes using directives in
header files. I'll make follow up changes to remove those in favor of
name specifiers.

Reviewers: espindola

Differential Revision: http://llvm-reviews.chandlerc.com/D975

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183989 91177308-0d34-0410-b5e6-96231b3b80d8
ST/Makefile
STMatchers/Dynamic/Makefile
STMatchers/Makefile
ormat/Makefile
rontend/Makefile
ooling/Makefile
16a0ec60507a4eec275a5c3a86d4501b1b7b817b 14-Jun-2013 Alexander Kornienko <alexfh@google.com> Don't remove backslashes from block comments.

Summary:
Don't remove backslashes from block comments. Previously this
/* \ \ \ \ \ \
*/
would be turned to this:
/*
*/
which spoils some kinds of ASCII-art, people use in their comments. The behavior
was related to handling escaped newlines in block comments inside preprocessor
directives. This patch makes handling it in a more civilized way.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D979

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183978 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e3f1197cad5cda243093e8b39caa43f13111de89 12-Jun-2013 Alexander Kornienko <alexfh@google.com> Preserve newlines before block comments in static initializers.

Summary:
Basically, don't special-case line comments in this regard. And fixed
an incorrect test, that relied on the wrong behavior.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D962

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183851 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8229d22e6449851b89361bf2f41804557328be63 12-Jun-2013 Rafael Espindola <rafael.espindola@gmail.com> Include Path.h instead of PathV2.h.

I am about to move PathV2.h to Path.h.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183795 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PPCallbacksTest.cpp
ooling/CompilationDatabaseTest.cpp
2db9828139c36f7d6fadbf57b0eb0c2915416b91 11-Jun-2013 Rafael Espindola <rafael.espindola@gmail.com> Include PathV1.h in a file that uses it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183786 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
2b2faa53ecd32e823c55430d0889c11ea91b582c 11-Jun-2013 Alexander Kornienko <alexfh@google.com> Insert a space at the start of a line comment in case it starts with an alphanumeric character.

Summary:
"//Test" becomes "// Test". This change is aimed to improve code
readability and conformance to certain coding styles. If a comment starts with a
non-alphanumeric character, the space isn't added, e.g. "//-*-c++-*-" stays
unchanged.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D949

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183750 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
44ee0a710c59d8e6793189f903bae21c16814324 07-Jun-2013 Eli Friedman <eli.friedman@gmail.com> Re-commit r183466 with a fix to make the TypeLoc casting machinery work
correctly in the presence of qualified types.

(I had to change the unittest because it was trying to cast a
QualifiedTypeLoc to TemplateSpecializationTypeLoc.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183563 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
54e6c9d1f15153d1756642080866f10a91cc86ea 07-Jun-2013 Alexander Kornienko <alexfh@google.com> Improved handling of escaped newlines at the token start.

Summary: Remove them from the TokenText as well.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D935

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183536 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2785b9aabcb2c3fd6f7dd8b63d3cd3d4b9bca284 07-Jun-2013 Alexander Kornienko <alexfh@google.com> Fixed calculation of penalty when breaking tokens.

Summary:
Introduced two new style parameters: PenaltyBreakComment and
PenaltyBreakString. Add penalty for each character of a breakable token beyond
the column limit (this relates mainly to comments, as they are broken only on
whitespace). Tuned PenaltyBreakComment to prefer comment breaking over breaking
inside most binary expressions.
Fixed a bug that prevented *, & and && from being considered TT_BinaryOperator
in the presense of adjacent comments.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D933

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183530 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7e6e515fc74ecb6d98689a93b5569763c53c107a 07-Jun-2013 Manuel Klimek <klimek@google.com> Adds a test that verifies angle bracket locations.

Regression test to make sure TemplateSpecializationTypeLocs have the
correct locations for angle brackets.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183514 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
65d2c3829494d254039683c73f95843c29c661b4 06-Jun-2013 Daniel Jasper <djasper@google.com> Fix incorrect line breaking before trailing block comments.

Before, clang-format would happily move a trailing block comment to a
new line, which normally changes the perceived binding of that comment.

E.g., it would move:
void f() { /* comment */
...
}
to:
void f() {
/* comment */
...
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183420 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9acb8b4355028887e8cc4aa8f683aceee021a62b 06-Jun-2013 Daniel Jasper <djasper@google.com> Fix clang-format's expression parser for leading }s.

The leading "}" in the construct "} else if (..) {" was confusing the
expression parser. Thus, no fake parentheses were generated and the
indentation was broken in some cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183393 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ff1a2e519ebcd6d7a060eac7ba8aca37b2bf89d0 06-Jun-2013 Daniel Jasper <djasper@google.com> Improve c-style cast detection.

Before:
return (my_int) aaaa;
template <> void f<int>(int i)SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa)"aaaa");

After:
return (my_int)aaaa;
template <> void f<int>(int i) SOME_ANNOTATION;
f("aaaa" SOME_MACRO(aaaa) "aaaa");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183389 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
07eda943366b889e52d6db31302c5c0992ccbd43 06-Jun-2013 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests/Format/FormatTest.cpp: Suppress utf8 literals with _MSC_VER. MS cl.exe is unaware of BOM-less utf8 source files.

FIXME: Encode Cyrillic and CJK characters below to appease MS compilers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183366 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dda770b4a3135ac372a84a2e53d8b58a0c62b9e1 05-Jun-2013 Alexander Kornienko <alexfh@google.com> Added test with characters using four bytes in UTF-8 representation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183315 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
00895106f9ed602af67984ec4d225a0cdc8c12af 05-Jun-2013 Alexander Kornienko <alexfh@google.com> UTF-8 support for clang-format.

Summary:
Detect if the file is valid UTF-8, and if this is the case, count code
points instead of just using number of bytes in all (hopefully) places, where
number of columns is needed. In particular, use the new
FormatToken.CodePointCount instead of TokenLength where appropriate.
Changed BreakableToken implementations to respect utf-8 character boundaries
when in utf-8 mode.

Reviewers: klimek, djasper

Reviewed By: djasper

CC: cfe-commits, rsmith, gribozavr

Differential Revision: http://llvm-reviews.chandlerc.com/D918

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183312 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4b9b292074b56e8cf2e72c2ef70ec59e5356a02a 05-Jun-2013 NAKAMURA Takumi <geek4civic@gmail.com> ASTTests/DeclTest.cpp: Tweak on msvc target to add "-fno-ms-extensions".

MS extensions don't prefer imaginary suffix even with -std=c++11.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183301 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclTest.cpp
7a337af9e8bc752a2d3b227e4058ed2baf7a19d1 04-Jun-2013 Samuel Benzaquen <sbenza@google.com> Parser/Registry argument enhancements.

Summary:
Parser/Registry argument enhancements.
- 2 argument support.
- unsigned values support.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D915

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183231 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
48b3f0f74da575a66802dc5019b7440914983885 04-Jun-2013 Manuel Klimek <klimek@google.com> Enables chaining of argument adjusters in clang tools.

This enables changing clang-check to get extra arguments.

Patch by Pavel Labath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183227 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
c69e1733cdcf74cde52f596310dd8d07eb28e585 03-Jun-2013 Benjamin Kramer <benny.kra@googlemail.com> __uint128_t is only available on 64 bit platforms, only test it when it's around.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183146 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclTest.cpp
4f37d925927dfdd0c770702ffb22de38fc2007dc 03-Jun-2013 Samuel Benzaquen <sbenza@google.com> Add support for .bind("foo") expressions on the dynamic matchers.

Summary: Add support on the parser, registry, and DynTypedMatcher for binding IDs dynamically.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D911

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183144 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/ParserTest.cpp
15f33f03e742fb6567e4789996fa0391a8e18068 03-Jun-2013 Daniel Jasper <djasper@google.com> Let clang-format remove empty lines before "}".

These lines almost never aid readability.

Before:
void f() {
int i; // some variable

}

After:
void f() {
int i; // some variable
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183112 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f0f353b36f173ea282209070fcdbbedab84c19db 03-Jun-2013 Manuel Klimek <klimek@google.com> Fix memory leak for APValues that do memory allocation.

This patch ensures that APValues are deallocated with the ASTContext by
registering a deallocation function for APValues to the ASTContext.

Original version of the patch by James Dennett.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183101 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
ST/DeclTest.cpp
ce912f45660613c1bc49696eb07ff7f8aecffe18 03-Jun-2013 Daniel Jasper <djasper@google.com> Improve detection preventing certain kind of formatting patterns.

An oversight in this detection made clang-format unable to format
the following nicely:
void aaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbbbbbbbbbbbbbbbbbbbbbbbb>(
cccccccccccccccccccccccccccc);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183097 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5ef8aacd5f25767fc7bd1ec47c2b5f5fd1ac38eb 03-Jun-2013 Daniel Jasper <djasper@google.com> Fix line-breaking problem caused by comment.

Before, clang-format would not find a solution for formatting:
if ((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
bbbbbbbbbbbbbbbbbb) && // aaaaaaaaaaaaaaaa
cccccc) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183096 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0348be0c78781c5ddb8c271976812705410c731a 01-Jun-2013 Daniel Jasper <djasper@google.com> Improve recognition of template parameters.

Before: return a<b &&c> d;
After: return a < b && c > d;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183077 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b8b4295b4ee161bfb76ff7b0ec1007bfd959553b 31-May-2013 Daniel Jasper <djasper@google.com> Improve clang-format's c-style cast detection.

Before:
x[(uint8) y];
x = (uint8) y;
void f() { x = (uint8) y; }
#define AA(X) sizeof(((X *) NULL)->a)

After:
x[(uint8)y];
x = (uint8)y;
void f() { x = (uint8)y; }
#define AA(X) sizeof(((X *)NULL)->a)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183014 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f7ec1cc7f931833b2cb9876a5e7dfd6bf8681c6a 31-May-2013 Daniel Jasper <djasper@google.com> Improve clang-format's error recovery.

If a "}" is found inside parenthesis, this is probably a case of
missing parenthesis. This enables continuing to format after stuff code
like:

class A {
void f(
};
..

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183009 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8893b8a28d32359a5c778d9308780200a09402ba 31-May-2013 Daniel Jasper <djasper@google.com> Make formatting of empty blocks more consistent.

With this patch, the simplified rule is:
If the block is part of a declaration (class, namespace, function,
enum, ..), merge an empty block onto a single line. Otherwise
(specifically for the compound statements of if, for, while, ...),
keep the braces on two separate lines.

The reasons are:
- Mostly the formatting of empty blocks does not matter much.
- Empty compound statements are really rare and are usually just
inserted while still working on the code. If they are on two lines,
inserting code is easier. Also, overlooking the "{}" of an
"if (...) {}" can be really bad.
- Empty declarations are not uncommon, e.g. empty constructors. Putting
them on one line saves vertical space at no loss of readability.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183008 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c01897c3f6139304ed25e3f673bef77be209617f 31-May-2013 Daniel Jasper <djasper@google.com> Properly format nested conditional operators.

Before:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;

After:
bool aaaaaa = aaaaaaaaaaaaa //
? aaaaaaaaaaaaaaa
: bbbbbbbbbbbbbbb //
? ccccccccccccccc
: ddddddddddddddd;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183007 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
eb48366d41a6dcca236f1e28aea61efd569a3374 31-May-2013 Daniel Jasper <djasper@google.com> Fix detection/formatting of braced lists in ternary expressions.

Before:
foo = aaaaaaaaaaa ? vector<int> {
aaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaa
}
: vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb, bbbbbbbbbbbbbbbbbbbb, bbbbb };

After:
foo = aaaaaaaaaaa ? vector<int>{ aaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa, aaaaa }
: vector<int>{ bbbbbbbbbbbbbbbbbbbbbbbbbbb,
bbbbbbbbbbbbbbbbbbbb, bbbbb };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182992 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cb4b40b86e284151d6ca14181f949655a9ceccd8 30-May-2013 Daniel Jasper <djasper@google.com> More fixes for clang-format's multiline comment breaking.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182940 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
920927016ed13bff83af016701b7d118a3dfed3b 30-May-2013 Daniel Jasper <djasper@google.com> Fix another clang-format crasher related to multi-line comments.

This fixes:
/*
*
* something long going over the column limit.
*/

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182932 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5ec9580f68661ffccff07177613b692d0acb4797 30-May-2013 Edwin Vane <edwin.vane@intel.com> Coding style fix for SourceFileCallbacks



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182930 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
e2c482f3720261dea180400816d4572d1986f423 30-May-2013 Daniel Jasper <djasper@google.com> Fix crasher when formatting certain block comments.

Smallest reproduction:
/*
**
*/

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182913 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
be9ed776e57fe606b5826a0d37a5a2dbfb927e63 30-May-2013 Manuel Klimek <klimek@google.com> Fixes error when splitting block comments.

When trying to fall back to search from the end onwards, we
would still find leading whitespace if the leading whitespace
went on after the end of the line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182886 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ff62d64c63cbae47ed768638aa9c621eccff030c 29-May-2013 Roman Divacky <rdivacky@freebsd.org> Turn CLANG_ENABLE_{ARCMT,REWRITER,STATIC_ANALYZER} into proper options so that
users can disable those. Just like in autoconf generated makefiles.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182881 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
3c16e699b2a6926017b5f7a1516dc1be67468713 29-May-2013 Edwin Vane <edwin.vane@intel.com> Tooling: Call back for both begin and end of sources

newFrontendActionFactory() took a pointer to a callback to call when a source
file was done being processed by an action. This revision updates the callback
to include an ante-processing callback as well.

Callback-providing class renamed and callback functions themselves renamed.
Functions are no longer pure-virtual so users aren't forced to implement both
callbacks if one isn't needed.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182864 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
c76d59d8ff564f918833c97caede7dce2d8cfe60 29-May-2013 Daniel Jasper <djasper@google.com> Add return missing in r182855.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182856 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7e70f4c09c5e10c2690eac04d9d812fb8e4a0c0d 29-May-2013 Daniel Jasper <djasper@google.com> Leave some macros on their own line

If an identifier is on its own line and it is all upper case, it is highly
likely that this is a macro that is meant to stand on a line by itself.

Before:
class A : public QObject {
Q_OBJECT A() {}
};

Ater:
class A : public QObject {
Q_OBJECT

A() {}
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182855 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bbc8776493fc0176d925a5b528e61ee400895047 29-May-2013 Daniel Jasper <djasper@google.com> Add option to always break template declarations.

With option enabled (e.g. in Google-style):
template <typename T>
void f() {}

With option disabled:
template <typename T> void f() {}

Enabling this for Google-style and Chromium-style, not sure which other
styles would prefer that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182849 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8f9e590f78b1b05c36c2a14d68c4b9f9acbb891a 28-May-2013 Peter Collingbourne <peter@pcc.me.uk> Add an overridable MatchCallback::onEndOfTranslationUnit() function.

Differential Revision: http://llvm-reviews.chandlerc.com/D745

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182798 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
88959b764ede8aac9118434f6c21c15463dff595 28-May-2013 Daniel Jasper <djasper@google.com> Support uniform inits in braced lists.

This made it necessary to remove an error detection which would let us
bail out of braced lists in certain situations of missing "}". However,
as we always entirely escape from the braced list on finding ";", this
should not be a big problem.

With this, we can no format braced lists with uniformat inits:

return { arg1, SomeType { parameter } };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182788 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3ff4a2fea4aa6e5182b7799ccb4352e56961a212 28-May-2013 Daniel Jasper <djasper@google.com> Fix formatting regression regarding pointers to arrays.

Before: f( (*PointerToArray)[10]);
After: f((*PointerToArray)[10]);

This fixes llvm.org/PR16163

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182777 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5ad390d27f8f7cb6628bc2c32beba4d25bc2718b 28-May-2013 Daniel Jasper <djasper@google.com> Initial support for designated initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182767 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d63312b1484a4642225c97e1dd013fe520b2b9a4 28-May-2013 Manuel Klimek <klimek@google.com> Disable tab expansion when counting the columns in block comments.

To fully support this, we also need to expand tabs in the text before
the block comment. This patch breaks indentation when there was a
non-standard mixture of spaces and tabs used for indentation, but
fixes a regression in the simple case:
{
/*
* Comment.
*/
int i;
}
Is now formatted correctly, if there were tabs used for indentation
before.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182760 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c5cc4bf2699b0542f352738f84eee373cfcf670f 28-May-2013 Manuel Klimek <klimek@google.com> Fixes indentation of empty lines in block comments.

Block comment indentation of empty lines regressed, as we did not
have a test for it.
/* Comment with...
*
* empty line. */
is now formatted correctly again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182757 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
431f5918281dd1f178bf838b7a47ab1d11c52961 28-May-2013 Daniel Jasper <djasper@google.com> Clean up formatting of function types.

Before:
int (*func)(void*);
void f() { int(*func)(void*); }

After (consistent space after "int"):
int (*func)(void*);
void f() { int (*func)(void*); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182756 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
69c4371a978100d1538f414032f0a8750a0ca63f 28-May-2013 Daniel Jasper <djasper@google.com> Fix formatting of expressions containing ">>".

This gets turned into two ">" operators at the beginning in order to
simplify template parameter handling. Thus, we need a special case to
handle those two binary operators correctly.

With this patch, clang-format can now correctly handle cases like:
aaaaaa = aaaaaaa(aaaaaaa, // break
aaaaaa) >>
bbbbbb;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182754 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
131884a4bd9b72f8ced8c9f6d2b284f40fde1ea5 27-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of templates.

Before: A < int&& > a;
After: A<int &&> a;

Also remove obsolete FIXMEs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182741 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
de008c0f3bf66103185fc9f7f49995fa431451a6 27-May-2013 Manuel Klimek <klimek@google.com> Major refactoring of BreakableToken.

Unify handling of whitespace when breaking protruding tokens with other
whitespace replacements.

As a side effect, the BreakableToken structure changed significantly:
- have a common base class for single-line breakable tokens, as they are
much more similar
- revamp handling of multi-line comments; we now calculate the
information about lines in multi-line comments similar to normal
tokens, and always issue replacements

As a result, we were able to get rid of special casing of trailing
whitespace deletion for comments in the whitespace manager and the
BreakableToken and fixed bugs related to tab handling and escaped
newlines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182738 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
512843a7dc01a4f1755e699d1e394a691a39c176 27-May-2013 Daniel Jasper <djasper@google.com> Improve indentation of assignments.

Before:
unsigned OriginalStartColumn = SourceMgr.getSpellingColumnNumber(
Current.FormatTok.getStartOfNonWhitespace()) -
1;

After:
unsigned OriginalStartColumn =
SourceMgr.getSpellingColumnNumber(
Current.FormatTok.getStartOfNonWhitespace()) -
1;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182733 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
259a038a97c37109752c70a05e17aa811de3bd8f 27-May-2013 Daniel Jasper <djasper@google.com> Fix hacky way of preventing a certain type of line break.

In general, we like to avoid line breaks like:

...
SomeParameter, OtherParameter).DoSomething(
...

as they tend to make code really hard to read (how would you even indent the
next line?). Previously we have implemented this in a hacky way, which has now
shown to lead to problems. This fixes a few weird looking formattings, such as:

Before:
aaaaa(
aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
.aaaaa(aaaaa),
aaaaaaaaaaaaaaaaaaaaa);
After:
aaaaa(aaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa).aaaaa(aaaaa),
aaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182731 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f2ff8126e9e9df368f31b1f968d8fc80f99809b3 26-May-2013 Nico Weber <nicolasweber@gmx.de> Formatter/ObjC: In dictionary literals, break after ':', not before it.

Before:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
: regularFont, };

Now:
@{ NSFontAttributeNameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee :
regularFont, };

':'s in dictionary literals (and the corresponding {}s) are now marked as
TT_ObjCDictLiteral too, which makes further improvements to dict literal
layout possible.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182716 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6fb46b02599493d16e5130eff61050c72f65f89e 24-May-2013 Alexander Kornienko <alexfh@google.com> Ignore contents of #if 0 blocks.

Summary:
Added stack of preprocessor branching directives, and ignore all tokens
inside #if 0 except for preprocessor directives.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D855

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182658 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ce93356e2719d2992763ea747b65beada99f4c9b 23-May-2013 Daniel Jasper <djasper@google.com> More tests and a fix for braced init lists.

Before: f(new vector<int> { 1, 2, 3 });
After: f(new vector<int>{ 1, 2, 3 });

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182614 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
854ca794c17679ba4d0e529e8eb8b6b3703d1984 23-May-2013 Manuel Klimek <klimek@google.com> Fix aligning of comments.

Previously we started sequences to align for single line comments when
the previous line had a trailing comment, but the sequence was broken
for other reasons.

Now we re-format:
// a
// b
f(); // c
to:
// a
// b
f(); // c

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182608 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
23ad339cdb8ee55c5f243bc2573c5f9d6144a647 23-May-2013 Manuel Klimek <klimek@google.com> Fix aligning of comments that are at the start of the line.

Now correctly leaves:
f(); // comment
// comment
g(); // comment
... alone if the middle comment was aligned with g() before formatting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182605 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
de0d61fbe8bb0ba287eeed183bb98361d4e10c68 23-May-2013 Daniel Jasper <djasper@google.com> Increase test coverage for braced init lists.

Also fix a minor bug for constructor initializers with braced init lists.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182601 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1bee0738b67b784f08d5e2f8351920260c9cfb1d 23-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of braced lists.

Before: vector<int> v{ -1};
After: vector<int> v{-1};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182597 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ebfb88c32adb40b64a44479708dc6931224ccf96 23-May-2013 Manuel Klimek <klimek@google.com> Stop aligning trailing comments which are aligned with the next line.

Previously we would align:
f(); // comment
// other comment
g();

Even if // other comment was at the start of the line. Now we do not
align trailing comments if they have been already aligned correctly
with the next line.

Thus,
f(); // comment
// other comment
g();
will not be changed, while:
f(); // comment
// other commment
g();
will lead to the two trailing comments being aligned.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182577 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ad3094b7d85a4f8eeaf3f60364d5e8796537f061 23-May-2013 Manuel Klimek <klimek@google.com> Use a SourceRange for the whitespace location in FormatToken.

Replaces the use of WhitespaceStart + WhitspaceLength.
This made a bug in the formatter obvous where we would incorrectly
calculate the next column.

FIXME: There's a similar bug left regarding TokenLength. We should
probably also move to have a TokenRange instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182572 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2424eefa6936ec2dc35188e19c99e2f85428b52e 23-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of braced lists.

Before:
vector<int> x { 1, 2, 3 };
After:
vector<int> x{ 1, 2, 3 };

Also add a style option to remove the spaces inside braced lists,
so that the above becomes:
std::vector<int> v{1, 2, 3};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182570 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
80829bd8c3161cb706e28f29ac17a871f5eaaa5b 23-May-2013 Manuel Klimek <klimek@google.com> Expand parsing of braced init lists.

Allows formatting of C++11 braced init list constructs, like:
vector<int> v { 1, 2, 3 };
f({ 1, 2 });

This involves some changes of how tokens are handled in the
UnwrappedLineFormatter. Note that we have a plan to evolve the
design of the token flow into one where we create all tokens
up-front and then annotate them in the various layers (as we
currently already have to create all tokens at once anyway, the
current abstraction does not help). Thus, this introduces
FIXMEs towards that goal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182568 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e573c3f7fc40e813559ab4ff1e7eec4f66f1a50f 22-May-2013 Manuel Klimek <klimek@google.com> Makes whitespace management more consistent.

Instead of selectively storing some changes and directly generating
replacements for others, we now notify the WhitespaceManager of the
whitespace before every token (and optionally with more changes inside
tokens).

Then, we run over all whitespace in the very end in original source
order, where we have all information available to correctly align
comments and escaped newlines.

The future direction is to pull more of the comment alignment
implementation that is now in the BreakableToken into the
WhitespaceManager.

This fixes a bug when aligning comments or escaped newlines in unwrapped
lines that are handled out of order:
#define A \
f({ \
g(); \
});
... now gets correctly layouted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182467 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6e6efa7ec880559b7dd3096423b2345c0ff21c4c 22-May-2013 Daniel Jasper <djasper@google.com> Improve clang-format's stream formatting.

clang-format was a bit too aggressive when trying to keep labels and
values on the same line.

Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
<< aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182458 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
24e19e4f96abd12f3f4b72b8a315b8ac257bc88f 22-May-2013 Daniel Jasper <djasper@google.com> Fix function declaration behavior.

This only affects styles that prevent bin packing. There, a break after
a template declaration also forced a line break after the function name.

Before:
template <class SomeType, class SomeOtherType>
SomeType
SomeFunction(SomeType Type, SomeOtherType OtherType) {}

After:
template <class SomeType, class SomeOtherType>
SomeType SomeFunction(SomeType Type, SomeOtherType OtherType) {}

This fixes llvm.org/PR16072.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182457 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5ad72bb8eb8e5cc4c061ccd28632295213d319db 22-May-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing 'const'.

Reduce the preference for breaking before a trailing 'const' according
to review comments on r182362.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182455 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
54b4e4468ec2bcd381ede70e1391bcdb59b8fd1a 22-May-2013 Daniel Jasper <djasper@google.com> Cut-off clang-format analysis.

If clang-format is confronted with long and deeply nested lines (e.g.
complex static initializers or function calls), it can currently try too
hard to find the optimal solution and never finish. The reason is that
the memoization does not work effectively for deeply nested lines.

This patch removes an earlier workaround and instead opts for
accepting a non-optimal solution in rare cases. However, it only does
so only in cases where it would have to analyze an excessive number of
states (currently set to 10000 - the most complex line in Format.cpp
requires ~800 states) so this should not change the behavior in a
relevant way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182449 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6bd3b93200c6ae141d0f7444ffb4cacd52b183ed 21-May-2013 Daniel Jasper <djasper@google.com> Let clang-format move the cursor appropriately.

With this patch, clang-format will try to keep the cursor at the
original code position in editor integrations (implemented for emacs and
vim). This means, after formatting, clang-format will try to keep the
cursor on the same character of the same token.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182373 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
e033e87cbe77341777100093f8066167888d4440 21-May-2013 Daniel Jasper <djasper@google.com> Allow breaking before a trailing const.

Before:
void someLongFunction(
int someLongParameter) const;

After:
void someLongFunction(int someLongParameter)
const;

Also slightly cleanup tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182362 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
885f87b4be987fd8912779419ec88e3c37481967 19-May-2013 Alexander Kornienko <alexfh@google.com> Clang-format: allow -style="{yaml/json}" on command line

Summary: + improved handling of default style and predefined styles.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D813

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182205 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
399914b7a61a3823cc74ef3e47b1cde42528b9bf 17-May-2013 Daniel Jasper <djasper@google.com> Slightly modify the formatting rules for braced lists.

Basically, the new rule is: The opening "{" always has to be on the
same line as the first element if the braced list is nested
(e.g. in another braced list or in a function).

The solution that clang-format produces almost always adheres to this
rule anyway and this makes clang-format significantly faster for larger
lists. Added a test cases for the only exception I could find
(which doesn't seem to be very important at first sight).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182082 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c50c6ff49aa3648ae031349de6f09439f52425f0 16-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Lexer] Improve Lexer::getSourceText() when the given range deals with function macro arguments.

This is a modified version of a patch by Manuel Klimek.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182055 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
9e5b6c3ced66cffa403d7ce4a85f093b38119121 16-May-2013 Daniel Jasper <djasper@google.com> Add additional test-case for one-line-function.

This ensures that we format:
void longFunctionName {
} // long comment here

And not:
void longFunctionName {}
// long comment here

As requested in post-commit-review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182024 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5d5b424589efe6b3dd963cb6a2b71b5583a4f6f2 16-May-2013 Daniel Jasper <djasper@google.com> Don't insert a break into include lines with trailing comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182003 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2a2579afa84ae54f07d36a2ad9388746c0c61174 16-May-2013 Daniel Jasper <djasper@google.com> Add config parsing test for new parameter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182001 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f11bbb9b0e9b741c84214459526d3e5e137e9165 16-May-2013 Daniel Jasper <djasper@google.com> Add option to put short loops on a single line.

This enables things like:

for (int &v : vec) v *= 2;

Enabled for Google style.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182000 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8a99945769aa83270bda4ae4890f519800aa19eb 16-May-2013 Daniel Jasper <djasper@google.com> Add a more convenient interface to use clang-format.

It turns out that several implementations go through the trouble of
setting up a SourceManager and Lexer and abstracting this into a
function makes usage easier.

Also abstracts SourceManager-independent ranges out of
tooling::Refactoring and provides a convenience function to create them
from line ranges.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181997 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
058f6f889a1df37f31bcf6b82060b8f815113471 16-May-2013 Daniel Jasper <djasper@google.com> Comments should not prevent single-line functions.

Before:
void f() {}
void g() {
} // comment

After:
void f() {}
void g() {} // comment

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181996 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9a2f8d07bf820b524c7b23f6f625f206cad3bf96 16-May-2013 Daniel Jasper <djasper@google.com> Add back accidentally deleted line and add test for it.

Before:
f("a", "b"
"c");
After:
f("a", "b"
"c");

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181980 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5be59ba8c9fb291f83970f0ebddceda70088bb28 15-May-2013 Daniel Jasper <djasper@google.com> Don't put short namespace on a single line.

Before:
namespace abc { class SomeClass; }
namespace def { void someFunction() {} }

After:
namespace abc {
class Def;
}
namespace def {
void someFunction() {}
}

Rationale:
a) Having anything other than forward declaration on the same line
as a namespace looks confusing.
b) Formatting namespace-forward-declaration-combinations different
from other stuff is inconsistent.
c) Wasting vertical space close to such forward declarations really
does not affect readability.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181887 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5d823e3a00a3e21a0823288e6dee26a93758332b 15-May-2013 Daniel Jasper <djasper@google.com> Improve recognition of template definitions.

In the long run, this will probably be better fixed by a proper
expression parser..

Before:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c < is_base_of<F, T>::value &&
!is_same<F, T>::value > ::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}

After:
template <typename F>
Matcher(const Matcher<F> & Other,
typename enable_if_c<is_base_of<F, T>::value &&
!is_same<F, T>::value>::type * = 0)
: Implementation(new ImplicitCastMatcher<F>(Other)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181884 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
33f4b90476f24d269cac04915d951d8f05bd3a77 15-May-2013 Daniel Jasper <djasper@google.com> Break function declarations after multi-line return types.

Before:
template <typename A>
SomeLoooooooooooooooooooooongType<
typename some_namespace::SomeOtherType<A>::Type> Function() {}

After:
template <typename A>
SomeLoooooooooooooooooooooongType<
typename some_namespace::SomeOtherType<A>::Type>
Function() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181877 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9f3216199484a95fd765caa6555fd44e5c0ed1ea 15-May-2013 Daniel Jasper <djasper@google.com> Don't merge one-line functions in weird brace styles.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181872 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
caf42a3ef114900fd2ab927d1a13b4db000515e8 15-May-2013 Daniel Jasper <djasper@google.com> Remove diagnostics from clang-format.

We only ever implemented one and that one is not actually all that
helpful (e.g. gets incorrectly triggered by macros).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181871 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a8fda85af8ddc91366b5522aee3a78a1fed206f7 15-May-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types.

The function type detection in r181438 and r181764 detected function
types too eagerly. This led to inconsistent formatting of inline
assembly and (together with r181687) to an incorrect formatting of calls
in macros.

Before: #define DEREF_AND_CALL_F(parameter) f (*parameter)
After: #define DEREF_AND_CALL_F(parameter) f(*parameter)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181870 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7247c88d1e41514a41085f83ebf03dd5220e054a 15-May-2013 David Blaikie <dblaikie@gmail.com> Use only explicit bool conversion operator

The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

DiagnosticBuilder kept its implicit conversion operator owing to the
prevalent use of it in return statements.

One bug was found in ExprConstant.cpp involving a comparison of two
PointerUnions (PointerUnion did not previously have an operator==, so
instead both operands were converted to bool & then compared). A test
is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix
(adding operator== to PointerUnion in LLVM).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181869 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
d741f02da9c91c197ba8816b4b454e1ad7cd47b6 14-May-2013 Daniel Jasper <djasper@google.com> Fix expression breaking for one-parameter-per-line styles.

Before:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
After:
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181828 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9d126fb59cf4aacc8e5058c830f23ba7be1db0fe 14-May-2013 Benjamin Kramer <benny.kra@googlemail.com> Take a stab at trying to unbreak the makefile build.

There is no clangRewrite.a.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181781 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/Makefile
1ba0d65d14ba08f490d79003988c3eae71762bda 14-May-2013 Manuel Klimek <klimek@google.com> Hopefully fix configure build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181780 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Dynamic/Makefile
84f5ddfacc59c5d4878cd47b7794e53dc8e2e9f9 14-May-2013 Daniel Jasper <djasper@google.com> Correctly determine ranges for clang-format.

We have been assuming that CharSourceRange::getTokenRange() by itself
expands a range until the end of a token, but in fact it only sets
IsTokenRange to true. Thus, we have so far only considered the first
character of the last token to belong to an unwrapped line. This
did not really manifest in symptoms as all edit integrations
expand ranges to fully lines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181778 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1fb8d8814ae28a4ebe94652faafad8545a115bfe 14-May-2013 Daniel Jasper <djasper@google.com> Fix clang-format bug in unwrapped-line merging.

Before (in styles that allow it), clang-format would not merge an
if statement onto a single line, if only the second line was format
(e.g. in an editor integration):

if (a)
return; // clang-format invoked on this line.

With this patch, this gets properly merged to:

if (a) return; // ...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181770 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f7f295f321fd434e1e542844a71f538a56f2f8fb 14-May-2013 Manuel Klimek <klimek@google.com> First revision of the dynamic ASTMatcher library.

This library supports all the features of the compile-time based ASTMatcher
library, but allows the user to specify and construct the matchers at runtime.
It contains the following modules:
- A variant type, to be used by the matcher factory.
- A registry, where the matchers are indexed by name and have a factory method
with a generic signature.
- A simple matcher expression parser, that can be used to convert a matcher
expression string into actual matchers that can be used with the AST at
runtime.

Many features where omitted from this first revision to simplify this code
review. The main ideas are still represented in this change and it already has
support working use cases.
Things that are missing:
- Support for polymorphic matchers. These requires supporting code in the
registry, the marshallers and the variant type.
- Support for numbers, char and bool arguments to the matchers. This requires
supporting code in the parser and the variant type.
- A command line program putting everything together and providing an already
functional tool.

Patch by Samuel Benzaquen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181768 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.h
STMatchers/CMakeLists.txt
STMatchers/Dynamic/CMakeLists.txt
STMatchers/Dynamic/Makefile
STMatchers/Dynamic/ParserTest.cpp
STMatchers/Dynamic/RegistryTest.cpp
STMatchers/Dynamic/VariantValueTest.cpp
STMatchers/Makefile
2a9805d227375efd988522873d4edc282010baae 14-May-2013 Manuel Klimek <klimek@google.com> Implement string literal breaking on unbreakable token sequences.

This fixes indentation where there are for example multiple closing
parentheses after a string literal, and where those parentheses
run over the end of the line.

During testing this revealed a bug in the implementation of
breakProtrudingToken: we don't want to change the state if we didn't
actually do anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181767 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7424d79613a67ba200b6801468f2b59cde7ab087 14-May-2013 Daniel Jasper <djasper@google.com> Don't format sizeof/alignof as function types.

Before: A<sizeof (*x)> a;
After: A<sizeof(*x)> a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181764 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3371711aabc154acb4bffee4dc9491632379857d 14-May-2013 Patrik Hagglund <patrik.h.hagglund@ericsson.com> Replace EXPECT_EQ with EXPECT_FALSE to avoid gcc warning
[-Wconversion-null], introduced in r181326.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181761 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
27c7f54cf7d18276be2979d5c795533cc5592675 13-May-2013 Daniel Jasper <djasper@google.com> Align a multiline string literal with the first part.

Before:
#define A(X) \
"aaaaa" #X "bbbbbb" \
"ccccc"

After:
#define A(X) \
"aaaaa" #X "bbbbbb" \
"ccccc"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181732 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
44135b8836fc3ffb84e540d8a097955271ccbc23 13-May-2013 Manuel Klimek <klimek@google.com> Implements brace breaking styles.

We now support "Linux" and "Stroustrup" brace breaking styles, which
gets us one step closer to support formatting WebKit, KDE & Linux code.

Linux brace breaking style:
namespace a
{
class A
{
void f()
{
if (x) {
f();
} else {
g();
}
}
}
}

Stroustrup brace breaking style:
namespace a {
class A {
void f()
{
if (x) {
f();
} else {
g();
}
}
}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181700 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7c9a93ec7cea816e94a0674909c312f3d0227864 13-May-2013 Manuel Klimek <klimek@google.com> Implements UseTab for clang-format.

This is required for kernel linux kernel style formatting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181693 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c3df5ffb52cb656c3a4d0b4d70f8f28ed2390e78 13-May-2013 Daniel Jasper <djasper@google.com> Further improve optimization for nested calls.

Fake parentheses (i.e. emulated parentheses used to correctly handle
binary expressions) used to prevent the optimization implemented in
r180264.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181692 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
07a64eca75d96ce77d1ce8cb73d1cb0877695d06 13-May-2013 Manuel Klimek <klimek@google.com> Implements IndentWidth.

This is required for various styles that are for example based on
8-indent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181690 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
378d93dcf7ec80661efc65642dc6266c9e13780a 13-May-2013 Daniel Jasper <djasper@google.com> Assume macros to contain declarations.

This seems to be the vastly more common case. If we find enough
examples to the contrary, we can make it smarter.

Before: #define MACRO void f(int * a)
After: #define MACRO void f(int *a)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181687 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
04abbb2125272a9930cbaee6530e7754566d8e66 10-May-2013 Daniel Jasper <djasper@google.com> When breaking at function calls, indent from function name.

Otherwise (when indenting from the wrapped -> or .), this looks
like a confusing indent.

Before:
aaaaaaa //
.aaaaaaa( //
aaaaaaa);
After:
aaaaaaa //
.aaaaaaa( //
aaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181595 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
89b3a7f76ffe333aa61ab63826834883236caf96 10-May-2013 Daniel Jasper <djasper@google.com> Always format entire macro definitions.

Thereby, the macro is consistently formatted (including the trailing
escaped newlines) even if clang-format is invoked only on single lines
of the macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181590 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dd256314cf391063329e504f0ece46ee51bbfa2a 10-May-2013 Alexander Kornienko <alexfh@google.com> Config file support for clang-format, part 2.

Summary:
Adds actual config file reading to the clang-format utility.
Configuration file name is .clang-format. It is looked up for each input file
in its parent directories starting from immediate one. First found .clang-format
file is used. When using standard input, .clang-format is searched starting from
the current directory.
Added -dump-config option to easily create configuration files.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, jordan_rose, kimgr

Differential Revision: http://llvm-reviews.chandlerc.com/D758

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181589 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
acf02715ab1aa1e5a791f20e0d1ca217af256823 10-May-2013 Peter Collingbourne <peter@pcc.me.uk> Add caseStmt(), defaultStmt(), eachCase() and hasCaseConstant() matchers.

Differential Revision: http://llvm-reviews.chandlerc.com/D744

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181588 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
6ea933c7e8f6988d5647af4a0eafd393a4c3685a 10-May-2013 Daniel Jasper <djasper@google.com> Fix bug when formatting overloaded operators.

Before, the actual operator of an overloaded operator declaration was
handled as a binary operator an thus, clang-format could not find valid
formattings for many examples, e.g.:

template <typename AAAAAAA, typename BBBBBBB>
AAAAAAA operator/(const AAAAAAA &a, BBBBBBB &b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181585 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
32a6ebc63900b85780328c337787bb7adad2bcab 09-May-2013 Edwin Vane <edwin.vane@intel.com> Adding isConst() ASTMatcher for CXXMethodDecl nodes

Updated reference and unit tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181522 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
4b7b104c2c66550ecc4ebfe39225fe067858b9aa 08-May-2013 Daniel Jasper <djasper@google.com> Further fix to pointer to member formatting.

With style where the *s go with the type:
Before: typedef bool* (Class:: *Member)() const;
After: typedef bool* (Class::*Member)() const;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181439 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
395228fdc343df39c2507e414dc1406a185c6d37 08-May-2013 Daniel Jasper <djasper@google.com> Fix formatting of pointers to members.

Before: int(S::*func)(void *);
After: int (S::*func)(void *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181438 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
11e13801d8a25cea011c2a154380c371b6ddaaf6 08-May-2013 Daniel Jasper <djasper@google.com> Improve line breaking in binary expressions.

If the LHS of a binary expression is broken, clang-format should also
break after the operator as otherwise:
- The RHS can be easy to miss
- It can look as if clang-format doesn't understand operator precedence

Before:
bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !=
bbbbbbbbbbbbbbbbbb && ccccccccc == ddddddddddd;
After:
bool aaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa != bbbbbbbbbbbbbbbbbb &&
ccccccccc == ddddddddddd;

As an additional note, clang-format would also be ok with the following
formatting, it just has a higher penalty (IMO correctly so).
bool aaaaaaaaaaaaaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa !=
bbbbbbbbbbbbbbbbbb &&
ccccccccc == ddddddddddd;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181430 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b2f063aeb93670c2415825be457b9e518a9fefdf 08-May-2013 Daniel Jasper <djasper@google.com> Change indentation of multi-line nested name specifiers.

Before:
aaaaaaaa::
aaaaaaaa::
aaaaaaaa();
After:
aaaaaaaa::
aaaaaaaa::
aaaaaaaa();

The reason for the change is that:
a) we are not sure which is better
b) it is a really rare edge case
c) it simplifies the code
d) it currently causes problems with memoization

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181421 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d71ec16fffd10879bf74e531d9f7fb4c5ac4eaf8 07-May-2013 Alexander Kornienko <alexfh@google.com> Config file support for clang-format, part 1.

Summary:
Added parseConfiguration method, which reads FormatStyle from YAML
string. This supports all FormatStyle fields and an additional BasedOnStyle
field, which can be used to specify base style.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D754

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181326 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dbef71ebc66fe5553db01eb8e95b696c3223e737 07-May-2013 Daniel Jasper <djasper@google.com> Correctly recognize dereference after 'delete'.

With certain styles:
Before: delete* x;
After: delete *x;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181318 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7ff96ed7336b4f0efef05c10fd5ce5143918d4e1 06-May-2013 Daniel Jasper <djasper@google.com> Don't break comments after includes.

LLVM/Clang basically don't use such comments and for Google-style,
include-lines are explicitly exempt from the column limit. Also, for
most cases, where the column limit is violated, the "better" solution
would be to move the comment to before the include, which clang-format
cannot do (yet).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181191 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
53e72cdcc0bc217cab33fa56858a0fe5b94ca453 06-May-2013 Daniel Jasper <djasper@google.com> Change indentation when breaking after a type.

clang-format did not indent any declarations/definitions when breaking
after the type. With this change, it indents for all declarations but
does not indent for function definitions, i.e.:

Before:
const SomeLongTypeName&
some_long_variable_name;
typedef SomeLongTypeName
SomeLongTypeAlias;
const SomeLongReturnType*
SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

After:
const SomeLongTypeName&
some_long_variable_name;
typedef SomeLongTypeName
SomeLongTypeAlias;
const SomeLongReturnType*
SomeLongFunctionName();
const SomeLongReturnType*
SomeLongFunctionName() { ... }

While it might seem inconsistent to indent function declarations, but
not definitions, there are two reasons for that:
- Function declarations are very similar to declarations of function
type variables, so there is another side to consistency to consider.
- There can be many function declarations on subsequent lines and not
indenting can make them harder to identify. Function definitions
are already separated by their body and not indenting
makes the function name slighly easier to find.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181187 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c194c95036b7bf1281a6f2ed683f7c85ee5d2c20 06-May-2013 Daniel Jasper <djasper@google.com> Break the class-inheritance ":" to the new line.

This seems to be more common in LLVM, Google and Chromium.

Before:
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA :
public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {
};

After:
class AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
: public BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
public CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC {
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181183 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f022018698ced7e538b338d4f7befef9f81051ea 06-May-2013 Daniel Jasper <djasper@google.com> Don't put a space before ellipsis.

Before: template <class ... Ts> void Foo(Ts ... ts) { Foo(ts ...); }
After: template <class... Ts> void Foo(Ts... ts) { Foo(ts...); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181182 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ad6fd9f93ce0d328397e8d57ef7117ced24fc8e2 04-May-2013 Fariborz Jahanian <fjahanian@apple.com> [Doc parsing] Provide diagnostics for unknown documentation
commands. // rdar://12381408


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181071 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
dd08a0c178329ec16cb9e494e6880f3991708b93 04-May-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [Preprocessor] For the MacroExpands preprocessor callback, also pass the MacroArgs object that provides information about
the argument tokens for a function macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181065 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
454cb70f9470dc37d0c0646012877d64fb1e73d7 03-May-2013 Daniel Jasper <djasper@google.com> Add space between ; and (.

Before: for (int i = 0;(i < 10); ++i) {}
After: for (int i = 0; (i < 10); ++i) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181020 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
16a69ef481f4580c571b6c693a5d3dd64ea56b53 03-May-2013 Daniel Jasper <djasper@google.com> Fix expression recognition in for-loops.

Before: for (; a&& b;) {}
After: for (; a && b;) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181017 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9b1317531d376738fd6631291b0a04109c76a63b 30-Apr-2013 Richard Smith <richard-llvm@metafoo.co.uk> When deducing an 'auto' type, don't modify the type-as-written.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180808 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
fca24bc45192c254ca92ef1d7cef71a290392f31 25-Apr-2013 Daniel Jasper <djasper@google.com> Improve clang-format's memoization behavior.

Deeply nested expressions basically break clang-format's memoization.
This patch slightly improves the situations and makes expressions like

aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(aaaaa(
aaaaa(aaaaa())))))))))))))))))))))))))))))))))))))));

work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180264 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2972d049637349bb82f52a27ad3337cf4ab769b4 25-Apr-2013 Daniel Jasper <djasper@google.com> Add option to align escaped newlines left.

This enables formattings like:

#define A \
int aaaa; \
int b; \
int ccc; \
int dddddddddd;

Enabling this for Google/Chromium styles only as I don't know whether it
is desired for Clang/LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180253 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
af8497681e38106ad6f84408e029537e2a13d79d 24-Apr-2013 Daniel Jasper <djasper@google.com> Fix comment alignment behavior.

In the following snippet, clang-format incorrectly aligned the
trailing comment, when only the last line was formatted:

int aaaaaa; // comment
int b;
int c; // Formatting only this line moved this comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180173 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aae7bad5cdd804cb88e918e9defbf5faf69f4cfd 23-Apr-2013 Daniel Jasper <djasper@google.com> Fix formatting of complex #if expressions.

Before:
#if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC || \
defined DDDDDDDD) && defined(BBBBBBBB)

After:
#if !defined(AAAAAAAAAAAAAAAA) && (defined CCCCCCCC || defined DDDDDDDD) && \
defined(BBBBBBBB)

This fixes llvm.org/PR15828.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180105 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
001bf4e2bedfc6bc6a7638c098a004e4d57e308f 22-Apr-2013 Daniel Jasper <djasper@google.com> Fix bin-packing behavior of constructor initialziers.

In Google style, constructor initializers need to be all on one line or
one initializer per line if that does not fit. Without this patch, this
non-bin-packing-behavior incorrectly extends to the parameters of the
initializers.

Before:
Constructor()
: aaaaa(aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa) {}

After:
Constructor()
: aaaaa(aaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@180001 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
919398bb40d5d643f38b6595f5e8eac641e89d50 17-Apr-2013 Alexander Kornienko <alexfh@google.com> Unified token breaking logic: support for line comments.

Summary:
Added BreakableLineComment, moved common code from
BreakableBlockComment to newly added BreakableComment. As a side-effect of the
rewrite, found another problem with escaped newlines and had to change
code which removes trailing whitespace from line comments not to break after
this patch.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D682

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179693 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
01218ffddc239a71951035d6c7698a11e323efe3 16-Apr-2013 Daniel Jasper <djasper@google.com> Break after multiline parameters.

We do this in general, but missed a few cases.

Before:
void aaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbb bbbb);

After:
void aaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
bbbb bbbb);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179570 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
70ce7881fc30a39b795b2873f008e7eca72ba669 15-Apr-2013 Alexander Kornienko <alexfh@google.com> Unified token breaking logic for strings and block comments.

Summary:
Both strings and block comments are broken into lines in
breakProtrudingToken. Logic specific for strings or block comments is abstracted
in implementations of the BreakToken interface. Among other goodness, this
change fixes placement of backslashes after a block comment inside a
preprocessor directive (see removed FIXMEs in unit tests).

The code is far from being polished, and some parts of it will be changed for
line comments support.

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D665

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179526 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
67d080dafa74c7d126da522fec333a6e52a5ae35 12-Apr-2013 Manuel Klimek <klimek@google.com> Revamps structural error detection / handling.

Previously we'd only detect structural errors on the very first level.
This leads to incorrectly balanced braces not being discovered, and thus
incorrect indentation.

This change fixes the problem by:
- changing the parser to use an error state that can be detected
anywhere inside the productions, for example if we get an eof on
SOME_MACRO({ some block <eof>
- previously we'd never break lines when we discovered a structural
error; now we break even in the case of a structural error if there
are two unwrapped lines within the same line; thus,
void f() { while (true) { g(); y(); } }
will still be re-formatted, even if there's missing braces somewhere
in the file
- still exclude macro definitions from generating structural error;
macro definitions are inbalanced snippets

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179379 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1407bee187d7b964d5293ac8bf4f7a490c78cec6 11-Apr-2013 Daniel Jasper <djasper@google.com> Change clang-format's affinity for breaking after return types.

Function declarations are now broken with the following preferences:
1) break amongst arguments.
2) break after return type.
3) break after (.
4) break before after nested name specifiers.

Options #2 or #3 are preferred over #1 only if a substantial number of
lines can be saved by that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179287 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2eb23b73f001e475c604652732f1a156f252352d 11-Apr-2013 Daniel Jasper <djasper@google.com> Fix formatting of overloaded assignment operators.

Before: SomeType &operator=(const SomeType & S);
After: SomeType &operator=(const SomeType &S);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179270 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
423dd93c8011aa8bca9b761b0b121ea8bce0fd03 10-Apr-2013 Manuel Klimek <klimek@google.com> Fixes recovering from errors when parsing braced init lists.

Before we would build huge unwrapped lines which take a long time
to optimze.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179168 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ac3223e45e7d17c65b143439313800eef4fdf71d 10-Apr-2013 Daniel Jasper <djasper@google.com> Fix labels with trailing comments and cleanup.

Before:
class A {
public : // test
};

After:
class A {
public: // test
};

Also remove duplicate methods calculating properties of AnnotatedTokens
and make them members of AnnotatedTokens so that they are in a common
place.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179167 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5771a2f0830228ac50e3473740e24d9dca67b54f 09-Apr-2013 Edwin Vane <edwin.vane@intel.com> Adding new AST Matchers isVirtual and isOverride

isVirtual - matches CXXMethodDecl nodes for virtual methods
isOverride - matches CXXMethodDecl nodes for methods that override virtual methods from a base class.

Author: Philip Dunstan <phil@philipdunstan.com>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179126 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
5999f7634e80daf849a036aa830fc0e4b1e03555 09-Apr-2013 Daniel Jasper <djasper@google.com> Fix comments before labels.

Before:
switch (...) {
// a
// b
// c
case first:
break;
}

After:
switch (...) {
// a
// b
// c
case first:
break;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179107 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
99b0e14691b61d8db4f1d239a11615957071fb45 09-Apr-2013 Alexander Kornienko <alexfh@google.com> Again macros without trailing semicolons: don't care about declaration context.

Summary:
Some codebases use these kinds of macros in functions, e.g. Chromium's
IPC_BEGIN_MESSAGE_MAP, IPC_BEGIN_MESSAGE_HANDLER, etc.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D645

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179099 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3d713a72a01bf1d270d00040a3fb195121012c61 09-Apr-2013 Alexander Kornienko <alexfh@google.com> Recognize function-like macro usages without semicolon in declaration context.

Summary:
Preserve line breaks after function-like macro usages without
semicolon, e.g.:

QQQ(xxx)
class X {
};

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D638

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179064 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bf71ba2988b34c45af968f0965e28ac952e4a15f 08-Apr-2013 Daniel Jasper <djasper@google.com> Revamp indentation behavior for complex binary expressions.

The idea is to indent according to operator precedence and pretty much
identical to how stuff would be indented with parenthesis.

Before:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;

After:
bool value = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa >
ccccccccccccccccccccccccccccccccccccccccc;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179049 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
abe922342d67d4ffe05b366a5a2af972185272f8 08-Apr-2013 Daniel Jasper <djasper@google.com> Add matcher for NamespaceDecls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179027 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
65622aae92ff6e338abed83d31e512ee0e013dc7 08-Apr-2013 Daniel Jasper <djasper@google.com> Revert accidental commit r179015.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179016 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c4ff76913ada469a70ed4bd960aeff038b6c2e1b 08-Apr-2013 Daniel Jasper <djasper@google.com> x

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179015 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8aa86d1155fb99e34fd084d83da3345b1ec2b2e4 05-Apr-2013 Tanya Lattner <tonic@nondot.org> Add an error to check that all program scope variables are in the constant address space in OpenCL.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178906 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
6b119d63f5036344acd4e00a6ff2b3c72f26966f 05-Apr-2013 Daniel Jasper <djasper@google.com> Allow breaking after 'class' for classes with looong names.

(Don't ask, this was a user request).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178888 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
27b91cc046f580fbe825f15b3e27f1b6407ee3e3 05-Apr-2013 Daniel Jasper <djasper@google.com> Fix bad formatting of overloaded operator definitions.

Before:
bool operator<
(const aaaaaaaaaaaaaaaaaaaaa &left, const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}

After:
bool operator<(const aaaaaaaaaaaaaaaaaaaaa &left,
const aaaaaaaaaaaaaaaaaaaaa &right) {
return left.group < right.group;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178887 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
adc0f09585f10061007ec529451a6dd10f86fea6 05-Apr-2013 Daniel Jasper <djasper@google.com> Improve formatting of multi-variable DeclStmts.

This fixed llvm.org/PR15670

Before:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
c = cccccccccccccccccccc,
d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
*c = ccccccccccccccccccc,
*d = ddddddddddddddddddd;

After:
aaaaaaaaa a = aaaaaaaaaaaaaaaaaaaa, b = bbbbbbbbbbbbbbbbbbbb,
c = cccccccccccccccccccc, d = dddddddddddddddddddd;
aaaaaaaaa *a = aaaaaaaaaaaaaaaaaaa, *b = bbbbbbbbbbbbbbbbbbb,
*c = ccccccccccccccccccc, *d = ddddddddddddddddddd;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178860 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8ed9f2b25f082a1643ab5310f9eec33cf31a7577 03-Apr-2013 Daniel Jasper <djasper@google.com> Improve formatting of for loops and multi-variable DeclStmts.

This combines several related changes:
a) Don't break before after the variable types in for loops with a
single variable.
b) Better indent DeclStmts defining multiple variables.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaa = aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaa =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaa),
bbbbbbbbbbbbbbbbbbbbbbbbb =
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(bbbbbbbbbbbbbbbb);
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa =
aaaaaaaaaaaaaaaa.aaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178641 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4128e19d6f3ae42e840bc6aaf6ce6d052a46f7e4 03-Apr-2013 Alexander Kornienko <alexfh@google.com> Even better way to handle comments adjacent to preprocessor directives.

Summary:
It turns out that we don't need to store CommentsBeforeNextToken in the
line state, but rather flush them before we start parsing preprocessor
directives. This fixes wrong comment indentation in code blocks in macro calls
(the test is included).

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D617

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178638 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7b69cd09440976d6b93a0db661a770b2337be8d2 02-Apr-2013 Edwin Vane <edwin.vane@intel.com> Adding a hasLocalQualifiers() AST Matcher.

Updated tests and docs.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178556 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
3791130df5ad83e4a9872f90cc9675e90b772f88 02-Apr-2013 Daniel Jasper <djasper@google.com> Fix some inconsistent use of indentation.

Basically we have always special-cased the top-level statement of an
unwrapped line (the one with ParenLevel == 0) and that lead to several
inconsistencies. All added tests were formatted in a strange way, for
example:

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();
if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178542 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f52d52790708132cc1a3b5c3aef1bed17eb6ff13 02-Apr-2013 Alexander Kornienko <alexfh@google.com> Alternative handling of comments adjacent to preprocessor directives.

Summary: Store comments in ScopedLineState

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D609

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178537 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
88be2fdec7a1375bc729a6499629532e7872f11a 01-Apr-2013 Edwin Vane <edwin.vane@intel.com> Adding parenType() and innerType() AST Matchers

Updated docs and tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178487 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
81d2d38d2d774a2550fa0d2efffa707e7a53b39c 01-Apr-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types.

Before: void * (*a)(int *, SomeType *);
After: void *(*a)(int *, SomeType *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178474 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9fdc00a237fe19b892f22780321ddfd1a3691d61 28-Mar-2013 Alexander Kornienko <alexfh@google.com> Fixed handling of comments before preprocessor directives.

Comments before preprocessor directives used to be stored with InPPDirective
flag set, which prevented correct comment splitting in this case. Fixed by
flushing comments before switching on InPPDirective. Added a new test and fixed
one of the existing tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178261 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
94b748ff16172f0da2b842fe0d5bae438f07034f 27-Mar-2013 Alexander Kornienko <alexfh@google.com> Insert extra new line before access specifiers.

Summary: Insert extra new line before access specifiers.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D581

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178149 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5262dd909a34f4c3e3f061009679fabb77b43ba4 27-Mar-2013 Alexander Kornienko <alexfh@google.com> Split line comments

Summary:
Split line comments that exceed column limit + fixed leading whitespace
handling when splitting block comments.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D577

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178133 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
627707b9360597b65a9a0953d0ead2a08c3a0d5d 22-Mar-2013 Daniel Jasper <djasper@google.com> Better fix for r177725.

It turns out that

-foo;

can be an objective C method declaration. So instead of the previous
solution, recognize objective C methods only if we are in a declaration
scope.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177740 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c363dbb204b6c77b67dfed030436643947b37cbd 22-Mar-2013 Daniel Jasper <djasper@google.com> Align comments to surrounding unformatted comments.

Before:
int a; // not formatted
// formatting this line only

After:
int a; // not formatted
// formatting this line only

This makes clang-format stable independent of whether the whole
file or single lines are formatted in most cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177739 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b5985420d5910e068b0c8b84b8af2223e6bdf130 22-Mar-2013 Daniel Jasper <djasper@google.com> More precisely recognize ObjC method declarations.

Otherwise, +/- and the beginning of constants can be recognized
incorrectly.

Before: #define A - 1
After: #define A -1

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177725 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b64eca09dd3bcd18eb1a5cca2b123b169340bdd5 22-Mar-2013 Daniel Jasper <djasper@google.com> Make clang-format understand more line comments.

Apparently one needs to set LangOptions.LineComment.

Before "//* */" got reformatted to "/ /* */" as the lexer was returning
the token sequence (slash, comment). This could also lead to weird other
stuff, e.g. for people that like to using comments like:
//****************

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177720 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7c22cf340995ab9107810aa39a190db3e0332294 21-Mar-2013 Alexander Kornienko <alexfh@google.com> Better block comment formatting.

Summary:
1. When splitting one-line block comment, use indentation and *s.
2. Remove trailing whitespace from all lines of a comment, not only the ones being splitted.
3. Add backslashes for all lines if a comment is used insed a preprocessor directive.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D557

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177635 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
906d66acc5cf2679453e10a4f0a67feedd765b21 20-Mar-2013 Douglas Gregor <dgregor@apple.com> <rdar://problem/12368093> Extend module maps with a 'conflict' declaration, and warn when a newly-imported module conflicts with an already-imported module.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177577 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
54a38bd5cf243310290f34b43fc940a498a00f90 20-Mar-2013 Alexander Kornienko <alexfh@google.com> Support for pointers-to-members usage via .*

Summary: Added support for pointers-to-members usage via .* and a few tests.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D556

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177537 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
92f9faf3cf1065f987f227e0c2fdf06fcccf1ae8 20-Mar-2013 Daniel Jasper <djasper@google.com> Remove assertion that can be triggered on bad input.

clang-format can't do anything useful, so it should leave the remainder
of the line unchanged, but it should not assert/segfault.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177530 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6fe554eb4e7075cbfda927c4747d7346a27637f1 20-Mar-2013 Daniel Jasper <djasper@google.com> Fix infinite-loop in unwrapped line parser.

Discovered when accidentally formatting a python file :-).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177527 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
83a90e5e6525acdb8cc4778ed102cd3952559f15 20-Mar-2013 Daniel Jasper <djasper@google.com> Do not consider comments when adjusting to local indent style.

Before (when only reformatting "int b"):
int a; // comment
// comment
int b;

After:
int a; // comment
// comment
int b;

This also fixes llvm.org/PR15433.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177524 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
64f092865c01c72ecb9e380432e241f3af55c249 20-Mar-2013 Daniel Jasper <djasper@google.com> Reduce penalty for breaks after "(" for functions with parameters.

Before:
aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177521 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f9955d309d3de328e65563baf2d34571249dccbb 20-Mar-2013 Daniel Jasper <djasper@google.com> Add extra indentation for multiline comparisons.

This seems to be generally more desired.

Before:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}
After:
if (aaaaaaaa &&
bbbbbbbb >
cccccccc) {}

Also: Some formatting cleanup on clang-format's files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177514 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bcca7e484117f3155ff98f9560996e760ca4f786 20-Mar-2013 Daniel Jasper <djasper@google.com> Don't remove all indentation when in #defines.

Otherwise, this can become hard to read.

Before: #define A \
case 1:
After: #define A \
case 1:

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177509 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9322aaee900b872c98f8fc10b38a231cb1e9b57a 20-Mar-2013 Daniel Jasper <djasper@google.com> Improve formatting of function types in template parameters.

Before: A<int * (int)>;
After: A<int *(int)>;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177505 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c30eb51b639e132af458fbf7647eefae6edb93ac 19-Mar-2013 Daniel Jasper <djasper@google.com> Fix indentation for case: // comment.

Before:
switch (x) {
case 1:
// Do amazing stuff
{
g();
f();
}
}

After:
switch (x) {
case 1:
// Do amazing stuff
{
g();
f();
}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177420 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
052685c170fcc4fa057c68a44425e6d9b945a167 19-Mar-2013 Alexander Kornienko <alexfh@google.com> Split long lines in multi-line comments.

Summary: This is implementation for /* */ comments only.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D547

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177415 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cf6d76af806f7e1ba97be7b72b31bc78b919e0f0 18-Mar-2013 Daniel Jasper <djasper@google.com> Fix clang-format segfault.

When annotating "lines" starting with ":", clang-format would segfault.
This could actually happen in valid code, e.g.
#define A :

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177283 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3af59ce065310fd3d0820a6e2644d4ca688be810 15-Mar-2013 Daniel Jasper <djasper@google.com> Improve formatting of chained calls.

clang-format already prevented sequences like:
...
SomeParameter).someFunction(
...

as those are quite confusing. This failed on:
...
SomeParameter).someFunction(otherFunction(
...

Fixed in this patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177157 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1fdd8b351e28ee175157e61dac1b3f62b79b7a62 15-Mar-2013 Alexander Kornienko <alexfh@google.com> Indent all lines in a multi-line comment by the same amount.

Summary:
Do this to avoid spoling nicely formatted multi-line comments (e.g.
with code examples or similar stuff).

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D544

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177153 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
374516c8ec4f0fcf5a8b65ef9cf029f862d11096 14-Mar-2013 Manuel Klimek <klimek@google.com> Implements memoization for ancestor matching.

This yields a log(#ast_nodes) worst-case improvement with matchers like
stmt(unless(hasAncestor(...))).

Also made the order of visitation for ancestor matches BFS, as the most
common use cases (for example finding the closest enclosing function
definition) rely on that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177081 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
f753615897c86928517e48e4d106e669d59618c5 14-Mar-2013 Alexander Kornienko <alexfh@google.com> Multi-line comment alignment

Summary:
Aligns continuation lines of multi-line comments to the base
indentation level +1:
class A {
/*
* test
*/
void f() {}
};

The first revision is work in progress. The implementation is not yet complete.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D541

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177080 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bfa1edd8247b80e951a570ff2486fe5fa9898c41 14-Mar-2013 Daniel Jasper <djasper@google.com> Slightly improve formatting of longer pipe statements.

The stronger binding of a string ending in :/= does not really make
sense if it is the only character.

Before:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa
<< "=" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

After:
llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << "="
<< bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177075 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
923ebef120a37122ce50722a85cbe42c0c2dab53 14-Mar-2013 Daniel Jasper <djasper@google.com> Basic support for formatting asm() statments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177073 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d3cf17b5f1fed43dbd0cd35c43d15139803c9c84 14-Mar-2013 Daniel Jasper <djasper@google.com> Fix dereference formatting in for-loops.

Before: for (char **a = b; * a; ++a) {}
After: for (char **a = b; *a; ++a) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177037 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8ef19a22956defa392df46c79e2d499ab7b16647 14-Mar-2013 Daniel Jasper <djasper@google.com> Improve formatting of trailing annotations.

Before:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa __attribute__((
unused));

After:
bool aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
__attribute__((unused));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177034 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6a365aaa057a8c445d25344c0433726c752b3e7d 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix incorrect cast identification.

Before: int a = sizeof(int *)+ b;"
After: int a = sizeof(int *) + b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176957 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6050a1e53aa3cd3b21d65d440413af5a5ac1d466 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix comment indentation before labels.

Before:
switch (x) {
// if 1, do f()
case 1:
f();
}

After:
switch (x) {
// if 1, do f()
case 1:
f();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176953 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8d0d19aa33751d89390e6a2bb2c2b19def287abe 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix formatting issue with builder-type calls.

Before:
->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() - aaaaaaaaa()->aaaaaa()
->aaaaa());

After:
a->aaaaaa()->aaaaaaaaaaa(aaaaaaaa()->aaaaaa()->aaaaa() -
aaaaaaaaa()->aaaaaa()->aaaaa());

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176952 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6f21a988990ff5872822dcb049bd8fc65ce3d236 13-Mar-2013 Daniel Jasper <djasper@google.com> Fix formatting of new arrays of pointers.

Before:
A = new SomeType * [Length];
A = new SomeType *[Length]();

After:
A = new SomeType *[Length];
A = new SomeType *[Length]();

Small formatting cleanups with clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176936 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3fd9ccdd9f8d259bcf518e7056cfd419d992e984 12-Mar-2013 Alexander Kornienko <alexfh@google.com> Implemented formatting of rvalue references

Summary:
Handle "&&" usage as rvalue reference, added tests and fixed incorrect
tests that interfere with this feature.

http://llvm.org/bugs/show_bug.cgi?id=15051

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D531

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176874 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4ba9bfd89d0ceb4eae161a4a21dd8e50be752754 12-Mar-2013 Daniel Jasper <djasper@google.com> Remove bad space after "default".

Before:
switch (x) {
default : {}
}

After:
switch (x) {
default: {}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176861 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aa62d0c4fc9449d4c438fe200ef329b067c037c7 08-Mar-2013 Manuel Klimek <klimek@google.com> Fixes breaking of string literals.

1. We now ignore all non-default string literals, including raw
literals.
2. We do not break inside escape sequences any more.

FIXME: We still break in trigraphs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176710 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f302354a7d1a63186fb0d9aa600ce3257be1f690 07-Mar-2013 Daniel Jasper <djasper@google.com> Remove unncessary whitespace when triggered on empty line.

With the cursor located at "I", clang-format would not do anything to:

int a;

I

int b;

With this patch, it reduces the number of empty lines as necessary, and
removes unnecessary whitespace. It does not change/reformat "int a;" or
"int b;".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176650 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f4b48042724d2253d0426cadcb93e24eeb47e264 07-Mar-2013 Edwin Vane <edwin.vane@intel.com> Adding lvalue and rvalue reference type matchers

Updated docs and tests.

Reviewers: klimek, gribozavr


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176630 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
6a19a97e57c8678adb0505a07c97d7ccadc8fe4e 06-Mar-2013 Edwin Vane <edwin.vane@intel.com> New ASTMatchers and enhancement to hasOverloadedOperatorName

Added two new narrowing matchers:
* hasMethod: aplies a matcher to a CXXRecordDecl's methods until a match is made
or there are no more methods.
* hasCanonicalType: applies a matcher to a QualType's canonicalType.

Enhanced hasOverloadedOperatorName to work on CXXMethodDecl as well as
CXXOperatorCallExpr.

Updated tests and docs.

Reviewers: klimek, gribozavr


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176556 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
808383d2d6d58a7c7db85f8c7618fb74d821309f 05-Mar-2013 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: refactor handling of command markers in AST

* Use the term 'command marker', because the semantics of 'backslash' and 'at'
commands are the same. (Talking about 'at commands' makes them look like a
special entity.)

* Sink the flag down into bitfields, reducing the size of AST nodes.

* Change the flag into an enum for clarity. Boolean function parameters are
not very clear.

* Add unittests for new tok::at_command tokens.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176461 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
0090591e505637cf2d9ea3b45768334d78d24ca2 04-Mar-2013 Manuel Klimek <klimek@google.com> Make sure to not split string literals at the first character.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176447 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aec89ac22e1876bb1cfff9062c882a622bc84510 04-Mar-2013 Edwin Vane <edwin.vane@intel.com> hasQualifer() matcher should return false if there's no qualifier

Instead of passing NULL on to sub-matcher, just return false. Updated tests and
regenerated docs.

Author: Tareq A Siraj <tareq.a.siraj@intel.com>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176441 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
1eee6c4269af28eb4e3500de7fc39c1eb8b26aa3 04-Mar-2013 Daniel Jasper <djasper@google.com> Format a line if a range in its leading whitespace was selected.

With [] marking the selected range, clang-format invoked on

[ ] int a;

Would so far not reformat anything. With this patch, it formats a
line if its leading whitespace is touched.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176435 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b88d9480e04039188c39e49367cb13d64e644cf8 02-Mar-2013 Peter Collingbourne <peter@pcc.me.uk> CommandLineArgumentParser: handle single quotes.

Differential Revision: http://llvm-reviews.chandlerc.com/D482

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176404 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
8536fa14ee1048e5e2d62cb3dc11fc640c7dc00d 02-Mar-2013 Fariborz Jahanian <fjahanian@apple.com> Some refactoring in my patch on document
command source fidelity. // rdar://13066276



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176401 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
516fb31d0536040334032e2af6b62cd6a5479d1c 01-Mar-2013 Daniel Jasper <djasper@google.com> Remove whitespace at end of file.

This fixes the rest of llvm.org/PR15062.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176361 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8a5d7cd100ebfb8c6b353ee4ad5b14ab4105d32d 01-Mar-2013 Daniel Jasper <djasper@google.com> Correctly format arrays of pointers and function types.

Before:
void f(Type(*parameter)[10]) {}
int(*func)(void *);

After:
void f(Type (*parameter)[10]) {}
int (*func)(void *);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176356 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
248497199bc56e86d1c089beb9529f3b3d77abb1 01-Mar-2013 Daniel Jasper <djasper@google.com> Normal indent for last element of builder-type call.

In builder type call, we indent to the laster function calls.
However, for the last element of such a call, we don't need to do
so, as that normally just wastes space and does not increase
readability.

Before:
aaaaaa->aaaaaa->aaaaaa( // break
aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa
->aaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaa->aaaaaa->aaaaaa( // break
aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176352 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
812c045e591495b940f5a9102b146bb43b970e1f 01-Mar-2013 Daniel Jasper <djasper@google.com> Remove trailing whitespace of line comments.

This fixed llvm.org/PR15378.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176351 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bc30c71d20f05bc39b5dd73f06ee4dede9c55710 01-Mar-2013 Manuel Klimek <klimek@google.com> Implements breaking string literals at slashes.

We now break at a slash if we do not find a space to break on.

Also fixes a bug where we would go over the limit when breaking the
second line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176350 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
af31fd7021e685280da9155e5017f1053b05fdf8 01-Mar-2013 Manuel Klimek <klimek@google.com> Implement fallback split point for string literals.

If we don't find a natural split point (currently space) in a string
literal protruding over the line, we just split at the last possible
point.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176349 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
25e81b255cea00fe633f2822c1d1d708ef871a59 28-Feb-2013 Daniel Jasper <djasper@google.com> Reduce penalty for splitting after "{" in static initializers.

This fixes llvm.org/PR15379.

Before:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = { 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00,
0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};

After:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
0x00, 0x00, 0x00, 0x00 // comment
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176262 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8ed4100410ea055a03be5ec4a92a947a0ee664cd 28-Feb-2013 Daniel Jasper <djasper@google.com> Dont break between (( in __attribute__((.

Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
(aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));

After:
void aaaaaaaaaaaaaaaaaa()
__attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaa));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176260 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9c3c7b3130bc72b3f50703c11b85152b1264fc90 28-Feb-2013 Daniel Jasper <djasper@google.com> No spaces around pointers to members.

Before: (a ->* f)()
After: (a->*f)()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176252 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ff9a01000ff74a994aa3da26ea2ec732c97291b7 28-Feb-2013 Manuel Klimek <klimek@google.com> First step towards adding a parent map to the ASTContext.

This does not yet implement the LimitNode approach discussed.

The impact of this is an O(n) in the number of nodes in the AST
reduction of complexity for certain kinds of matchers (as otherwise the
parent map gets recreated for every new MatchFinder).

See FIXMEs in the comments for the direction of future work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176251 91177308-0d34-0410-b5e6-96231b3b80d8
ST/ASTContextParentMapTest.cpp
ST/CMakeLists.txt
ST/MatchVerifier.h
a4d4621b206f941cc58d9d0bc7c67a8e705c9d49 28-Feb-2013 Daniel Jasper <djasper@google.com> Improve formatting of #defines.

Two improvements:
1) Always leave at least one space before "\". Otherwise is can look bad
and there is a risk of unwillingly joining to characters to a different
token.
2) Use the full column limit for single-line #defines.
Fixes llvm.org/PR15148

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176245 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b6f02f3bcb5ddcd7c7f1a3571d554fe55c72968f 28-Feb-2013 Daniel Jasper <djasper@google.com> Fix bug when formatting "A<A<A>>".

Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaa);
Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
int aaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176244 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3a39ac7cee044cf7d9b524b529a97d5f075ee695 28-Feb-2013 Daniel Jasper <djasper@google.com> Fix incorrect recognition of bin-packing.

Before (in Google style):
Constructor()
: aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(
aaaaaa) {}

After:
Constructor()
: aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa),
aaaaa(aaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176242 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
807809c421811509f488f3ebd249585025ad918a 28-Feb-2013 Daniel Jasper <djasper@google.com> Fix spacing after binary operator as macro parameter.

Before: COMPARE(a, == , b);
After: COMPARE(a, ==, b);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176241 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0cc798f29d489140dd81b558e9c052e9a83cce39 27-Feb-2013 Manuel Klimek <klimek@google.com> Make the negative test of recordType depend on a specific record.

Otherwise it'll break if there's a record type in the AST by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176181 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
9c65b069821b7de79427e291b006293a0f55ff8f 27-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting of multiplications in array subscripts.

Before:
a[a* a] = 1;

After:
a[a * a] = 1;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176180 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
faab0d35da240bde26a6281ed1cfa14c44585a5a 27-Feb-2013 Daniel Jasper <djasper@google.com> Enable bin-packing in Google style.

After some discussions, it seems that this is the better path in
the long run. Does not change Chromium style, as there, bin packing
is forbidden by the style guide.

Also fix two minor bugs wrt. formatting:
1. If a call parameter is a function call itself and is split before
the "." or "->", split before the next parameter.
2. If a call parameter is string literal that has to be split onto
two lines, split before the next parameter.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176177 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
518ee34467c0722e253a58efea20456e96aa5802 26-Feb-2013 Daniel Jasper <djasper@google.com> Fix bad line break decision.

Before:
if (Intervals[i].getRange().getFirst() < Intervals[i - 1]
.getRange().getLast()) {}

After:
if (Intervals[i].getRange().getFirst() <
Intervals[i - 1].getRange().getLast()) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176092 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
84a1a63b034744b68a27ec171dca5b1b7cf303f0 26-Feb-2013 Daniel Jasper <djasper@google.com> In range-based for-loops, prefer splitting after ":".

Before:
for (const aaaaaaaaaaaaaaaaaaaaa &
aaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

After:
for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa :
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176087 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1ef81d57fbcc26080c98e140e7c82db6d2aeba87 26-Feb-2013 Daniel Jasper <djasper@google.com> Only keep empty lines in unwrapped lines if they preceed a line comment.

Empty lines followed by line comments are often used to highlight the
comment. Empty lines somewhere else are usually left over from manual or
automatic formatting and should probably be removed.

Before (clang-format would keep):
S s = {
a,

b
};

After:
S s = { a, b };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176086 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0fb382bfbfbfee73763a213b2257042ed342c4b0 26-Feb-2013 Daniel Jasper <djasper@google.com> Only break string literals as a last resort.

We might want to move towards doing this if the formatting can be
significantly improved, but we need to carefully evaluate the different
situations first.

Before (the string literal was split by clang-format here):
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa "
"aaaaa aaa aaa aaaaaa"));

After:
aaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaa,
aaaaaa("aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa"));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176084 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
742d9e77e32f014194679575c97c6bb4fd0998c4 25-Feb-2013 Edwin Vane <edwin.vane@intel.com> Various additions to ASTMatcher library:

New type matchers:
* recordType
* elaboratedType

New narrowing matchers:
* hasQualifier
* namesType
* hasDeclContext

Added tests and updated LibASTMatchersReference.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176047 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
9c3e71acb53a67f305a54f3d6d6decb143acaae4 25-Feb-2013 Daniel Jasper <djasper@google.com> Re-add hack that caused regression.

This fixes llvm.org/PR15350.

Before:
Constructor(int Parameter = 0)
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

After:
Constructor(int Parameter = 0)
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),
aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}

I think the correct solution is to put the VariablePos into
ParenState, not LineState. Added FIXME.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176027 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3abf77872ca6c520903f9174cf6cd89a50df2714 25-Feb-2013 Edwin Vane <edwin.vane@intel.com> Adding hasDeclaration overload for TemplateSpecializationType

TemplateSpecializationType doesn't quite have getDecl(). Need to go
through TemplateName to get a TemplateDecl.

Added test cases for the hasDeclaration() overload for
TemplateSpecializationType. Also introduced the type matcher
templateSpecializationType() used by the new hasDeclaration() test case.

Updated LibASTMatchersReference.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176025 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
b45083d08377a8b9528401fdafd7210e78895dbe 25-Feb-2013 Edwin Vane <edwin.vane@intel.com> Support in hasDeclaration for types with getDecl()

Re-introducing r175532. The has_getDecl metafunction didn't compile with
Visual Studio. This revision uses approaches has_getDecl from a
different angle that isn't a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176024 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
1b354b868c1aa227619d81e299fe6e384e1999b7 25-Feb-2013 Edwin Vane <edwin.vane@intel.com> Reverting r176019. Corrupt patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176021 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
0b6f23a23c55b7024e7a0edca1fecf9bd4c380a1 25-Feb-2013 Edwin Vane <edwin.vane@intel.com> Support in hasDeclaration for types with getDecl()

Re-introducing r175532. The has_getDecl metafunction didn't compile with Visual
Studio. This revision approaches has_getDecl from a different angle that isn't
a problem for Visual Studio.

Added dedicated tests for the metafunction.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176019 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
f3197e9eb02120522c1f60f88dacc1cfe5b210f0 25-Feb-2013 Daniel Jasper <djasper@google.com> Add matcher for AccessSpecDecls.

Also, add matchers isPrivate(), isProtected() and isPublic(), that
restrict the matching of such AccessSpecDecls and all other Decls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@176017 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
3c08a818a6ac9115fe8880af9bbf5a0a87bdffaa 24-Feb-2013 Daniel Jasper <djasper@google.com> Allow breaking between a type and name in variable declarations.

This fixes llvm.org/PR14967 and is generall necessary to avoid
situations where the column limit is exceeded. The challenge is
restricting such lines splits, otherwise clang-format suddenly starts
breaking at bad places.

Before:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string,
SomeOtherTemplateParameter> &ReallyReallyLongParameterName,
const SomeType<string,
SomeOtherTemplateParameter> &AnotherLongParameterName) {}

After:
ReallyLongReturnType<TemplateParam1, TemplateParam2>
ReallyReallyLongFunctionName(
const std::string &SomeParameter,
const SomeType<string, SomeOtherTemplateParameter> &
ReallyReallyLongParameterName,
const SomeType<string, SomeOtherTemplateParameter> &
AnotherLongParameterName) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175999 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c515978bd3a703aa733f846a0094ffa84d149074 24-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Use MacroDirective in the preprocessor callbacks to make available the
full information about the macro (e.g if it was imported and where).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175978 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
237d4c1c785be13656bff6c09e5b7ccd066ff5ba 23-Feb-2013 Daniel Jasper <djasper@google.com> Better formatting of conditional expressions.

In conditional expressions, if the condition is split over multiple
lines, also break before both operands.

This prevents formattings like:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c;

Which are bad, because they suggestion incorrect operator precedence:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c);

This lead to the discovery that the expression parser incorrectly
handled conditional operators and that it could also handle semicolons
(which in turn reduced the amount of special casing for for-loops). As a
side-effect, we can now apply the bin-packing configuration to the
sections of for-loops.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175973 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
37eff83413a064c504c5a42097e4f5dd0b2962d2 23-Feb-2013 Daniel Jasper <djasper@google.com> Don't recognize unnamed pointer parameters as casts.

This fixes llvm.org/PR15061.

Before: virtual void f(int *)const;
After: virtual void f(int *) const;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175960 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3a204418482c9ae70ad482e781132c54306c3aa6 23-Feb-2013 Daniel Jasper <djasper@google.com> Allow splitting between string literals and identifiers.

Also don't break in long include directives as that is not desired.

We can now format:

#include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
#define LL_FORMAT "ll"
printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT
"d, ddddddddd: %" LL_FORMAT "d\n");

Before, this led to weird results.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175959 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5eada844fa70b6e2bc941dd7306f7a4fb1e8529d 22-Feb-2013 Benjamin Kramer <benny.kra@googlemail.com> Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175894 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
6ebf09130479bc7605aa09a3e6c4dc2ba3513495 22-Feb-2013 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: add CommentOptions to allow specifying custom comment block commands

Add an ability to specify custom documentation block comment commands via a new
class CommentOptions. The intention is that this class will hold future
customizations for comment parsing, including defining documentation comments
with specific numbers of parameters, etc.

CommentOptions instance is a member of LangOptions.

CommentOptions is controlled by a new command-line parameter
-fcomment-block-commands=Foo,Bar,Baz.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175892 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
f11a705c6075b12cbae5632ba4de433bc9bc105f 21-Feb-2013 Daniel Jasper <djasper@google.com> Consistently put {} onto the same line for empty functions.

This fixes llvm.org/PR15167.

Before:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {
}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}

After:
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL()
: AAAAAAAA(10), BBBBBBBBB(10) {}
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL() : AAAAAAAA(10) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175800 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7d81281fc39f6d40d86be6600adba13c05b4a639 21-Feb-2013 Daniel Jasper <djasper@google.com> Allow breaking between type and name in for loops.

This fixes llvm.org/PR15033.

Also: Always break before a parameter, if the previous parameter was
split over multiple lines. This was necessary to make the right
decisions in for-loops, almost always makes the code more readable and
also fixes llvm.org/PR14873.

Before:
for (llvm::ArrayRef<NamedDecl *>::iterator I = FD->getDeclsInPrototypeScope()
.begin(), E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc), d, bar(e, f));

After:
for (llvm::ArrayRef<NamedDecl *>::iterator
I = FD->getDeclsInPrototypeScope().begin(),
E = FD->getDeclsInPrototypeScope().end();
I != E; ++I) {
}
foo(bar(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccccccccccccccc),
d, bar(e, f));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175741 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e9a6226c7a2fd1c30a00990cdeb69b89f5599fb3 20-Feb-2013 Manuel Klimek <klimek@google.com> Fix regression in string literal alignment.

Now correctly indents (again):
a = a + "a"
"a"
"a";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175630 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b56b6d1bd6f41d7b944a9631a9ab481cafe6535b 20-Feb-2013 Manuel Klimek <klimek@google.com> Fixes bug in string literal alignment.

We now indent the following correctly:
1. some + "literal" /* comment */
"literal";
2. breaking string literals after which we have another string literal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175628 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c4615b7aaf97e303a4fc675956f7f5572d492885 20-Feb-2013 Daniel Jasper <djasper@google.com> Don't remove blank lines within unwrapped lines.

If the code author decides to put empty lines anywhere into the code we
should treat them equally, i.e. reduce them to the configured
MaxEmptyLinesToKeep.

With this change, we e.g. keep the newline in:
SomeType ST = {
// First value
a,

// Second value
b
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175620 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8092a940922f307edb569036a3bb6bb722fb3a3d 20-Feb-2013 Manuel Klimek <klimek@google.com> Implements breaking of string literals if they stick out.

An alternative strategy to calculating the break on demand when hitting
a token that would need to be broken would be to put all possible breaks
inside the token into the optimizer.

Currently only supports breaking at spaces; more break points to come.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175613 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
03628b86a9c50e066412fb0e49908686ff117378 19-Feb-2013 Daniel Jasper <djasper@google.com> Add missing clang-format null pointer check..

.. and a test that triggers it in valid albeit questionable code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175554 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
34511fb79201ba9ed39c97f3a7ea0f157a79436d 19-Feb-2013 Daniel Jasper <djasper@google.com> Correctly format macro with unfinished template declaration.

We can now format:
#define A template <typename T>

Before this created a segfault :-/.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175533 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
523806028d812a7f29636c59a8bc0e7e3d3fd9ae 19-Feb-2013 Edwin Vane <edwin.vane@intel.com> Support in hasDeclaration for types with getDecl()

Using a new metafunction for detecting the presence of the member
'getDecl' in a type T, added support to hasDeclaration for any such type
T. This allows hasDecl() to be replaced and enables several other
subclasses of clang::Type to use hasDeclaration.

Updated unittests and LibASTMatchersReference.html.

Reviewers: klimek


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175532 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
5be093c0ef46c7749c942d0d9056af6dc3d591a4 18-Feb-2013 David Blaikie <dblaikie@gmail.com> Clean up last use of dyn_cast on TypeLoc in ASTMatchers

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175454 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
82282dc907a04b1931f8f578693b035ad751fd3b 18-Feb-2013 Daniel Jasper <djasper@google.com> Improve indentation of builder type calls.

In builder-type calls, it can be very confusing to just indent
parameters from the start of the line. Instead, indent 4 from the
correct function call.

Before:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();

After:
aaaaaaaaaaaaaaaaaaa()->aaaaaa(bbbbb)->aaaaaaaaaaaaaaaaaaa( // break
aaaaaaaaaaaaaa);
aaaaaaaaaaaaaaaaaaaaaaa *aaaaaaaaa = aaaaaa->aaaaaaaaaaaa()
->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175444 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
515f65df40624a767bc8763a0b6b678146b8e3c9 18-Feb-2013 Daniel Jasper <djasper@google.com> Improve formatting of builder-type calls.

Before:
aaaaaaa->aaaaaaa->aaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)->aaaaaaaa(aaaaaaaaaaaaaaa);

After:
aaaaaaa->aaaaaaa
->aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
->aaaaaaaa(aaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175441 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
29333160cfd863a451ddb6fd505c3619c3724c95 18-Feb-2013 Daniel Jasper <djasper@google.com> Reformat lines if they were "moved around".

An unwrapped line can get moved around if there is no newline before
it and the previous line was formatted.

Example:

template<typename T> // Cursor is on this line when hitting "format"
T *getFETokenInfo() const { return static_cast<T*>(FETokenInfo); }

"return .." is the second unwrapped line in this scenario. I does not
touch any reformatted region. Thus, the result of formatting is:

template <typename T> T *getFETokenInfo() const { return static_cast<T *>(FETokenInfo); }

After second format (and arguably desired end-result):

template <typename T> T *getFETokenInfo() const {
return static_cast<T *>(FETokenInfo);
}

This fixes: llvm.org/PR15060.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175440 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d0f349be1422a123fdb28d6dd556f7300e6d51e9 18-Feb-2013 Daniel Jasper <djasper@google.com> Correctly determine */& usage in more cases.

This fixes llvm.org/PR15248.

Before:
Test::Test(int b) : a(b *b) {}
for (int i = 0; i < a *a; ++i) {}

After:
Test::Test(int b) : a(b * b) {}
for (int i = 0; i < a * a; ++i) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175439 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
66d19bdeef25611c9188b3f27b7d578df4b9a447 18-Feb-2013 Daniel Jasper <djasper@google.com> Always break after multi-line string literals.

Otherwise, other parameters can be quite hidden.
Reformatted unittests/Format/FormatTest.cpp after this.

Before:
someFunction("Always break between multi-line"
" string literals", and, other, parameters);

After:
someFunction("Always break between multi-line"
" string literals",
and, other, parameters);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175436 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cf5767d65a0ee64b22c242eb758e8684a6ea5a59 18-Feb-2013 Daniel Jasper <djasper@google.com> Prevent line breaks that make stuff hard to read.

Before:
aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175432 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4a544e5856ceadef1c095c7d1ae5c8d760851d59 15-Feb-2013 Daniel Jasper <djasper@google.com> Recognize < and > as binary expressions in builder-type calls.

The current heuristic assumes that there can't be binary operators in
builder-type calls (excluding assigments). However, it also excluded
< and > in general, which is wrong. Now they are only excluded if they
are template parameters.

Before:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa()i
.aaaaaa() < aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();

After:
return aaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa() <
aaaaaaaaaaaaaaaaaaa->aaaaa().aaaaaaaaaaaaa().aaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175291 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dc2efa1c10c4646d692cc57db9fdbbebe3a48255 15-Feb-2013 Daniel Jasper <djasper@google.com> Done break between 'operator' and '<<'.

Before:
ostream &operator
<<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);

After:
ostream &operator<<(ostream &out,
some::ns::SomeReallyLongType WithSomeReallyLongValue);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175286 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b130a54940171a95422a20a07ee8fdfe009806a5 15-Feb-2013 Daniel Jasper <djasper@google.com> Re-enable ConstructorInitializerAllOnOneLineOrOnePerLine option.

This got lost and was untested as the same effect is achieved by
avoiding bin packing, which is active in Google style by default.
However, moving forward, we want more control over the bin packing
option(s) and thus, this flag should work as expected.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175277 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7878a7bdebceaa8d8a893abb295027cde619e467 15-Feb-2013 Daniel Jasper <djasper@google.com> Prevent only breaking before "?" in conditional expressions.

This is almost always more readable.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
? aaaaaaaaaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
? aaaaaaaaaaaaaaaaaaaaaaaaaaa
: aaaaaaaaaaaaaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175262 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9fc56f2636137fcde8acb38865555ed6c7b84dfd 14-Feb-2013 Daniel Jasper <djasper@google.com> Fix counting of parameters so that r175162 works as expected.

Before:
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
.aaaaaaaaaaaaaaaaa());

After:
aaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa().aaaaaaaaaaaaaaaaa());

Not sure which of the formattings above is better, but we should not pick
one by accident.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175165 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fc75908a7f58903a92c47e1ae02f9a05c36c9f59 14-Feb-2013 Daniel Jasper <djasper@google.com> Reduce penalty for breaking before ./-> after complex calls.

This gives a clearer separation of the context, e.g. in GMOCK
statements.

Before:
EXPECT_CALL(SomeObject,
SomeFunction(Parameter)).WillRepeatedly(Return(SomeValue));

After:
EXPECT_CALL(SomeObject, SomeFunction(Parameter))
.WillRepeatedly(Return(SomeValue));

Minor format cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175162 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c78c6b35d398b4c9414e7c5c7e413e28a66c8c5f 14-Feb-2013 Daniel Jasper <djasper@google.com> Remove the trailing whitespace of formatted lines.

So far, clang-format has always assumed the whitespace belonging to the
subsequent token. This has the negative side-effect that when
clang-format formats a line, it does not remove its trailing whitespace,
as it belongs to the next token.

Thus, this patch fixes most of llvm.org/PR15062.

We are not zapping a file's trailing whitespace so far, as this does not
belong to any token we see during formatting. We need to fix this in a
subsequent patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175152 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c5cfa490a1fa4eb1a3a17803c6125b42abd73455 14-Feb-2013 Daniel Jasper <djasper@google.com> Get less confused by trailing comma in Google style.

The formatter can now format:
void aaaaaaaaaaaaaaaaaa(int level,
double *min_x,
double *max_x,
double *min_y,
double *max_y,
double *min_z,
double *max_z, ) {
}

Although this is invalid code, it frequently happens during development and
clang-format should be nicer :-).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175151 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
31672fb8c3fd3410725c9a4f293810ab69889020 14-Feb-2013 Daniel Jasper <djasper@google.com> Remove accidentally committed empty test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175148 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6cabab48dacc1317821f8f078ed2d4c603b67aff 14-Feb-2013 Daniel Jasper <djasper@google.com> Align superclasses for multiple inheritence.

This fixes llvm.org/PR15179.

Before:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};

After:
class ColorChooserMac : public content::ColorChooser,
public content::WebContentsObserver {
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175147 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a03ab10f0e4d888139b3b694dd55d176982f72a4 13-Feb-2013 Daniel Jasper <djasper@google.com> Allow breaking after the return type in function declarations.

This has so far been disabled for Google style, but should be done
before breaking at nested name specifiers or in template parameters.

Before (in Google style):
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa> aaaaaaaaaaaaaaaaaaaaaaaa<
T>::aaaaaaa() {}

After:
template <typename T>
aaaaaaaa::aaaaa::aaaaaa<T, aaaaaaaaaaaaaaaaaaaaaaaaa>
aaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaa() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175074 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
42f458d164cbbee23e55e874b6cee7026ca721ca 13-Feb-2013 Daniel Jasper <djasper@google.com> Fix comment alignment close to the column limit.

Due to an error in one of the expressions, we used to not align comments
although it would have been possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175068 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e0dc7c70ee3fc1d6bdd8e2f166cc9e9be89061d9 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: And more cast tests (these don't pass yet).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175031 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6fa7e74dea00f66315835e70cdea047ba58f7b4c 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add more cast tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175030 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
37d693160eba22343e08d7bcf66cd132ace77e5c 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Refactor the cast detection code to be a bit more readable.

No functionality change. Also add another cast test.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175029 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4c2cc603f5239f3b2963ce3e5d25adcf4d0a028d 13-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC method expressions after casts.

Not all casts are correctly detected yet, but it helps in some cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175028 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
89a0daa0ec1fbc43489e3bb9e9648c816258f00f 12-Feb-2013 Daniel Jasper <djasper@google.com> Fix crash for incomplete labels in macros.

Still the formatting can be improved, but at least we don't assert any
more. This happened when trying to format lib/Sema/SemaType.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175003 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9ece2bb8499251f3e7cdf65e7a65b38aaeead0d8 12-Feb-2013 Daniel Jasper <djasper@google.com> Fix bug in the adjustment to existing lines.

Before (if only the second line was reformatted):
void f() {}
void g() {}

After:
void f() {}
void g() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174978 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
95e8e468af284afb11ec1f994d0b5076fc7423d9 12-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Correctly format stars in `sizeof(int**)` and similar places.

This redoes how '*' and '&' are classified as pointer / reference markers when
followed by ')', '>', or ','.

Previously, determineStarAmpUsage() marked a single '*' and '&' followed by
')', '>', or ',' as pointer or reference marker. Now, all '*'s and '&'s
preceding ')', '>', or ',' are marked as pointer / reference markers. Fixes
PR14884.

Since only the last '*' in 'int ***' was marked as pointer before (the rest
were unary operators, which don't reach spaceRequiredBetween()),
spaceRequiredBetween() now had to be thought about handing multiple '*'s in
sequence.

Before:
return sizeof(int * *);
Type **A = static_cast<Type * *>(P);

Now:
return sizeof(int**);
Type **A = static_cast<Type **>(P);

While here, also make all methods of AnnotatingParser except parseLine()
private.

Review URL: http://llvm-reviews.chandlerc.com/D384



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174975 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7f43fcf5d9406788ce95c9f3b785e0a6bc75a7f7 12-Feb-2013 Edwin Vane <edwin.vane@intel.com> Adding more overloads for allOf matcher

Adding overloads of allOf accepting 4 and 5 arguments.

Reviewer: klimek



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174967 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
c2e6d2a4a7fe9dfa7d52a38c6048b7b18e6b591a 11-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC message expressions after 'in' in loop

Before:
for (id foo in[self getStuffFor : bla]) {
}

Now:
for (id foo in [self getStuffFor:bla]) {
}

"in" is treated as loop keyword if the line starts with "for", and as a
regular identifier else. To check for "in", its IdentifierInfo is handed
through a few layers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174889 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3f4535e44965f46cf603146141d2d27a1cef1f7f 11-Feb-2013 Manuel Klimek <klimek@google.com> Get rid of manual debug output, now that the test runner supports it.

You can run tests with -debug instead now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174880 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
729a743b317d877df3978e88a4a247d2edbf2090 11-Feb-2013 Daniel Jasper <djasper@google.com> Fix invalid formatting with spaces before trailing comments.

In google style, trailing comments are separated by two spaces. This
patch fixes the counting of these spaces and prevents clang-format from
creating a line with 81 columns.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174879 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a28fc067e3ee8eb84368530e878ce094f39651d3 11-Feb-2013 Manuel Klimek <klimek@google.com> Fixes handling of empty lines in macros.

Now correctly formats:
#define A \
\
b;
to
#define A b;

Added the state whether an unwrapped line is a macro to the debug
output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174878 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2b4c924f85e156d66c01b3f16c850892c47dcc7a 11-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting of overloaded operator definitions.

Before:
operatorvoid*();
operator vector< A< A>>();

After:
operator void *();
operator vector<A<A> >();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174863 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0ac717b2a5ba15233ed25edc5310c64d441669b1 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add a test for multi-line ObjC dict literals.

As it turns out, this already works reasonably well.

This example from http://clang.llvm.org/docs/ObjectiveCLiterals.html
NSDictionary *dictionary = @{
@"name" : NSUserName(),
@"date" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo]
};

is formatted like
NSDictionary *dictionary = @{ @"name" : NSUserName(), @"date" : [NSDate date],
@"processInfo" : [NSProcessInfo processInfo] };

There's already a FIXME in NestedStaticInitializers about supporting one
initializer per line, which is really all that's missing here too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174842 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e62620021c734140de6f3d3fe81a66c3ee578e93 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add another ObjC literal test.

(From http://clang.llvm.org/docs/ObjectiveCLiterals.html.)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174841 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d74fcdb630dad817f5d462edd6d12bb95e3f27f1 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Initial support for ObjC dictionary literals.

Before:
@{
foo:
bar
}
;

Now:
@{ foo : bar };

parseBracedList() already does the right thing from an UnwrappedLineParser
perspective, so check for "@{" in all loops that process constructs that can
contain expressions and call parseBracedList() if found.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174840 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
051860ee770bf83c3e66ab893be3642bb8bc2680 10-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC array literals.

Use this to add a space after "@[" and before "]" for now.

Later, I want to use this to format multi-line array literals nicer, too.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174822 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7728057cf03f8e5791e46eefc6e146214d0a1c24 09-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add test for default arguments.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174816 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3f6f51e28231f65de9c2dd150a2d757b2162cfa3 08-Feb-2013 Jordan Rose <jordan_rose@apple.com> Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.

Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
asic/CharInfoTest.cpp
9893902eceba7f01dd1521349d33866f77254d78 08-Feb-2013 Jordan Rose <jordan_rose@apple.com> Pull Lexer's CharInfo table out for general use throughout Clang.

Rewriting the same predicates over and over again is bad for code size and
code maintainence. Using the functions in <ctype.h> is generally unsafe
unless they are specified to be locale-independent (i.e. only isdigit and
isxdigit).

The next commit will try to clean up uses of <ctype.h> functions within Clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174765 91177308-0d34-0410-b5e6-96231b3b80d8
asic/CMakeLists.txt
asic/CharInfoTest.cpp
52635ff9fb530dfdfc6a94e52a2270bf1bb8346b 08-Feb-2013 Manuel Klimek <klimek@google.com> Fix indentation-detection at indent level 0.

This correctly formats:
{
a;
}
where { is incorrectly indented by 2, but is at level 0, when
reformatting only 'a;'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174737 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
547d5db5ed482e23edf62130ffdee86ba810d432 08-Feb-2013 Manuel Klimek <klimek@google.com> Takes the context into account when re-indenting regions.

Fixes llvm.org/PR14916.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174720 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
087387a1e9ce5abeb4f348e14f64e5c2273eaedb 08-Feb-2013 Daniel Jasper <djasper@google.com> Fix handling of fake parenthesis during formatting.

They are much easier to handle when attached to the previous token.

Before:
unsigned Indent =
formatFirstToken(TheLine.First, IndentForLevel[TheLine.Level] >=
0 ? IndentForLevel[TheLine.Level]
: TheLine.Level * 2, TheLine.InPPDirective, PreviousEndOfLineColumn);

After:
unsigned Indent = formatFirstToken(
TheLine.First, IndentForLevel[TheLine.Level] >= 0
? IndentForLevel[TheLine.Level] : TheLine.Level * 2,
TheLine.InPPDirective, PreviousEndOfLineColumn);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174718 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
29f123b2fa0435bb1962f0d9e9a2e660f35fbb2f 08-Feb-2013 Daniel Jasper <djasper@google.com> Implement a tiny expression parser to improve formatting decisions.

With this patch, the formatter introduces 'fake' parenthesis according
to the operator precedence of binary operators.

Before:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA || bbbb &
BBBBBBBBBBBBBBBBBBBBBBBBBBBBB || cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

After:
return aaaa & AAAAAAAAAAAAAAAAAAAAAAAAAAAAA ||
bbbb & BBBBBBBBBBBBBBBBBBBBBBBBBBBBB ||
cccc & CCCCCCCCCCCCCCCCCCCCCCCCCC ||
dddd & DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD;
f(aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaa);

Future improvements:
- Get rid of some of the hacky ways to nicely format certain constructs.
- Merge this parser and the AnnotatingParser as we now have several parsers
that analyze (), [], etc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174714 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ce3d1a68d98f8a557ba5a5391cae8278ae6f29d2 08-Feb-2013 Daniel Jasper <djasper@google.com> Avoid unnecessary line breaks in nested ObjC calls.

Before:
[pboard setData:[NSData dataWithBytes:&button
length:sizeof(button)]
forType:kBookmarkButtonDragType];
After:
[pboard setData:[NSData dataWithBytes:&button length:sizeof(button)]
forType:kBookmarkButtonDragType];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174701 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
daf1a15d734d154f07d5a0328d3ef59cd9a68f13 07-Feb-2013 Daniel Jasper <djasper@google.com> clang-format: Don't put useless space in f( ::g()).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174662 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fa37c5ca61af275a329386407e58cf70f4d9f596 07-Feb-2013 Manuel Klimek <klimek@google.com> Implements equalsNode for Decl and Stmt.

This is a powerful tool when doing iterative refined matches,
where another match is started inside the match callback of the first
one; this allows for example to find out whether the node was in
the condition or body of its parent if-statement.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174605 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
712f5b3bef988e8d3dd38fdf2264e7cc1a3f6bf9 07-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Move ObjC literal tests to its own test case.

Slightly expand the boxed expressions test with a few more snippets from
http://clang.llvm.org/docs/ObjectiveCLiterals.html



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174559 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
474e46211a141e4566c399b80ae26e3580b70c90 06-Feb-2013 Daniel Jasper <djasper@google.com> Fix bug in the alignment of comments.

Before:
const char *test[] = {
// A
"aaaa",
// B
"aaaaa",
};

After:
const char *test[] = {
// A
"aaaa",
// B
"aaaaa",
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174549 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4e8a7b4a95962f63a938c0d21c9aca0a51b78345 06-Feb-2013 Daniel Jasper <djasper@google.com> Become a little smarter with formatting long chains of pipes.

Assign a high penalty to breaking before "<<" if the previous token is a
string literal ending in ":" or "=".

Before:
llvm::outs()
<< "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa << "bbbbbbbbbbbbbbbbb = "
<< bbbbbbbbbbbbbbbbb << "ccccccccccccccccc = " << ccccccccccccccccc
<< "ddddddddddddddddd = " << ddddddddddddddddd << "eeeeeeeeeeeeeeeee = "
<< eeeeeeeeeeeeeeeee;

After:
llvm::outs() << "aaaaaaaaaaaaaaaaa = " << aaaaaaaaaaaaaaaaa
<< "bbbbbbbbbbbbbbbbb = " << bbbbbbbbbbbbbbbbb
<< "ccccccccccccccccc = " << ccccccccccccccccc
<< "ddddddddddddddddd = " << ddddddddddddddddd
<< "eeeeeeeeeeeeeeeee = " << eeeeeeeeeeeeeeeee;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174545 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
15417ef20e3cda668351c67cc580587913f6bee8 06-Feb-2013 Daniel Jasper <djasper@google.com> Align trailing block comments like trailing line comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174537 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4ed7f3e003c906d9fdb92a9484feeb8ac6e28e2f 06-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Correctly detect ObjC message expressions preceded by a comment.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174521 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b3507cd01ead99113eed92a815b826f26f6dbadb 06-Feb-2013 Manuel Klimek <klimek@google.com> Fix handling of comments in macros.

We now correctly format:
// Written as a macro, it is reformatted from:
#define foo(a) \
do { \
/* Initialize num to zero. */ \
int num = 10; \
/* This line ensures a is never zero. */ \
int i = a == 0 ? 1 : a; \
i = num / i; /* This division is OK. */ \
return i; \
} while (false)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174517 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7fc2db0acd3fb0f38db19764eef137ae3a9edc9f 06-Feb-2013 Manuel Klimek <klimek@google.com> Much semicolon after namespaces.

We now leave the semicolon in the line of the closing brace in:
namespace {
...
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174514 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9e9e6e0297a96e237b53e6be433749065bcea5f8 06-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting of ObjC method calls.

This fixes llvm.org/PR15165.

We now correctly align:
[image_rep drawInRect:drawRect
fromRect:NSZeroRect
operation:NSCompositeCopy
fraction:1.0
ssssssssdd:NO
hints:nil];

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174513 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b8b1ce12362860e55590c55fd43db875c9193357 06-Feb-2013 Manuel Klimek <klimek@google.com> Parse record declarations with token pasted identifiers.

This is pretty common in macros:
#define A(X, Y) class X##Y {};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174512 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
36ba0ff4b632cff7424693b9818bcc8d9ea7798a 06-Feb-2013 Daniel Jasper <djasper@google.com> Fix a formatting bug caused by comments in expressions.

This fixes llvm.org/PR15162.

Before:
bool aaaaaaaaaaaaa = // comment
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

After:
bool aaaaaaaaaaaaa = // comment
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaaa;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174508 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8ff690ab478b33e0d830a6203de12d191d94f8ff 06-Feb-2013 Daniel Jasper <djasper@google.com> Optionally derive formatting information from the input file.

With this patch, clang-format can analyze the input file for two
properties:
1. Is "int *a" or "int* a" more common.
2. Are non-C++03 constructs used, e.g. A<A<A>>.

With Google-style, clang-format will now use the more common style for
(1) and format C++03 compatible, unless it finds C++11 constructs in the
input.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174504 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6b5ba8be528bf614d5f4477a4cdbd7c3b19714a6 06-Feb-2013 Daniel Jasper <djasper@google.com> Fix an issue with the formatting of stars in default values.

Before: void f(int *a = d *e, int b = 0);
After: void f(int *a = d * e, int b = 0);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174500 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cf87bffc346244f0ed8eae7fffb52a0f03cd0413 06-Feb-2013 Manuel Klimek <klimek@google.com> Adds a convenience function selectFirst to simplify matching.

A very common use case is to search for the first occurrence of
a certain node that is a descendant of another node. In that
case, selectFirst significantly simplifies the code at the client side.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174499 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
4e778091b0ff42895644ca8bef30f1a91ba6b32b 06-Feb-2013 Daniel Jasper <djasper@google.com> Handle nested ObjC calls.

Properly handle annotation contexts while calculating extra information
for each token. This enable nested ObjC calls and thus solves (most of)
llvm.org/PR15164. E.g., we can now format:

[contentsContainer replaceSubview:[subviews objectAtIndex:0]
with:contentsNativeView];

Also fix a problem with the formatting of types in casts as this was
trivial now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174498 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e8a97985f72b4e11435ff2107c0f11e925fb6d96 06-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: No space after & and * in front of ObjC message expressions.

1. let determineStarAmp() check of unary operators before checking for
"is next '['". That check was added in r173150, and the test from that
revision passes either way.

2. change determineStarAmp() to categorize '*' and '&' after '=' as unary
operator.

3. don't let parseSquare() overwrite the type of a '*' or '&' before the start
of an objc message expression if has the role of unary operator.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174489 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ee0feec7362053f22b6c01d12e1bfa06fb3ac93f 05-Feb-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Detect ObjC method expressions after unary operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174384 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
63d7cedca8616921c1908c88c2f23fcd67bbab99 05-Feb-2013 Daniel Jasper <djasper@google.com> Initial support for formatting ObjC method declarations/calls.

We can now format stuff like:
- (void)doSomethingWith:(GTMFoo *)theFoo
rect:(NSRect)theRect
interval:(float)theInterval {
[myObject doFooWith:arg1 //
name:arg2
error:arg3];

}

This seems to fix everything mentioned in llvm.org/PR14939.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174364 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d399bfff5a57325d8e63116c70aa727b1fb43232 05-Feb-2013 Daniel Jasper <djasper@google.com> Fix some linebreak decisions in Google format.

Before:
f(aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaa +
aaaaaaaaaaaaaaaaaaaa);
aaaaaaa(aaaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaa));

After:
f(aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaa);
aaaaaaa(aaaaaaaaaaaaa,
aaaaaaaaaaaaa,
aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaa));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174363 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5b7e7b0ec77f49c1b24deffc9b7032ca16ca9f0d 05-Feb-2013 Daniel Jasper <djasper@google.com> Fix formatting regression introduced by r174307.

In preprocessor definitions, we would not parse all the tokens and thus
not annotate them anymore. This led to a wrong formatting of comments
in google style:

#endif // HEADER_GUARD -- requires two spaces

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174361 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
afbcab8d10d4208c7ad8da79e948432117d4a326 05-Feb-2013 Richard Smith <richard-llvm@metafoo.co.uk> PR15095: Use more correct source locations for the InitListExpr we fake up for
vector initialization. Patch by John Stratton!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174339 91177308-0d34-0410-b5e6-96231b3b80d8
ST/MatchVerifier.h
ST/SourceLocationTest.cpp
152ea0e4711f7aed75f6a1d1995b0bd94eb31c98 04-Feb-2013 Manuel Klimek <klimek@google.com> Implements the convenience matcher findAll.

We found that findAll has been implemented incorrectly multiple times
by various people using the matchers. To prevent further wasted
development effort, it makes sense to add it as convenience matcher
implemented as eachOf(m, forEachDescendant(m)).

This patch also updates the docs with the new matchers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174320 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
7387673f83b8b37f660422947c9990778ba88193 04-Feb-2013 Manuel Klimek <klimek@google.com> Add an eachOf matcher.

eachOf gives closure on the forEach and forEachDescendant matchers.
Before, it was impossible to implement a findAll matcher, as matching
the node or any of its descendants was not expressible (since anyOf
only triggers the first match).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174315 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
cda165056890b8ccfc6e2897c711388c5fb518c0 04-Feb-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing block comments

This is a follow up to r174309 to actually make it work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174314 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fa543accd8945c39d5128612c8822d0ab4ad594c 04-Feb-2013 Daniel Jasper <djasper@google.com> Improve formatting of stream operators.

If there are string literals on either side of a '<<', chances are
high that they represent logically separate concepts. Otherwise,
the author could just have just a single literal (possible split
over multiple lines).

So, we can now nicely format things like:
cout << "somepacket = {\n"
<< " val a = " << ValueA << "\n"
<< " val b = " << ValueB << "\n"
<< "}";

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174310 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2752ff35854b295837b8088e44d5a932be60e107 04-Feb-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing block comments.

We can now (even in non-bin-packing modes) format:
someFunction(1, /* comment 1 */
2, /* comment 2 */
3, /* comment 3 */
aaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174309 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8159d2f271c9142b46a672ac2c45821911171a7d 04-Feb-2013 Daniel Jasper <djasper@google.com> Fix an error in formatting of for-loops.

Two minor changes:
* Slight penalty for breaking at "," as opposed to ";".
* Don't apply bin-packing rules to for-loops.

Before:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb; ++aaaaaa,
++ccccccccccccccc) {}

After:
for (int aaaaaa = aaaaaaaaaa; aaaaaa < bbbbbbbb;
++aaaaaa, ++ccccccccccccccc) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174308 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0178673f541685cf5067814dfeee2644078e39a9 04-Feb-2013 Daniel Jasper <djasper@google.com> Restructuring of token annotation for formatting.

This combines several changes:
* Calculation token type (e.g. for * and &) in the AnnotatingParser.
* Calculate the scope binding strength in the AnnotatingParser.
* Let <> and [] scopes bind stronger than () and {} scopes.
* Add minimal debugging output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174307 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6bd0232b4f58e7ad40f687b09b0eb897bcc3fd1e 03-Feb-2013 Daniel Jasper <djasper@google.com> Fix bug in formatting of nested initializers.

We can now format:
SomeArrayOfSomeType a = { { { 1, 2, 3 } }, { { 1, 2, 3 } },
{ { 111111111111111111111111111111,
222222222222222222222222222222,
333333333333333333333333333333 } },
{ { 1, 2, 3 } }, { { 1, 2, 3 } } };

Before, we did strange things there.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174291 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5ebcb20b0331a6e64c213f0bb5f4bed9a9e8eb34 01-Feb-2013 Argyrios Kyrtzidis <akyrtzi@gmail.com> For ModuleLoader::makeModuleVisible() also pass the source location where the
module import occurred.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174191 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
60969f5f6be1cbf7ac2384cc5ad571d28adf6bf1 01-Feb-2013 Manuel Klimek <klimek@google.com> Re-design the convenience interfaces on MatchFinder.

First, this implements a match() method on MatchFinder; this allows us
to get rid of the findAll implementation, as findAll is really a special
case of recursive matchers on match.

Instead of findAll, provide a convenience function match() that lets
users iterate easily over the results instead of needing to implement
callbacks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174172 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
bd04f2aa2247f2fda3fd8f3fee90479ba2c94499 31-Jan-2013 Manuel Klimek <klimek@google.com> Never break inside something that was a preprocessor directive.

Just put it in one unwrapped line and let the formatter handle it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174063 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f343cabb68d495041706b8e2f1ed48fbac3cba06 31-Jan-2013 Daniel Jasper <djasper@google.com> Several improvements to the formatting of static initializers.

1. Never avoid bin packing in static initializers as this can
lead to terrible results.
2. If an element has to be broken over multiple lines, break after
the following comma.

This should be a step forward, but there are still many cases
especially with nested static initializers that we handle badly.
More patches will follow.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174061 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4d0e9f58076037d84a7da0b407c3de8f76a9d552 31-Jan-2013 Manuel Klimek <klimek@google.com> Move commonly useful code for AST testing into MatchVerfier.h.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174057 91177308-0d34-0410-b5e6-96231b3b80d8
ST/MatchVerifier.h
ST/SourceLocationTest.cpp
afcbd859f839db4133311147c1bc7db29dfaea10 30-Jan-2013 Daniel Jasper <djasper@google.com> Don't generate no-op replacements.

No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173916 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d4f2c2e21addd8ed0a50b92f062d3229cde0506a 29-Jan-2013 Daniel Jasper <djasper@google.com> Improve formatting of code with comments.

Before:
aaaaaaa(aaaaaa( // comment
aaaaaaa));
<big mess>

After:
aaaaaaa(aaaaaa( // comment
aaaaaaaa));
function(/* parameter 1 */ aaaaaaa,
/* parameter 2 */ aaaaaaa,
/* parameter 3 */ aaaaaaa,
/* parameter 4 */ aaaaaaa);

(the latter example was only wrong in the one-arg-per-line mode, e.g. in
Google style).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173821 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f1579605adf03f94a2ddddc95c764737ead0efe5 29-Jan-2013 Daniel Jasper <djasper@google.com> Allow all parameters on next line for function calls in Chrome.

The style guide only forbids this for function declarations. So,
now

someFunction(
aaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa, aaaaaaaaaaaa);

Is allowed in Chromium mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173806 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2e60377273fb451587a60209997148480754b9fa 29-Jan-2013 Daniel Jasper <djasper@google.com> Initial support for multiple variable declarations.

Before:
SomeType aaaaaaaaaaaaaaaaa = aaaaaa->aaaaaaaaaaaaaaaaa(),
aaaaaaaaaaa = aaaaaa->aaaaaaaaaaa();
After:
SomeType aaaaaaaaaaaaaaaaa = aaaaaa->aaaaaaaaaaaaaaaaa(),
aaaaaaaaaaa = aaaaaa->aaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173792 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
93384a910cb98f3a128b76e6043f149e1b384c65 29-Jan-2013 Daniel Jasper <djasper@google.com> Reverting changes from r173785 (removing empty lines before "}").

This needs some more thinking, e.g. for namespaces, chains of if-else
if, ...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173787 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8df364fc0b3d89fb4ea632c6824a121a8c7752a5 29-Jan-2013 Daniel Jasper <djasper@google.com> Remove empty lines before "}".

Those empty lines waste vertical whitespace and almost never
increase readability.

Before:
void f() {
DoSomething();

}

After:
void f() {
DoSomething();
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173785 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7522318ce2b2280dc679b62a4193c8f179632c16 28-Jan-2013 Daniel Jasper <djasper@google.com> Fix a bug that would lead to bad line break decisions in for loops.

Before:
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa = aaaaaaaaaaaaaaa
.aaaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {}

After:
for (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaa =
aaaaaaaaaaaaaaa.aaaaaaaaaaaaaaaa;
aaaaaaaaaaa != aaaaaaaaaaaaaaaaaaa; ++aaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173695 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d75ff6496bfb599a9edde41681873919d4d44152 28-Jan-2013 Daniel Jasper <djasper@google.com> Don't put a function's return type on its own line in Google style.

This would be against the style guide:
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Function_Declarations_and_Definitions#Function_Declarations_and_Definitions

Not sure what to do as a last resort if the function signature does not
fit onto a single line in Google style ..

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173690 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
83f25ba0499f18b91501fb6538c49ebc7827bea0 28-Jan-2013 Daniel Jasper <djasper@google.com> Let clang-format break after a function's return type.

Before:
TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *II,
Type *T) {}

After:
TypeSpecDecl *
TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *II, Type *T) {}

This fixes llvm.org/PR14717.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173688 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
02b771e3110f7799f93d5d17dc6fefc5713387c3 28-Jan-2013 Daniel Jasper <djasper@google.com> Make continuations in constructor initializers consistent.

Before:
Constructor
: LooooooooooooooooooooongVariable(
LooooooooooooooooooooongValue) {}

After:
Constructor
: LooooooooooooooooooooongVariable(
LooooooooooooooooooooongValue) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173685 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3b9a8fc5bee5434bebc9058646896423adac625b 28-Jan-2013 Daniel Jasper <djasper@google.com> Initial support for formatting range-based for-loops.

Before (in good cases):
for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
for (auto aaaaaaaaaaaaaaaaaaaa : aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa,
aaaa)) {}

After:
for (auto aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa :
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
for (auto aaaaaaaaaaaaaaaaaaaa :
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaa)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173684 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bfe6fd4f00257b113ea3bcb4efef8d9f9f245882 28-Jan-2013 Daniel Jasper <djasper@google.com> Improve formatting of conditional expressions.

Before we did not really systematically format those. Now, we format the
different cases as:

- 1 Line: a ? b : c;
- 2 Lines: short ? loooooooooong
: loooooooooong
- 2 Lines: loooooooooooooooong
? short : short
- 3 Lines: loooooooooooooooong
? loooooooooooooong
: loooooooooooooong

Not sure whether "?" and ":" should go on the new line, but it seems to
be the most consistent approach.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173683 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ae8699bde649e2ed1f66414b4283b862f11056dd 28-Jan-2013 Daniel Jasper <djasper@google.com> Several small changes in formatting decisions.

1. Use a hanging ident for function calls nested in binary expressions.
E.g.:
int aaaaa = aaaaaaaaa && aaaaaaaaaa(
aaaaaaaaaa);

2. Slightly improve heuristic for builder type expressions and reduce
penalty for breaking before "." and "->" in those.

3. Remove mostly obsolete metric of decreasing indent level. This
fixes: llvm.org/PR14931.

Changes #1 and #2 were necessary to keep tests passing after #3.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173680 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5f2173ee723fd17b758f2a35a5bb39ca74eca523 28-Jan-2013 Daniel Jasper <djasper@google.com> Improve indentation after breaking at nested name specifiers.

These always represent a continuation and we should increase the ident.

Before:
aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa::
aaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaa::
aaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173675 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
986e17ff3bd3df2762f88569cab3fdfbabc08bb1 28-Jan-2013 Daniel Jasper <djasper@google.com> Avoid confusing identations for multi-parameter functions.

Before:
aaaaaaaa(aaaaaaaaa(
aaaaaaaaaa(),
aaaaaaaaa);

After:
aaaaaaaa(aaaaaaaaa(
aaaaaaaaaa(),
aaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173673 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b8d2441144557c1b20b89b524d7ac54dbfaac0db 28-Jan-2013 Hal Finkel <hfinkel@anl.gov> Fix a typo in the name of a tooling unit test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173658 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
3499ddac3f075cbda6347067190fcc7a972dcaca 25-Jan-2013 Daniel Jasper <djasper@google.com> Fix some alignment and line break decisions.

This combines two small changes:
1) Put a penalty on breaking after "<"
2) Only produce a hanging indent when parameters are separated by
commas.

Before:
aaaaaaaaaaaaaaaaaaaaaaaa<
aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
aaaaaa(new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa));

After:
aaaaaaaaaaaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa>(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
aaaaaa(new Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa));

This changes one ObjC test, but AFAICT this is not according to any
style guide (neither before nor after). We probably should be aligning
on the ":" there according to:
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml?showone=Method_Invocations#Method_Invocations

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173457 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
63f003644420fff0ea3d463e68aee83f2f5842cd 25-Jan-2013 Daniel Jasper <djasper@google.com> Allow breaking after "::" if absolutely necessary.

Otherwise, really long nested name specifiers can easily lead to a
violation of the column limit.

Not sure about the rules for indentation in those cases, so input is
appreciated (see tests.).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173438 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1ea6bc0fd9c1ff9fa03e8a829a79c4167445d503 25-Jan-2013 Daniel Dunbar <daniel@zuster.org> [Lex] Remove DirectoryLookup.UserSpecified, which is unused.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173409 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PPCallbacksTest.cpp
e438bac04165937036e41c321fa0d5567d1e520c 23-Jan-2013 Daniel Jasper <djasper@google.com> Add extra indent for nested calls inside if's.

Before:
if (aaaaaaaaaa(
aaaaaaaaaa)) {}

After:
if (aaaaaaaaaa(
aaaaaaaaaa)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173290 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f39c8859b087151617aa2c8b193d0b332503e3ca 23-Jan-2013 Daniel Jasper <djasper@google.com> Don't try to align builder-type continuations on assignments.

Before:
int aaaa = aaaaa().aaaaa() // force break
.aaaaa();
After:
int aaaa = aaaaa().aaaaa() // force break
.aaaaa();

The other indent is just wrong and confusing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173273 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
13cb7c2c46bca6f52fd217091ef2922a3eca46f5 23-Jan-2013 Daniel Jasper <djasper@google.com> Don't try to do a hanging ident after assignments.

Before:
bool aaaa = aaaaaaaaaaa(
aaaaaaaaaaaaaaaaa);

After:
bool aaaa = aaaaaaaaaaa(
aaaaaaaaaaaaaaaaa);

The other indentation was a nice attempt but doesn't work in many cases.
Not sure what the right long term solution is as the "After: " is still
not nice. We either need to figure out what to do in the cases where it
"doesn't work" or come up with a third solution, e.g. falling back to:

bool aaaa =
aaaaaaaaaaa(
aaaaaaaaaaaaaaaaa);

which should always work and nicely highlight the structure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173268 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7ccbc2156bfe473f080b585130d70e51c4b62bb0 23-Jan-2013 Manuel Klimek <klimek@google.com> Fix handling of macro definitions.

Now correctly formats:
#define A (1)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173264 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a32a7fda316289dca6aac1352fde3caf14a1cb2f 23-Jan-2013 Manuel Klimek <klimek@google.com> Fixes layouting regression and invalid-read.

Layouting would prevent breaking before + in
a[b + c] = d;
Regression detected by code review.

Also fixes an invalid-read found by the valgrind bot.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173262 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
20d3583857c2cc99dcc9c27ff5f23916df9c0812 23-Jan-2013 Daniel Jasper <djasper@google.com> Fix the formatting of pointer/reference types in range-based for loops.

Before: for (int & a : Values) {}
After: for (int &a : Values) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173259 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7006e7ebc0098b7627bd3cc13367ea576c25dcbb 23-Jan-2013 Daniel Jasper <djasper@google.com> Removing the penalty for breaking after "=".

Having seen more cases, this actually was not a good thing to do in the
first place. We can still improve on what we do now, but breaking after
the "=" is good in many cases.

Before:
aaaaaaaaaaaaa = aa->aaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa));

After:
aaaaaaaaaaaaa =
aa->aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173257 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4bfc65aab5408f76dfe38e3f4e4375fadeda3bc3 23-Jan-2013 Daniel Jasper <djasper@google.com> Fix another regression for pointer types.

Before: if (int * a = &b) ...
After: if (int *a = &b) ...

Also changed all the existing tests to test the expressions in question
both in a declaration and in an expression context.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173256 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
218b6dfaee321cec558e15d47b68155dd9f35684 23-Jan-2013 Daniel Jasper <djasper@google.com> Fix regression in formatting pointer types.

We will need a more principled solution, but we should not leave this
unfixed until we come up with one.

Before: void f() { int * a; }
After: void f() { int *a; }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173252 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
836b58f564e07e806d3d0b41a193fde0921013c7 23-Jan-2013 Manuel Klimek <klimek@google.com> Fixes incorrect handling of the declaration context stack.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173250 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
092a2c7373c02d1653bea1feb1ada05363b02bc2 23-Jan-2013 Manuel Klimek <klimek@google.com> Fix segfaults in the formatter.

Also: expletive deleted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173247 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8f4bd7a20f89d9065bebadd270e6bc7822257d37 23-Jan-2013 Daniel Jasper <djasper@google.com> Add option to allow putting all parameters onto the next line.

This only affects styles where BinPackParameters is false.

With AllowAllParametersOnNextLine:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaaaa);

Without it:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaa,
aaaaaaaaaa,
aaaaaaaaaa,
aaaaaaaaaaa,
aaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173246 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
70b03f4edaefcc5b9aa2e084d1c12e9d91b32a77 23-Jan-2013 Manuel Klimek <klimek@google.com> Allow us to better guess the context of an unwrapped line.

This gives us the ability to guess better defaults for whether a *
between identifiers is a pointer dereference or binary operator.

Now correctly formats:
void f(a *b);
void f() { f(a * b); }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173243 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f5ecfa5b4fb01dee3f357efc815fbc715706aba5 22-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove a fixme klimek fixed in r173168.

Add a few comments to the ObjC test cases.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173169 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
86721d2a4610ac0a4b162952ec409df1fe397d58 22-Jan-2013 Manuel Klimek <klimek@google.com> Implements more principled comment parsing.

Changing nextToken() in the UnwrappedLineParser to get the next
non-comment token. This allows us to correctly layout a whole class of
snippets, like:

if /* */(/* */ a /* */) /* */
f() /* */; /* */
else /* */
g();

Fixes a bug in the formatter where we would assume there is a previous
non-comment token.
Also adds the indent level of an unwrapped line to the debug output in
the parser.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173168 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3298327e0e6ecb31ca8f3d0996043292e7c860f2 22-Jan-2013 Daniel Jasper <djasper@google.com> Let the formatter be more restrictive for breaking around . and ->

Before:
aaaaaaaaaaaaaaa(aaaaaaaaa, aaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaa)
.aaaaaaaaaaaaaaaaaa();

After:
aaaaaaaaaaaaaaa(aaaaaaaaa, aaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173160 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ffee17126e10a0e2febfcfbf61d8e0d6e2fcf4c0 22-Jan-2013 Daniel Jasper <djasper@google.com> Fix "*" formatting when creating arrays of pointers.

Before: A = new int * [10]();
After: A = new int *[10]();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173150 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
821627e5865c29357aef0e4f175b0abd083bf191 21-Jan-2013 Daniel Jasper <djasper@google.com> Remove "incorrect" aligning of trailing comments.

We used to align trailing comments belong to different things.
Before:
void f() { // some function..
}
int a; // some variable..

After:
void f() { // some function..
}
int a; // some variable..

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173100 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
308232c0aef773d24693f9e456dc3bc983934f7f 21-Jan-2013 Manuel Klimek <klimek@google.com> Fixes various problems around enum parsing.

Very similar to what we do for record definitions:
- tighten down what is an enum definition, so that we don't mistake a
function for an enum
- allow common idioms around declarations (we'll want to handle that
more centrally in the future)

We now correctly format:
enum X f() {
a();
return 42;
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173075 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2f1ac41a6d8d202dcc39ab8eb56ccea823dc062e 21-Jan-2013 Manuel Klimek <klimek@google.com> Fixes formatting of empty blocks.

We now only put empty blocks into a single line, if all of:
- all tokens of the structural element fit into a single line
- we're not in a control flow statement

Note that we usually don't put record definitions into a single line, as
there's usually at least one more token (the semicolon) after the
closing brace. This doesn't hold when we are in a context where there is
no semicolon, like "enum E {}".

There were some missing tests around joining lines around the corner
cases of the allowed number of columns, so this patch adds some.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173055 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
032f25329565adfc542f001953565091eccba130 21-Jan-2013 Daniel Jasper <djasper@google.com> Fix parsing of templated declarations.

Before: template <template <typename T>, typename P > class X;
After: template <template <typename T>, typename P> class X;

More importantly, the token annotations for the second ">" are now computed
correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173047 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d19dc2ddf3f8630cfdbefec490c0000c14bee6bd 21-Jan-2013 Manuel Klimek <klimek@google.com> Fixes indent in linkage specification blocks.

We now indent:
extern "C" {
int a;
}

without additional indent inside the extern "C" block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173045 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0fbe0087d2558c509dcfdb4b593b844625c2dd3d 21-Jan-2013 Manuel Klimek <klimek@google.com> Add regression test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173042 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3a3408cceb438af7cdebb5b3d938abb916162bb4 21-Jan-2013 Manuel Klimek <klimek@google.com> Fixes detection of class template specializations.

Now correctly formats:
template <> class A<int> {} a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173038 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7f5b025e9b9a981a257d83063064ac6e58239d76 21-Jan-2013 Manuel Klimek <klimek@google.com> Allow for nested name specifiers in record declarations.

Now correctly formats:
class A::B {} n;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173019 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c44ee89cb448e34aada006b707eb45a1280f31e3 21-Jan-2013 Manuel Klimek <klimek@google.com> Fix parsing of return statements.

Previously, we would not detect brace initializer lists in return
statements, thus:
return (a)(b) { 1, 2, 3 };
would put the semicolon onto the next line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173017 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d47afb96a3f988e6d21a92fe4dfe875ab227c7c0 20-Jan-2013 Sean Silva <silvas@purdue.edu> Nuke SetUpBuildDumpLog.

Also, it was the only reason that `argc` and `argv` were being passed
into createDiagnostics, so remove those parameters and clean up callers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172945 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/FrontendActionTest.cpp
44a3ddbf7d2f46a002b5e85b240359c435509b4e 19-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: add more tests for html character references


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172923 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
3a5fa0383c33140f661027d708d3f49b30cd4de0 19-Jan-2013 Chris Lattner <sabre@nondot.org> fix the unit tests too.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172907 91177308-0d34-0410-b5e6-96231b3b80d8
ST/Makefile
STMatchers/CMakeLists.txt
STMatchers/Makefile
ormat/CMakeLists.txt
ormat/Makefile
rontend/CMakeLists.txt
rontend/Makefile
ooling/CMakeLists.txt
ooling/Makefile
b1ba0efc3d1dc1daa5d82c40bc504e1f368c4fa0 19-Jan-2013 Chandler Carruth <chandlerc@gmail.com> Re-sort all the headers. Lots of regressions have crept in here.
Manually fix the order of UnwrappedLineParser.cpp as that one didn't
have its associated header as the first header.

This also uncovered a subtle inclusion order dependency as CLog.h didn't
include LLVM.h to pick up using declarations it relied upon.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172892 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4c1281283513ff5cd37ee224639e2f3853ec9ea8 18-Jan-2013 Manuel Klimek <klimek@google.com> Fixes issues around pulling in the next line in simple if statements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172822 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
525fe168c25a8273899281c5d2326c722fc3f2a5 18-Jan-2013 Manuel Klimek <klimek@google.com> Fixes problems with line merging in the face of preprocessor directives.

This patch prepares being able to test for and fix more problems (see
FIXME in the test for example).

Previously we would output unwrapped lines for preprocessor directives
at the point where we also parsed the hash token. Since often
projections only terminate (and thus output their own unwrapped line)
after peeking at the next token, this would lead to the formatter seeing
the preprocessor directives out-of-order (slightly earlier). To be able
to correctly identify lines to merge, the formatter needs a well-defined
order of unwrapped lines, which this patch introduces.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172819 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c79afdae8a2e12d1e8f27a2ae0a43dfca3b8283b 18-Jan-2013 Daniel Jasper <djasper@google.com> Reduce penalty for splitting between ")" and ".".

').' is likely part of a builder pattern statement.
This is based upon a patch developed by Nico Weber. Thank you!

Before:
int foo() {
return llvm::StringSwitch<Reference::Kind>(name).StartsWith(
".eh_frame_hdr", ORDER_EH_FRAMEHDR).StartsWith(
".eh_frame", ORDER_EH_FRAME).StartsWith(".init", ORDER_INIT).StartsWith(
".fini", ORDER_FINI).StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

After:
int foo() {
return llvm::StringSwitch<Reference::Kind>(name)
.StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
.StartsWith(".eh_frame", ORDER_EH_FRAME)
.StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
.StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

Probably not ideal, but makes many cases much more readable.

The changes to overriding-ftemplate-comments.cpp don't seem better or
worse. We should address those soon.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172804 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7d1185de4405637094d64f960f2b6d01f8bce04e 18-Jan-2013 Daniel Jasper <djasper@google.com> Also align trailing line comments in include directives.

Before:
#include <a> // for x
#include <a/b/c> // for yz
After:
#include <a> // for x
#include <a/b/c> // for yz

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172799 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dcc2a6269ba86285b20ee76487807b9cd20cefbe 18-Jan-2013 Daniel Jasper <djasper@google.com> Let the formatter align trailing line comments where possible.

Before:
int a; // comment
int bbbbb; // comment

After:
int a; // comment
int bbbbb; // comment

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172798 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
94fb72932c806c549f5c51f4bfa99fa7b481324a 18-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: After case blocks, "break" goes on the same line as the "}", PR14907.

Before:
switch (foo) {
case a: {
int a = g();
h(a);
}
break;
}

Now:
switch (foo) {
case a: {
int a = g();
h(a);
} break;
}



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172789 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5dfe9b47a5d52b97ba6452d40edb7ea0e04c4435 18-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Enable @encode test.

This doesn't work right with pointers to pointers, but that's likely just a
dupe of PR14884.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172785 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6a21a556a728325e1fae4387128d149927a4fbff 18-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: The contents of @selector() should be formatted as a selector.

Before: @selector(foo: )
Now: @selector(foo:)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172781 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5096a44f2ec5ab9e5b801424e04919f4fcf29f1d 17-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Get bit tests in ifs right.

It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.

Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.

Before:
if (a& b)
if (int* b = f())

Now:
if (a & b)
if (int* b = f())



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172731 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
60ca75d4d1878f8a45799316f462d4d0114238b4 17-Jan-2013 Daniel Jasper <djasper@google.com> Allow breaking after the trailing const after a function declaration.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const
GUARDED_BY(aaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172718 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2c6cc48a38455969b4602a2d37ce620101b7eebc 17-Jan-2013 Daniel Jasper <djasper@google.com> Improve handling of comments in static initializers.

Also adding more tests.

We can now keep the formatting of something like:

static SomeType type = { aaaaaaaaaaaaaaaaaaaa, /* comment */
aaaaaaaaaaaaaaaaaaaa /* comment */,
/* comment */ aaaaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaa, // comment
aaaaaaaaaaaaaaaaaaaa };

Note that the comment in the first line is handled like a trailing line comment
as that is likely what the user intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172711 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
aab60054553c35f6761cf96f3476997f250f1f4a 17-Jan-2013 Nico Weber <nicolasweber@gmx.de> Revert most of r172140.

r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions
as reference. But now that I look at that link again, it seems I didn't
read it very carefully the first time round.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172703 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
16618240a8a28d84de6d950f89145a78645e26e7 16-Jan-2013 Daniel Jasper <djasper@google.com> Fix a bug where we would move a following line into a comment.

Before: Constructor() : a(a), // comment a(a) {}
After: Constructor() : a(a), // comment
a(a) {}

Needed this as a quick fix. Will add more tests for this in a future
commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172624 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1f2b07898f66524fd7fe1b177fb0d7c58016e93b 16-Jan-2013 Daniel Jasper <djasper@google.com> Fix parsing error in conditional expressions.

We used to incorrectly parse

aaaaaa ? aaaaaa(aaaaaa) : aaaaaaaa;

Due to an l_paren being followed by a colon, we assumed it to be part of
a constructor initializer. Thus, we never found the colon belonging to
the conditional expression, marked the line as bing incorrect and did
not format it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172621 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
48bd7b72b8911147ec9bdeaa8ebb211543fd23a9 16-Jan-2013 Daniel Jasper <djasper@google.com> Improve understanding of unary operators.

Before: int x = ** a;
After: int x = **a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172619 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
df3736aa70443ac0f33af094989b4ba88d73f568 16-Jan-2013 Daniel Jasper <djasper@google.com> Disable inlining of short ifs in Google style.

Various reasons seem to speak against it, so I am disabling this for
now.

Changed tests to still test this option.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172618 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
0df6acdf4f6faf7579775a739e1c09448c076c0f 16-Jan-2013 Daniel Jasper <djasper@google.com> Add option to avoid "bin-packing" of parameters.

"Bin-packing" here means allowing multiple parameters on one line, if a
function call/declaration is spread over multiple lines.

This is required by the Chromium style guide and probably desired for
the Google style guide. Not making changes to LLVM style as I don't have
enough data.

With this enabled, we format stuff like:
aaaaaaaaaaaaaaa(aaaaaaaaaa,
aaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaa).aaaaaaaaaaaaaaaaaa();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172617 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ca547dbbb1e10c801158f2eecaf3d49e1071b0e3 16-Jan-2013 Manuel Klimek <klimek@google.com> Add debugging support for split penalties.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172616 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
51c23fa34bb29b77fc0867b233147d3427757573 16-Jan-2013 Alexander Kornienko <alexfh@google.com> Clang Format: A couple of tests for the trailing stuff case

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172607 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d881875b6c78386c4f0da911c1110f9ed1235c6a 16-Jan-2013 Alexander Kornienko <alexfh@google.com> Clang Format: Handle missing semicolon

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172606 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6b825c2e1e691deca41c6f979164b5d20c203593 16-Jan-2013 Daniel Jasper <djasper@google.com> Never merge < and ::, as it produces different tokens.

Before: vector<::Type> t;
After: vector< ::Type> t;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172601 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
55b08e769f05987942c307fde8eb168df01e504f 16-Jan-2013 Daniel Jasper <djasper@google.com> Remove errors were if statements were incorrectly put on a single line.

Before: if (a) // This comment confused clang-format f();
After: if (a) // No more confusion
f();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172600 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
407a31afffc936291d719665b9edb72532c0ed3b 15-Jan-2013 Manuel Klimek <klimek@google.com> Fix formatting of preprocessor directives (incluces, warnings & errors).

Treat tokens inside <> for includes and everything from the second token
of a warning / error on as an implicit string literal, e.g. do not
change its whitespace at all.

Now correctly formats:
#include < path with space >
#error Leave all white!!!!! space* alone!

Note that for #error and #warning we still format the space up to the
first token of the text, so:
# error Text
will become
#error Text

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172536 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b369c2cb31358f749b9ced97440a6c457f38eaae 15-Jan-2013 Daniel Jasper <djasper@google.com> Improve operator kind detection in presence of comments.

We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.

Example:
Before: int a = /**/ - 1;
After: int a = /**/ -1;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172533 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
47ea7f64108163491ed74dc746c8d94e10764704 15-Jan-2013 Manuel Klimek <klimek@google.com> Fixes various bugs around the keywords class, struct and union.

This switches to parsing record definitions only if we can clearly
identify them. We're specifically allowing common patterns for
visibility control through macros and attributes, but we cannot
currently fix all instances. This fixes all known bugs we have though.

Before:
static class A f() {
return g();
} int x;

After:
static class A f() {
return g();
}
int x;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172530 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2c7739e3cbf1357c0ef8d894045a300331053565 14-Jan-2013 Manuel Klimek <klimek@google.com> Fixes formatting of nested brace initializers.

We now format this correctly:
Status::Rep Status::global_reps[3] = {
{ kGlobalRef, OK_CODE, NULL, NULL, NULL },
{ kGlobalRef, CANCELLED_CODE, NULL, NULL, NULL },
{ kGlobalRef, UNKNOWN_CODE, NULL, NULL, NULL }
};

- fixed a bug where BreakBeforeClosingBrace would be set on the wrong
state
- added penalties for breaking between = and {, and between { and any
other non-{ token

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172433 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6f5bb2c93c31a7977382c5079d85db8ca3267cd0 14-Jan-2013 Daniel Jasper <djasper@google.com> Make single-line if statements optional.

Now, "if (a) return;" is only allowed, if this option is set.

Also add a Chromium style which is currently identical to Google style
except for this option.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172431 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fd0ca976bd55167364ba1178e884d275cc6ef30b 14-Jan-2013 Daniel Jasper <djasper@google.com> Fix a bug in the line merging.

If the first line of a merge would exactly fit into the column limit,
an unsigned overflow made us not break.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172426 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2b9c10bd8f80c004756308a5163fa7eda27eb5ce 14-Jan-2013 Daniel Jasper <djasper@google.com> Fix bug that would lead to joining preprocessor directives.

Before: #include "a.h" #include "b.h"
After: #include "a.h"
#include "b.h"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172424 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e0b15ea7edeceb41decddfeabaf6fac935ed7baf 14-Jan-2013 Daniel Jasper <djasper@google.com> Put simple preprocessor directives on a single line.

Before: #define A \
A
After: #define A A

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172423 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
feb18f5ff2cfa952fec4e751eb9665706c4674af 14-Jan-2013 Daniel Jasper <djasper@google.com> Put short if statements on a single line.

Before: if (a)
return;
After: if (a) return;

Not yet sure, whether this is always desired, but we can add options and
make this a style parameter as we go along.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172413 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4abbb535f0f050aea6373e26e769643c3c61a9b1 14-Jan-2013 Daniel Jasper <djasper@google.com> Improve understanding post increment and decrement.

Before: (a->f()) ++;
a[42] ++;
After: (a->f())++;
a[42]++;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172400 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a4ae9f30ef7bccdaa3feef8036af07fbb91f107c 14-Jan-2013 Alexander Kornienko <alexfh@google.com> Custom DiagnosticConsumer parameter of reformat() + silence diagnostics in unit tests.

Summary:
Added tests for clang-format diagnostics. Added DiagnosticConsumer
argument to clang::format::reformat().

Reviewers: klimek, djasper

Reviewed By: djasper

CC: cfe-commits, thakis, rafael.espindola

Differential Revision: http://llvm-reviews.chandlerc.com/D290

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172399 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1b6f4bd8d7e75e775053b1cb1281c6a127746e93 14-Jan-2013 Manuel Klimek <klimek@google.com> Adds some more tests for * and &.

While reviewing r172303 I noticed that I wasn't sure whether we still
format those correctly and didn't see any tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172396 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
efaddc0705cfc7c36b76da9ebc33b69843e31996 14-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add a test for bitfields.

They work fine, but this fifth use of colons (after labels, in ?:,
in initalizer lists in constructors, in objc method expressions, and in
bitfields) wasn't covered by tests yet.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172377 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
487f64b2ae3f991216eb1346a62ea18156f0b519 13-Jan-2013 Daniel Jasper <djasper@google.com> Stronger respect the input codes line breaks wrt. comments.

clang-format should not change whether or not there is a line break
before a line comment as this strongly influences the percieved binding.

User input: void f(int a,
// b is awesome
int b);
void g(int a, // a is awesome
int b);
Before: void f(int a, // b is awesome
int b);
void g(int a, // a is awesome
int b);
After: <unchanged from input>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172361 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1774603d8b34f86bd254d85a125592fcb323a488 13-Jan-2013 Daniel Jasper <djasper@google.com> Format unions like structs and classes.

Note that I don't know whether we should put {} on a single line in this
case, but it is probably a theoretical issue as in practice such
structs, classes or unions won't be empty.

Before: union A {}
a;
After: union A {} a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172355 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4e9008ac62b4c403c5c30724953664dcbb03d02e 13-Jan-2013 Daniel Jasper <djasper@google.com> Always put a space after ",".

I am not aware of a case where that would be wrong. The specific case I
am fixing are function parameters wrapped in parenthesis (e.g. in
macros).

Before: function(a,(b));
After: function(a, (b));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172351 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8134e1e575f862799c361b9c146eae7672010fa0 13-Jan-2013 Daniel Jasper <djasper@google.com> Don't put spaces around hyphens in include paths.

Before: #include <a - a>
After: #include <a-a>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172350 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4981bd0ca215570ef1e2e1c1c64a2c399069dc42 13-Jan-2013 Daniel Jasper <djasper@google.com> Improve identification of c-style casts.

A ")" before any of "=", "{" or ";" won't be a cast. This fixes issues
with the formatting of unnamed parameters.

Before: void f(int *){}
After: void f(int *) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172349 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cd458330d0cdced36a49f1d66cd9c5908f46d939 13-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Don't insert a space before unary operators after selector names.

Before:
[color getRed: &r green: &g blue: &b alpha: &a];

Now:
[color getRed:&r green:&g blue:&b alpha:&a];



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172337 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6292dd4be36f2dac5df121a8c81c043f6c6243cf 13-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add a test for @selector in an ObjC method expression, which happens to work already.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172335 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ea86563962102149609f6442491d884bc337a175 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove debugging junk I accidentally landed in r172333.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172334 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e8ccc81a9f66361450148338b8457dd2c6ad11de 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Prefer breaking before ObjC selector names over breaking at their ':'

Before:
if ((self = [super initWithContentRect:contentRect styleMask:
styleMask backing:NSBackingStoreBuffered defer:YES])) {

Now:
if ((self = [super initWithContentRect:contentRect styleMask:styleMask
backing:NSBackingStoreBuffered defer:YES])) {




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172333 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cfa88f893915ceb8ae4ce2f17c46c24a4d67502f 12-Jan-2013 Dmitri Gribenko <gribozavr@gmail.com> Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.h
ooling/CompilationDatabaseTest.cpp
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
ooling/ToolingTest.cpp
b312314cd7aaf8a4c3902aa28c8bc0a9662a8e9b 12-Jan-2013 Daniel Jasper <djasper@google.com> Fix incorrect comparison operator causing loooong formatting times.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172308 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
774b97312ddffe64435a1428f904211ee46cf289 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove a redundant CurrentLineType check.

The containing if checks for this already. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172306 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bcfdd263b79c766db9154b009bd831ef83090c83 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Initial support for formatting Objective-C method expressions.

This follows the approach suggested by djasper in PR14911: When a '[' is
seen that's at the start of a line, follows a binary operator, or follows one
of : [ ( return throw, that '[' and its closing ']' are marked as
TT_ObjCMethodExpr and every ':' in that range that isn't part of a ternary
?: is marked as TT_ObjCMethodExpr as well.

Update the layout routines to not output spaces around ':' tokens that are
marked TT_ObjCMethodExpr, and only allow breaking after such tokens, not
before.

Before:
[self adjustButton : closeButton_ ofKind : NSWindowCloseButton];

Now:
[self adjustButton:closeButton_ ofKind:NSWindowCloseButton];



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172304 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5e9f91c342f8efffe0423d516997ddbc408c9f53 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: * and & are binary operators before ( and [.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172303 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2355cebe3847acd4ce175e3a88788b8effd93c6e 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: * and & are binary operators after ) and ].

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172302 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cc191d1980101bba47d3d67acf782890076fa5c3 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: + and - after { are unary operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172301 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1a4191d0697098c424646654784399b839f87bc4 12-Jan-2013 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests: Fixup corresponding to r172290.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172295 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
7d37b8bb101c872801e6d2ce82eec377a94ce042 12-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: add a test for :? in []

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172289 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
67015ed2f40d6f69ee9e15d79aa88530f4b4afe2 11-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Format ObjC static and instance methods consistently, add a test for that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172254 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6eca03fcac1e408470d48e6309a280d3681f717d 11-Jan-2013 Manuel Klimek <klimek@google.com> Fix crashes in UnwrappedLineParser on missing parens.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172239 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d5688cf3e314819ca196053ac245c19a7c321332 11-Jan-2013 Manuel Klimek <klimek@google.com> Fix single-line optimization for ObjC.

Puts blocks always into multiple lines when they start with an ObjC
keyword or minus.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172238 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d465843f5376c7c1574fe61338cbf3dc50684d5b 11-Jan-2013 Manuel Klimek <klimek@google.com> Fix crash on invalid.

if { foo; }
would previously crash clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172232 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
606e07ecc0b7b0e01d23baa833b4b4c73af0d4f4 11-Jan-2013 Manuel Klimek <klimek@google.com> Fix parsing of initializer lists with elaborated type specifier.

Now we correctly parse and format:
verifyFormat("struct foo a = { bar };
int n;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172229 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
517e894c56211f57c487bdaba8ead0edc84396fe 11-Jan-2013 Manuel Klimek <klimek@google.com> Implements pulling simple blocks into a single line.

void f() { return 42; }

The final change that implements the feature.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172225 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
088dab50b76d235cd5b0e701048efccfcea3677e 11-Jan-2013 Daniel Jasper <djasper@google.com> Correct spacing around new and delete.

This fixes llvm.org/PR14913.

Before: A *a = new(placement) A;
After: A *a = new (placement) A;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172212 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7d19bc2c8882457e833dfe9741ac5a4a7198e46f 11-Jan-2013 Daniel Jasper <djasper@google.com> Improve handling of trailing declaration annotations.

Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) GUARDED_BY(
aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
GUARDED_BY(aaaaaaaaaaaaa);

Also did some formatting cleanups with clang-format on the way.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172200 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7e9bf8c249a5a9717447a00a8669596002a5569a 11-Jan-2013 Daniel Jasper <djasper@google.com> Improved formatting of constructor initializers

Added option to put each constructor initializer on its own line
if not all initializers fit on a single line. Enabling this for
Google style now as the style guide (arguable) suggests it. Not
sure whether we also want it for LLVM.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172196 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8e2999cd4cfcf6447ca1f6e41d5707305e2d8dd0 11-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove a fixme, Jordy says @synthesize is good as is.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172141 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cd52bdaaf076b0082c07c6b3d88937fb737054f1 11-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Put spaces in ObjC method decls in the right place for Google style.

Objective-C method declarations look like this:

- (returntype)name:(type)argname anothername:(type)arg2name;

In google style, there's no space after the leading '-' but one after
"(returntype)" instead (but none after the argument types), see
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions

Not inserting the space after '-' is easy, but to insert the space after the
return type, the formatter needs to know that a closing parenthesis ends the
return type. To do this, I tweaked the code in parse() to check for this, which
in turn required moving detection of TT_ObjCMethodSpecifier from annotate() to
parse(), because parse() runs before annotate().

(To keep things interesting, the return type is optional, but it's almost
always there in practice.)

http://llvm-reviews.chandlerc.com/D280



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172140 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7084823f8ec4367019940b26245e01684b62c7e1 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: No spaces around '=' in @property lines.

Before:
@property(assign, getter = isEditable) BOOL editable;

Now:
@property(assign, getter=isEditable) BOOL editable;

It'd be nice if some Apple person could let me know if spaces are preferred
around '=' in @synthesize lines (see FIXME in the test).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172110 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e0fd429757fb4cf801643200b2fb709cd7a957ad 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add test for template and protocol parameters in ObjC method declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172100 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5f500df1b28e6b1c49d4256dda130ecd8696ea2e 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatting: In @implementation etc lines, put a space before protocol lists.

Don't do this in Google style though:
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Protocols

Most other places (function declarations, variable declarations) still get
this wrong, and since this looks very similiar to template instantiations to
the lexer (`id <MyProtocol> a = ...`), it's going to be hard to fix in some
places.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172099 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
81ed2f1cd7202e84bf1f3868a60a36904499c94c 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Don't put a space in ObjC number literals like @+50

Before:
@ -4.5

Now:
@-4.5



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172095 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ed91bbaa8c4c92a1c94c9a7a5f4141551718cf6b 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add space before '(' in @implemenation, @interface, @protocol lines

The first token in @implementation, @interface, and @protocol lines is now
marked TT_ObjCDecl, and lines starting with a TT_ObjCDecl token are now marked
LT_ObjCMethodDecl.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172093 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c8c8a478639f1474f4c53d12befc405934083633 10-Jan-2013 Manuel Klimek <klimek@google.com> Fixes layout of right braces.

We now decide whether a newline should go before the closing brace
depending on whether a newline was inserted after the opening brace.

For example, we now insert a newline before '};' in:
static SomeClass WithALoooooooooooooooooooongName = {
100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
};
... while not inserting a newline here:
static SomeClass = { a, b, c, d, e, f, g, h, i, j,
looooooooooooooooooooooooooooooooooongname,
looooooooooooooooooooooooooooooong };

Also fixes the formating of (column limit 25):
int x = {
avariable,
b(alongervariable)
};

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172076 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2851c16443dcdb9d8bb509d321fb827a560b47bc 10-Jan-2013 Manuel Klimek <klimek@google.com> Fixes formatting of function calls etc inside an initializer list.

We're now formatting (column limit 25):
int x = {
avariable,
b(alongervariable) };

This also fixes:
Aaa({
int i;
}, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
ccccccccccccccccc));
... where we would previously break after the '},'.

Putting the closing curly into an extra line when there's a break
directly after the first curly will be done in a subsequent patch.

Paired with djasper.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172070 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
36fab8d70eee342d66e03c9b09c029f126196103 10-Jan-2013 Manuel Klimek <klimek@google.com> Do not add newline in empty blocks.

void f() {}
now gets formatted in one line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172067 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
46ef852618b18bc79e403b37a12c9b692e76126b 10-Jan-2013 Daniel Jasper <djasper@google.com> Improvements to function type and ObjC block formatting.

Before: int (^myBlock) (int) = ^(int num) {}
A<void ()>;
int (*b)(int);

After: int (^myBlock)(int) = ^(int num) {}
A<void()>;
int(*b)(int);

For function types and function pointer types, this patch only makes
the behavior consistent (for types that are keywords and other types).
For the latter function pointer type declarations, we'll probably
want to add a space after "int".

Also added LangOpts.Bool = 1, so we handle "A<bool()>" appropriately
Moved the LangOpts-settings to a public place for use by tests
and clang-format binary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172065 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
bb42bf1a8bfd18fa2beec7fcbcb73f738fb455ba 10-Jan-2013 Manuel Klimek <klimek@google.com> Fix layout of blocks inside statements.

Previously, we would not indent:
SOME_MACRO({
int i;
});
correctly. This is fixed by adding the trailing }); to the unwrapped
line starting with SOME_MACRO({, so the formatter can correctly match
the braces and indent accordingly.

Also fixes incorrect parsing of initializer lists, like:
int a[] = { 1 };

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172058 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5cf7cf317f684dc61b8a0e4476440b5635b80db4 10-Jan-2013 Daniel Jasper <djasper@google.com> Improve clang-format's understanding of casts.

This fixes llvm.org/PR14684.

Before: int *pa = (int *) & a;
After: int *pa = (int *)&a;

We still don't understand all kinds of casts. I added a FIXME to
address that.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172056 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
700e710544a50ec63f984b9b098530bf9107920a 10-Jan-2013 Daniel Jasper <djasper@google.com> Do more error checking for '{}'.

This fixes llvm.org/PR14883, where clang-format would run into an
assertion on:

void f() { return } 42

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172049 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
880e538536d1a7597eb5805d67a08e3941577c7f 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Remove unused @-formatting code.

@optional @property is put on two different unwrapped lines now, so this is no
longer necessary.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172024 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b530fa374a8d4d96e61bf1dae8f4a73f4b3d2436 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: @optional and @required go on their own line.

Previously:
@protocol myProtocol
- (void)mandatoryWithInt:(int)i;
@optional - (void) optional;
@required - (void) required;
@end

Now:
@protocol myProtocol
- (void)mandatoryWithInt:(int)i;
@optional
- (void)optional;
@required
- (void)required;
@end



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172023 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
50767d8c8f2f667255bdb99692c0467ce992bc67 10-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add support for @implementation.

Just reuse the @interface code for this. It accepts slightly more than
necessary (@implementation cannot have protocol lists), but that's ok.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172019 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
049c44767370b7257d17a5c32d407f19efa01c6f 09-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Make parseObjCUntilAtEnd() actually work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172003 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1abe6ea5b8961a0fc14c2e0bdbd7451f643ca065 09-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatting: Add support for @protocol.

Pull pieces of the @interface code into reusable methods.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172001 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
27d1367871a6eab347346497e87ea1adb2fd15a5 09-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add support for @interface.

Previously:
@interface Foo + (id)init; @end

Now:
@interface Foo
+ (id)init;
@end

Some tweaking remains, but this is a good first step.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171995 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
526ed11ad9743c773df76bd1649d33fb92c2b8cb 09-Jan-2013 Manuel Klimek <klimek@google.com> Enables layouting unwrapped lines around preprocessor directives.

Previously, we'd always start at indent level 0 after a preprocessor
directive, now we layout the following snippet (column limit 69) as
follows:

functionCallTo(someOtherFunction(
withSomeParameters, whichInSequence,
areLongerThanALine(andAnotherCall,
B
withMoreParamters,
whichStronglyInfluenceTheLayout),
andMoreParameters),
trailing);

Note that the different jumping indent is a different issue that will be
addressed separately.

This is the first step towards handling #ifdef->#else->#endif chains
correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171974 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3fc0bb779e751de71166c20a365cd5c28c3de8ed 09-Jan-2013 Daniel Jasper <djasper@google.com> Only align after assignments on the top level.

This fixes llvm.org/PR14870 and we no longer mess up:
template <typename T1, typename T2 = char, typename T3 = char,
typename T4 = char>
void f();

It removes the nice aligment for assignments inside other expressions,
but I am not sure those are actually practically relevant. If so, we can
fix those later.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171966 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ceb99ab9d721848c0851c59f3fdd9c1ca85c58be 09-Jan-2013 Daniel Jasper <djasper@google.com> Don't simply give up when exceeding 80cols, choose an "ok" option.

This addresses llvm.org/PR14847.

We can now format something like:
int aaaaaaaaaaaaaaaaaaaaaaaaaaa =
// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

clang-format unavoidably exceeds the column limit, but does not just
flush everything into a single line. Moreover, it tries to minimize the
number of characters beyond the column limit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171964 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d64f73812f3e6473ef8b6b6ec909bb9d8a510843 09-Jan-2013 Daniel Jasper <djasper@google.com> Correctly format wrapped function call parameters in templated functions.

This fixes llvm.org/PR14846.

Before:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
int aaaaaaaaaaaaaaaaa);

After:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
int aaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171963 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
043835aa876b1edeca0a05def0cc0989faa15892 09-Jan-2013 Daniel Jasper <djasper@google.com> Allow comments in the middle of statements to be on their own line.

This fixes llvm.org/PR14860.

Before, we messed up the format of:
if (DeclaratorInfo.isFunctionDeclarator() &&
//getDeclSpecContextFromDeclaratorContext(Context) == DSC_top_level &&
Tok.is(tok::semi) && NextToken().is(tok::l_brace)) {
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171961 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
886568dc24eb0a1ccf73bf32d1eafa8fd4008cc6 09-Jan-2013 Daniel Jasper <djasper@google.com> Fix ObjC block declarations.

Before: int ( ^ Block1) (int, int) = ^ (int i, int j)
After: int (^Block1) (int, int) = ^(int i, int j)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171959 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9c837d05c9e6d6971900d36b1e462ed3666b7487 09-Jan-2013 Daniel Jasper <djasper@google.com> Improve formatting of conditional operators.

This addresses llvm.org/PR14864.

We used to completely mess this up and now format as:
Diag(NewFD->getLocation(),
getLangOpts().MicrosoftExt ? diag::ext_function_specialization_in_class :
diag::err_function_specialization_in_class)
<< NewFD->getDeclName();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171957 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3a2673e2e93376da249fae8b4aa805a6118ddd4e 08-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: More tests for already-passing ObjC bits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171892 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
2db356d619fbf56e342fbc3fd5301e2e539e51b6 08-Jan-2013 Daniel Jasper <djasper@google.com> Don't break after unary operators.

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171890 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cb4d690820295d93c1cea6c13fb4409b8c1db2cf 08-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Format @ literals better. Array and dictionary literals need more work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171887 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c31689a4aa1e1a534482349fabaebedaae2ea17d 08-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: More ObjC tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171883 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cf4a79c3ec035521170d1913b7918a2f962118e1 08-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add tests for some ObjC bits that happen to be formatted correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171875 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
765561ff8fa636cc88d133b85ecb592094104554 08-Jan-2013 Daniel Jasper <djasper@google.com> Don't put spaces around ##.

In Clang/LLVM this seems to be the more common formatting for ##s. There
might still be case that we miss, but we'll fix those as we go along.

Before:

#define A(X)
void function ## X();

After:

#define A(X)
void function##X();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171862 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
26f7e78018ed6ce8aa11b5eef94c772ca4ee48bf 08-Jan-2013 Daniel Jasper <djasper@google.com> Change the data structure used in clang-format.

This is a first step towards supporting more complex structures such
as #ifs inside unwrapped lines. This patch mostly converts the array-based
UnwrappedLine into a linked-list-based UnwrappedLine. Future changes will
allow multiple children for each Token turning the UnwrappedLine into a
tree.

No functional changes intended.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171856 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6092d4ed09a2368871993d9a45717f24394329ce 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Support @public/@protected/@package/@private.

@package is an Objective-C 2 feature, so turn on ObjC2 as well.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171766 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
de7685487c5d628dd9fe64c4f861cd1888f50fc7 07-Jan-2013 Manuel Klimek <klimek@google.com> Fix parsing of variable declarations directly after a class / struct.

Previous indent:
class A {
}
a;
void f() {
};

With this patch:
class A {
} a;
void f() {
}
;

The patch introduces a production for classes and structs, and parses
the rest of the line to the semicolon after the class scope.
This allowed us to remove a long-standing wart in the parser that would
just much the semicolon after any block.
Due to this suboptimal formating some tests were broken.

Some unrelated formatting tests broke; those hit a bug in the ast
printing, and need to be fixed separately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171761 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a9ccdd1b8ef31d1942193ffa6bc32781055cf493 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Add tests for try/catch. Let 'throw' start an expression.

Before:
throw a *b;

Now:
throw a * b;



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171754 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d0af4b46741560cf2e52d819e1f3a2506a1e7a3c 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Formatter: Don't put spaces betwen @ and objc keywords.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171753 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4a293a2edaf1b24cbc810c162a4a6a76713d8471 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Test all @keywords. Turns out some of them are not formatted correctly yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171752 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
581f5577e8e42d72faef571e0e15ddb5da661f5a 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Slightly expand the @ test to cover whitespace between @ and keyword.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171751 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
efcfe733970b994b75ba5fc728a97357b3a6a0e1 07-Jan-2013 Nico Weber <nicolasweber@gmx.de> Add a test that checks that the formatter doesn't discard '@' with ObjC1 set.

Also set ObjC1 in the formatter tests.

The only effect of this flag in the lexer is that '@' now gets turned into
tok::at instead of tok::unknown.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171742 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cd162384a552ef4e4913244f4f14b9a3e5a791e1 07-Jan-2013 Daniel Jasper <djasper@google.com> Reformat clang-formats source code.

All changes done by clang-format itself. No functional changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171732 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9cda8000434be3360abb38fe1690fa24ae3d48be 07-Jan-2013 Daniel Jasper <djasper@google.com> Prefer not to break after assignments.

This addresses llvm.org/PR14830.

Before:
unsigned Cost =
TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),
SI->getPointerAddressSpace());
CharSourceRange LineRange =
CharSourceRange::getTokenRange(TheLine.Tokens.front().Tok.getLocation(),
TheLine.Tokens.back().Tok.getLocation());

After:
unsigned Cost = TTI.getMemoryOpCost(I->getOpcode(), VectorTy,
SI->getAlignment(),
SI->getPointerAddressSpace());
CharSourceRange LineRange = CharSourceRange::getTokenRange(
TheLine.Tokens.front().Tok.getLocation(),
TheLine.Tokens.back().Tok.getLocation());

This required rudimentary changes to static initializer lists, but we
are not yet formatting them in a reasonable way. That will be done in a
subsequent patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171731 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7ad4effaa96905ef9dbc3815760b06b1d1639390 07-Jan-2013 Daniel Jasper <djasper@google.com> Add style option for number of spaces before trailing comments.

In LLVM style, a single space should be enough. In Google style, two
spaces are required.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171725 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
71607512cb70db3c1be8f0287153b681531687fc 07-Jan-2013 Daniel Jasper <djasper@google.com> Do not break before "0" in pure virtual function declarations.

Before:
virtual void write(ELFWriter *writer, OwningPtr<FileOutputBuffer> &buffer) =
0

After:
virtual void write(ELFWriter *writerrr,
OwningPtr<FileOutputBuffer> &buffer) = 0;

This addresses llvm.org/PR14815.

To implement this I introduced a line type during parsing and moved the
definition of TokenType out of the struct for increased readability.
Should have done the latter in a separate patch, but it would be hard to
pull apart now.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171724 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
dd5b1018d97a9666da92d320485a727ac63ee89a 07-Jan-2013 Manuel Klimek <klimek@google.com> Fix incorrect FIXME.

The case that we wanted to write a test for cannot happen, as the
UnwrappedLineParser already protects against it. Added an assert to
prevent regressions of that assumption.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171720 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d544c574ccbcbfcb5b3c3edd19956143826008cf 07-Jan-2013 Manuel Klimek <klimek@google.com> Do not ever allow using the full line in preprocessor directives.

We would format:
#define A \
int f(a); int i;
as
#define A \
int f(a);\
int i

The fix will break up macro definitions that could fit a line, but hit
the last column; fixing that is more involved, though, as it requires
looking at the following line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171715 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6cf581436e9e59a18f6a362027a69eaaa9b67597 07-Jan-2013 Manuel Klimek <klimek@google.com> Fix layouting of single-line-comments preceded by an escaped newline.

Previously, we'd format
int i;\
// comment
as
int i; // comment

The problem is that the escaped newline is part of the next token, and
thus the raw token text of the comment doesn't start with "//".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171713 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9541938d4e3b9cbafdf0e1a28900c535b82767a4 07-Jan-2013 Manuel Klimek <klimek@google.com> Fix layouting of tokens with a leading escaped newline.

If a token follows directly on an escaped newline, the escaped newline
is stored with the token. Since we re-layout escaped newlines, we need
to treat them just like normal whitespace - thus, we need to increase
the whitespace-length of the token, while decreasing the token length
(otherwise the token length contains the length of the escaped newline
and we double-count it while indenting).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171706 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
46a46a20a3ec397192550915964cb227e87b79b2 07-Jan-2013 Daniel Jasper <djasper@google.com> Put a higher penalty on breaking before "." or "->".

This fixes llvm.org/PR14823.

Before:
local_state->SetString(prefs::kApplicationLocale, parent_local_state
->GetString(prefs::kApplicationLocale));
After:
local_state->SetString(
prefs::kApplicationLocale,
parent_local_state->GetString(prefs::kApplicationLocale));

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171705 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a5342db6fcc6ee3fae084f584ecb019726de9cca 06-Jan-2013 Manuel Klimek <klimek@google.com> Fixes handling of unbalances braces.

If we find an unexpected closing brace, we must not stop parsing, as
we'd otherwise not layout anything beyond that point.

If we find a structural error on the highest level we'll not re-indent
anyway, but we'll still want to format within unwrapped lines.

Needed to introduce a differentiation between an expected and unexpected
closing brace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171666 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f6fd00b12ae7d89436d32851c9bcc8dd3d046ad3 05-Jan-2013 Manuel Klimek <klimek@google.com> Fixes parsing of hash tokens in the middle of a line.

To parse # correctly, we need to know whether it is the first token in a
line - we can deduct this either from the whitespace or seeing that the
token is the first in the file - we already calculate this information.
This patch moves the identification of the first token into the
getNextToken method and stores it inside the FormatToken, so the
UnwrappedLineParser can stay independent of the SourceManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171640 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c37b4d60f926bf440dfcc312bd6482fed3176e33 05-Jan-2013 Manuel Klimek <klimek@google.com> Fixes PR14801 - preprocessor directives shouldn't be indented

Uses indent 0 for macros for now and resets the indent state to the
level prior to the preprocessor directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171639 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
6f8424b79863fc9810393c95ecdee97895ab6f26 05-Jan-2013 Manuel Klimek <klimek@google.com> Fixes PR14811: Crash when formatting some macros

A preprocessor directive cannot be started while we're parsing one.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171635 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
d4397b99e2fcb189002d04410d7c3bf85ab4bba3 05-Jan-2013 Manuel Klimek <klimek@google.com> Various fixes to clang-format's macro handling.

Some of this is still pretty rough (note the load of FIXMEs), but it is
strictly an improvement and fixes various bugs that were related to
macro processing but are also imporant in non-macro use cases.

Specific fixes:
- correctly puts espaced newlines at the end of the line
- fixes counting of white space before a token when escaped newlines are
present
- fixes parsing of "trailing" tokens when eof() is hit
- puts macro parsing orthogonal to parsing other structure
- general support for parsing of macro definitions

Due to the fix to format trailing tokens, this change also includes a
bunch of fixes to the c-index tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171556 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9bb0d280faaedd528d2af7eeaf06c9f262345ad2 04-Jan-2013 Daniel Jasper <djasper@google.com> Correctly format dereference and address of in array parameters.

Before: InvalidRegions[ &R] = 0;
After: InvalidRegions[&R] = 0;

This fixes llvm.org/PR14793

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171522 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1f42f11870325d1869eb7d51b98ebf5e6d7bcc26 04-Jan-2013 Daniel Jasper <djasper@google.com> Let the formatter ignore UnwrappedLines containing errors.

This prevents code like:

namespace {
class Foo {
Foo(
};
} // comment

from causing segfaults (see llvm.org/PR14774).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171495 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
060143e4ad7f80c4349d472c06a63a953650c2a9 02-Jan-2013 Manuel Klimek <klimek@google.com> Fixes multiple formatting bugs.

Fixes:
- incorrect handling of multiple consecutive preprocessor directives
- crash when trying to right align the escpaed newline for a line that
is longer than the column limit
- using only ColumnLimit-1 columns when layouting with escaped newlines
inside preprocessor directives

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171401 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5eda31ee30106c769b5829683761d42e6e50467f 02-Jan-2013 Daniel Jasper <djasper@google.com> Don't allow line breaks after template parameters.

This fixes llvm.org/PR14786.

We will need to split there as a last resort, but that should be done
consistently independent of whether the type is a template type or not.

Before:
template <typename T>
aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa<T>
::aaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
template <typename T>
aaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaa,
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171400 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ba3d3074e8ef4c4c05ac062b073b2e082e6a0206 02-Jan-2013 Daniel Jasper <djasper@google.com> Format */& as binary operator if followed by a unary operator.

This fixes llvm.org/PR14687.
Also fixes segfault for lines starting with * or &.

Before:
a *~b;
*a = 1; // <- this segfaulted

After:
a * ~b;
*a = 1; // no segfault :-)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171396 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a080a187fa7e538da3212c7d5e678e4b7ae03253 02-Jan-2013 Manuel Klimek <klimek@google.com> Fixes use of unescaped newlines when formatting preprocessor directives.

This is the first step towards handling preprocessor directives. This
patch only fixes the most pressing issue, namely correctly escaping
newlines for tokens within a sequence of a preprocessor directive.

The next step will be to fix incorrect format decisions on #define
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171393 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ef5b9c3d38a1f6d0921591cb2749e529a8cc4a2e 02-Jan-2013 Daniel Jasper <djasper@google.com> Correctly format pointers and references in casts.

This fixes llvm.org/PR14747.

Before: Type *A = (Type * ) P;
After: Type *A = (Type *) P;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171390 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1f0754bf761f7d4910348ce3aba867d34473bceb 02-Jan-2013 Daniel Jasper <djasper@google.com> Understand unary operators after "return" and "case".

This fixes llvm.org/PR14746.

Before: return - 1;
After: return -1;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171389 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9a64fb5690ba2b53c761def068e20ec64c584d96 02-Jan-2013 Daniel Jasper <djasper@google.com> Prefer splitting after "template <...>" and fix indentation.

This addresses llvm.org/PR14699

Before:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T> void looooooooooooooooooooongFunction(
int Paaaaaaaaaaaaaaaaaaaaram1, int Paaaaaaaaaaaaaaaaaaaaram2);

After:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T>
void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1,
int Paaaaaaaaaaaaaaaaaaaaram2);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171388 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
723f0304eaaf1aed20aece9021a1bb8578477e75 02-Jan-2013 Daniel Jasper <djasper@google.com> Prefer to break after operators over breaking after "(".

Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa && aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa &&
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171386 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
5d334407e68e45e3e7baa0cd140d4fd75e7483d6 02-Jan-2013 Daniel Jasper <djasper@google.com> Understand * and & in ternary expressions.

Before: "int a = b ? *c : * d;"
After: "int a = b ? *c : *d;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171358 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
4dc41def6129bcecd4d08e5ffafe021aa7b1fa2a 02-Jan-2013 Daniel Jasper <djasper@google.com> Don't break after pointer or reference specifier.

This fixes llvm.org/PR14717.
Buggy format:
TypeSpecDecl *
TypeSpecDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
IdentifierInfo *II, Type *T) {

Now changed to:
TypeSpecDecl *TypeSpecDecl::Create(ASTContext &C, DeclContext *DC,
SourceLocation L, IdentifierInfo *II,
Type *T) {

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171357 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
1f94f2b484dc74e09fe31dd5ea9d3f715be6c133 30-Dec-2012 Dmitri Gribenko <gribozavr@gmail.com> Formatter: parse and format inline namespaces like regular namespaces

This changes formatting from:

inline namespace X {
class A {
};
}

to:

inline namespace X {
class A {
};
}



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171266 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a4974cf6ae618f04d5dd7fc45bc18bff41ca86bf 24-Dec-2012 Daniel Jasper <djasper@google.com> Penalize tokens with a lower parenthesis level than the start of the line.

This prevents formattings like this (assuming "parameter" doesn't fit the line):
bool f = someFunction() && someFunctionWithParam(
parameter) && someOtherFunction();

Here, "parameter" - the start of line 2 - has a parenthesis level of 2, but
there are subsequent tokens ("&&" and "someOtherFunction") with a lower level.
This is bad for readability as "parameter" hides "someOtherFunction". With this
patch, this changes to:
bool f = someFunction() &&
someFunctionWithParam(parameter) &&
someOtherFunction();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171038 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cf225b67e66d7a85773b7bf7907c0fef4374c31b 24-Dec-2012 Daniel Jasper <djasper@google.com> Align RHS after assignments and return statements.

This changes:
int Result = a + // force break
b;
return Result + // force break
5;

To:
int Result = a + // force break
b;
return Result + // force break
5;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171032 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
f6aef6a25bd47f2a7bfc24938e29b746fdccdc72 24-Dec-2012 Daniel Jasper <djasper@google.com> Fix formatting over overloaded operators.

This fixes llvm.org/pr14686.

We used to add too many spaces for different versions of overloaded operator
function declarations/definitions. This patch changes, e.g.

operator *() {}
operator >() {}
operator () () {}

to

operator*() {}
operator>() {}
operator()() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171028 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e2c7acf58856fec94ed2b8089116e1ad80e3c30f 24-Dec-2012 Daniel Jasper <djasper@google.com> Take operator precedence into account when splitting lines.

With this patch, splitting after binary operators has a panelty corresponding
to the operator's precedence. We used to ignore this and eagerly format like:

if (aaaaaaaaaaaaaaaaaaaaaaaaa || bbbbbbbbbbbbbbbbbbbbbbbbb &&
ccccccccccccccccccccccccc) { .. }

With this patch, this becomes:

if (aaaaaaaaaaaaaaaaaaaaaaaaa ||
bbbbbbbbbbbbbbbbbbbbbbbbb && ccccccccccccccccccccccccc) { .. }

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171007 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
00d5a04dc0eaa0f067656033ab81fc352c5a991a 23-Dec-2012 Nico Weber <nicolasweber@gmx.de> libFormat: Teach the *& usage heuristic that "return" starts a rhs too.

"return a*b;" was formatted as "return a *b;" and is now formatted as "return a * b;".

Fixes PR14687 partially.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170993 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9b3f02c3526e31fcb9c41afef143eae73643e257 21-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Adding to FormatTest.cpp test for a very long ObjC method
declaration requiring formatting of wrap-arounds.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170946 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
b23ae0c5104a4fec4c2ff603143fe142ec409249 21-Dec-2012 Nico Weber <nicolasweber@gmx.de> format: Handle #import as include directive too.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170914 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cd1a32b1f02016fe5ebb1142aadccc54bbdf5d89 21-Dec-2012 Daniel Jasper <djasper@google.com> clang-format: No spaces around directory specifiers

This fixes PR14683. We used to format like this:
#include <a / b>

And this patch changes this to:
#include <a/b>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170910 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a324a0e673cf486de281c84af3f09ba58627bbd2 21-Dec-2012 Daniel Jasper <djasper@google.com> Basic support for formatting for-loops.

We used to not really format them. Now we do:

for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(),
SE = BB->succ_end();
SI != SE; ++SI) {

This is just one example and I am sure we still mess some of them up, but it
is a step forward.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170899 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
98e6b4a65fcc81b1be11f09837e0fc8fac85897b 21-Dec-2012 Daniel Jasper <djasper@google.com> Formatting fixes for PR14680

Also, some (automated) formatting fixes and slight cleanups.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170873 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
154120cde4f56ed04261bab302fdbbed1a7f080b 20-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Add objective-C style formatting to clang format and
use it to format xml declaration tags.
// rdar://12378714


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170727 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
88d158c631c4c08831855f601990f36f2234f975 20-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Provide couple of DeclPrint tests for my last patch.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170635 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
40902d817e5a73850045d8a0c9795bc5047ee000 20-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Audit DeclPrinter with -ast-dump on Cocoa.h and
fix any bad objectiveC syntax coming out of
DeclPrinter. This is on going. Also, introduce a new
PrintPolicy and use it as needed when declaration tag
is to be produced via DeclPrinter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170606 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
88b9521364735a6c9a7ccd23c5bd19d81a80cdd3 19-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> This is the libclang patch providing minimal API to
use clang's formatter. Currently, formatter is used
to format declaration tags for xml comments. Since formatter
is in flux and its change will break several of the clang comment
tests, only a single tests is formatted using this facility.
Doug has reviewed and approved it for check-in.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170467 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
1321eb593c8e13738dcaf72e409aa466c8cf6463 18-Dec-2012 Daniel Jasper <djasper@google.com> Better support for constructor initializers.

We used to format initializers like this (with a sort of hacky implementation):
Constructor()
: Val1(A),
Val2(B) {

and now format like this (with a somewhat better solution):
Constructor()
: Val1(A), Val2(B) {

assuming this would not fit on a single line. Also added tests.

As a side effect we now first analyze whether an UnwrappedLine needs to be
split at all. If not, not splitting it is the best solution by definition. As
this should be a very common case in normal code, not exploring the entire
solution space can provide significant speedup.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170457 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
e35ec2b10c2a0d53ae76a7a6c383fa6aaf7645bd 18-Dec-2012 Daniel Jasper <djasper@google.com> Make the format scrambler understand line comments.

This allows for writing tests including line comments easier and more readable.
We will need more of those tests in the future and also line comments are
useful to force line breaks in tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170446 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
9a0b494f999dfd47152565f7bbeaa69b3fef8feb 17-Dec-2012 Daniel Jasper <djasper@google.com> Add basic support for splitting before function calls if it can't be
avoided.

This required a minor modification of the memoization as now the
"CurrentPenalty" depends on whether or not we break before the current
token. Therefore, the CurrentPenalty should not be memoized but added
after retrieving a value from memory. This should not affect the runtime
behavior.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170337 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
05b1ac8791ee89fdf0b275631ab8118febc7c33d 17-Dec-2012 Daniel Jasper <djasper@google.com> Fix several formatting problems.

More specifically:
- Improve formatting of static initializers.
- Fix formatting of lines comments in enums.
- Fix formmating of trailing line comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170316 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
fc2929fdb7cce47daf5b2857a56013fad0257cb6 13-Dec-2012 Roman Divacky <rdivacky@freebsd.org> Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
specifies not to. Dont build ASTMatchers with Rewriter disabled and
StaticAnalyzer when it's disabled.

Without all those three, the clang binary shrinks (x86_64) from ~36MB
to ~32MB (unstripped).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170135 91177308-0d34-0410-b5e6-96231b3b80d8
akefile
e5d30e3b403539b10aaa52f03875a2243bf88904 11-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Extend stat query APIs to explicitly specify if the query is for
a file or directory, allowing just a stat call if a file descriptor
is not needed.

Doing just 'stat' is faster than 'open/fstat/close'.
This has the effect of cutting down system time for validating the input files of a PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169831 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
1d28caf3b5254e60d3e3a1d2d37e5df2e5924111 11-Dec-2012 Richard Smith <richard-llvm@metafoo.co.uk> PR14558: Compute triviality of special members (etc) at the end of the class
definition, rather than at the end of the definition of the set of nested
classes. We still defer checking of the user-specified exception specification
to the end of the nesting -- we can't check that until we've parsed the
in-class initializers for non-static data members.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169805 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
8b39c6693aadd30f77ac039de69130c22e066994 10-Dec-2012 Daniel Jasper <djasper@google.com> Addi formatting tests for pointer template parameters.

Fix spacing before ",".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169746 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
56e49c5cc2b05e805c7aa9dc53672711e540d58b 10-Dec-2012 Alexander Kornienko <alexfh@google.com> Clang-format: error recovery for access specifiers

Reviewers: klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D198

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169738 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ec33b6f64480df41a6add1f112c7321ba96de378 10-Dec-2012 Manuel Klimek <klimek@google.com> Adding tests since when I was asked whether this works I wasn't
100% sure.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169725 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
c74e2794bebaab41213f23b27c09c21cb1e1f81b 07-Dec-2012 Daniel Jasper <djasper@google.com> Small tweaks to clang-format.

Now not joining keywords with '::' and not putting a space between
a pointer pointer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169594 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
c35fac11ecc1a55c5dd6ef1d10c2514bb274e3a1 06-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Fixes Makefile for Format unit tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169554 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/Makefile
akefile
15757316d67cb7a854d53a0402d67ad58347600a 06-Dec-2012 Alexander Kornienko <alexfh@google.com> Clang-format: IndentCaseLabels option, proper namespace handling

Summary: + tests arranged in groups, as their number is already quite large.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D185

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169520 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a3a2b3a1e86a93d2044106046a4dca13a3558fba 06-Dec-2012 Alexander Kornienko <alexfh@google.com> Clang-format: detect unbalanced braces.

Reviewers: klimek, djasper

Reviewed By: klimek

CC: cfe-commits, silvas

Differential Revision: http://llvm-reviews.chandlerc.com/D176

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169518 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
30ace3715015b4a9bc5fa538a6515481abed40f9 06-Dec-2012 Manuel Klimek <klimek@google.com> Implements multiple parents in the parent map.

Previously we would match the last visited parent, which in the
case of template instantiations was the last instantiated template.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169508 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
d56a737842f28db4403430082c4d2686bc6cc3b3 06-Dec-2012 Daniel Jasper <djasper@google.com> Improve clang-format's handling of unary operators.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169500 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
3b5943f535eca0e0b91f4bcda9d09c9c275cf855 06-Dec-2012 Daniel Jasper <djasper@google.com> "<<" alignment for clang-format.

Also, small fix for handling the first token correctly.

Review: http://llvm-reviews.chandlerc.com/D177

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169488 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
ddb2968ba69e14bafec765401d70f2477bc977f6 05-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> In DeclPrint add printing of '= default'
in constructors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169440 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
65bcdabba34fddc303ab97f60dfea6079989306a 05-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> In DeclPrint add printing of 'explicit'
constructors.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169435 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
a3064c32d378d3a11f87945047c040276850ce4b 05-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> fix comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169413 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
02a2e5a1dd0ad1b93f66040fc7aae6d69a918daf 05-Dec-2012 Fariborz Jahanian <fjahanian@apple.com> Testing C++ declarations embedded in
<declaration> tag of Comment XML.
Added DeclPrint support for constructors
and fix tests accordingly.
This is wip. // rdar://12378714


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169412 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
2e97cfc78743fcaa988e3c45f7af1002063f780c 05-Dec-2012 Alexander Kornienko <alexfh@google.com> Clang-format: parse for and while loops

Summary: Adds support for formatting for and while loops.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D174

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169387 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
33182dd0f7d5b5e913b1957c2cb6dc04942efd46 05-Dec-2012 Daniel Jasper <djasper@google.com> Indentation fixes for clang-format.

- Fix behavior of memoization together with optimization
- Correctly attribute the PenaltyIndentLevel (breaking directly after "(" did
not count towards the inner level)
- Recognize more tokens as assignments

Review: http://llvm-reviews.chandlerc.com/D172

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169384 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
112fb27ab48ae3256173806a073ba7b88aa6531a 05-Dec-2012 Daniel Jasper <djasper@google.com> Small tweaks to automatic formatting.

Recognize '!=' as a binary operator and assume that there are no
type definitions on the RHS of an assignment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169363 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
cff563c0123bbb8d959c93ed371d27cbc6bc4a29 04-Dec-2012 Alexander Kornienko <alexfh@google.com> Error recovery part 2

Summary: Adds recovery for structural errors in clang-format.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, silvas

Differential Revision: http://llvm-reviews.chandlerc.com/D164

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169286 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
393b008bcebb0a678a5a0a93ad69e28a30a62e84 04-Dec-2012 Alexander Kornienko <alexfh@google.com> Clang-format error recovery part 1

Reviewers: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D163

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169278 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
a166e73d39d2f554d0f35f94c9804284d1ff804a 04-Dec-2012 Alexander Kornienko <alexfh@google.com> Enum formatting implementation

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D161

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169272 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
8cb9bf577e3cfe31f1f023ed3a978d726f136edc 04-Dec-2012 Manuel Klimek <klimek@google.com> Fix spelling I ran over while proof-reading tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169271 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
987c2f590fade75245e32807ee83c31483e02d8a 04-Dec-2012 Manuel Klimek <klimek@google.com> Fixes crash in isDerivedFrom for recursive templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169262 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8822d3a99c07c7d874f8bfd81a7fe02059b9c19e 04-Dec-2012 Daniel Jasper <djasper@google.com> Small fixes to unary operator recognition and handling of include
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169261 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
36e29d6732814e958aea4b2f403cec63d7ed3116 04-Dec-2012 Daniel Jasper <djasper@google.com> Add parameterCountIs() matcher.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169257 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
a88bb45f11c1e27f9caf60a85a8e1774d3e09ead 04-Dec-2012 Daniel Jasper <djasper@google.com> Replace workarounds with correct fixes.

Also fix header guard.

http://llvm-reviews.chandlerc.com/D159

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169254 91177308-0d34-0410-b5e6-96231b3b80d8
ormat/FormatTest.cpp
7cc315ccf80382fab7674735fbfda95990d28f8e 04-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Really sort the #include lines in unittests/...

I forgot to re-sort after fixing main module headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169244 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
rontend/FrontendActionTest.cpp
ex/LexerTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
ooling/RefactoringCallbacksTest.cpp
1050e8b2252d89a0004a6fd25a58dab88b5ee625 04-Dec-2012 Chandler Carruth <chandlerc@gmail.com> Sort the #include lines for unittests/...

I've tried to place sensible headers at the top as main-module headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169243 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
ST/SourceLocationTest.cpp
STMatchers/ASTMatchersTest.cpp
asic/FileManagerTest.cpp
asic/SourceManagerTest.cpp
ormat/FormatTest.cpp
rontend/FrontendActionTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PPConditionalDirectiveRecordTest.cpp
ooling/RefactoringCallbacksTest.cpp
ooling/RefactoringTest.cpp
ooling/TestVisitor.h
d031c6aa0cb70000381b587574ce560ffbc59d00 04-Dec-2012 NAKAMURA Takumi <geek4civic@gmail.com> ASTTests, ASTMatchersTests: Move clangEdit before clangAst in USEDLIB.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169236 91177308-0d34-0410-b5e6-96231b3b80d8
ST/Makefile
STMatchers/Makefile
bf5bc4cba590240e0e97eb529935fdfd512b02d5 04-Dec-2012 NAKAMURA Takumi <geek4civic@gmail.com> Untabify (in USEDLIBS, Makefile(s)).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169235 91177308-0d34-0410-b5e6-96231b3b80d8
ST/Makefile
STMatchers/Makefile
b331b5e4c621309a94bcfd00983ed1a97ef3d429 04-Dec-2012 NAKAMURA Takumi <geek4civic@gmail.com> clang/Lex: [CMake] Update CMakefiles since r169229.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169233 91177308-0d34-0410-b5e6-96231b3b80d8
ex/CMakeLists.txt
37ed12720a35b7bfa1c4de73ad6f1c6c1c88ee17 04-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Refactor recording the preprocessor conditional directive regions out of
PreprocessingRecord and into its own class, PPConditionalDirectiveRecord.

Decoupling allows a client to use the functionality of PPConditionalDirectiveRecord
without needing a PreprocessingRecord.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169229 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PPConditionalDirectiveRecordTest.cpp
ex/PreprocessingRecordTest.cpp
7e96bfb4d507700a122f270a11ce3fc0e8e36c85 04-Dec-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce CompilationDatabase::getAllCompileCommands() that returns all
compile commands of the database and expose it via the libclang API.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169226 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
bac016bd3f67ca2f4db1ddc619e611759352b84d 03-Dec-2012 Daniel Jasper <djasper@google.com> Initial version of formatting library.

This formatting library will be used by a stand-alone clang-format tool
and can also be used when writing other refactorings.

Manuel's original design document:
https://docs.google.com/a/google.com/document/d/1gpckL2U_6QuU9YW2L1ABsc4Fcogn5UngKk7fE5dDOoA/edit

The library can already successfully format itself.

Review: http://llvm-reviews.chandlerc.com/D80

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169137 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ormat/CMakeLists.txt
ormat/FormatTest.cpp
ormat/Makefile
189f2e421d06526ea8b4a3dcd9f4a072e10a859c 03-Dec-2012 Daniel Jasper <djasper@google.com> Make hasDeclaration work for enums.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169129 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8b9ed7106a40e8dacf212fa06eb859804b75a875 01-Dec-2012 Benjamin Kramer <benny.kra@googlemail.com> Update unit tests not to rely on transitive includes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169096 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
7dff05bf3019995798def5d1066e4282b8578df6 30-Nov-2012 Douglas Gregor <dgregor@apple.com> Fix unit tests for ModuleLoader change in r168961.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168962 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PreprocessingRecordTest.cpp
9c196ac0fc7c7c6cad68d967c1a74959dd7e0f58 30-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> Remove out-of-date comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168957 91177308-0d34-0410-b5e6-96231b3b80d8
ST/StmtPrinterTest.cpp
96794f1f38119691879e99a3f4298cd442130cf2 29-Nov-2012 NAKAMURA Takumi <geek4civic@gmail.com> ASTTests/StmtPrinterTest/StmtPrinter.TestMSIntegerLiteral: Remove i128 stuff. Conditioning-out in macro argument was not accepted on MS cl.exe.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168867 91177308-0d34-0410-b5e6-96231b3b80d8
ST/StmtPrinterTest.cpp
3b164774ad067557486dd1221f0ecbf2e905a816 29-Nov-2012 NAKAMURA Takumi <geek4civic@gmail.com> ASTTests/StmtPrinterTest/StmtPrinter.TestMSIntegerLiteral: Suppress i128 according to r168856, for now.

I think "i128", that I conditioned out, could be completely removed.
MS Compiler doesn't accept i128. We can assume no one would use i128.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168865 91177308-0d34-0410-b5e6-96231b3b80d8
ST/StmtPrinterTest.cpp
d1bac8d46740eb00085ec816af0829fd75fb4d5c 27-Nov-2012 Richard Smith <richard-llvm@metafoo.co.uk> Allow an ASTConsumer to selectively skip function bodies while parsing. Patch
by Olivier Goffart!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168726 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
5f684e90c2f44eda979573a01c2ed063d9adc7a8 16-Nov-2012 Daniel Jasper <djasper@google.com> Fix partial-match-bind-behavior with forEachDescendant() matchers.

The problem is that a partial match of an (explicit or implicit) allOf matcher
binds results, i.e.

recordDecl(decl().bind("x"), hasName("A"))

can very well bind a record that is not named "A". With this fix, the common
cases of stumbling over this bug are fixed by the BoundNodesMap overwriting the
results of a partial match. An error can still be created with a weird
combination of anyOf and allOf (see inactive test). We need to decide whether
this is worth fixing, as the fix will have performance impact.

Review: http://llvm-reviews.chandlerc.com/D124

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168177 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
3a4c8cf5c0669f48a66da2df30c7963dce8348ff 16-Nov-2012 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests: Fixup corresponding to Doug's r168136.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168137 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PPCallbacksTest.cpp
ex/PreprocessingRecordTest.cpp
278057fd9f44684af832695cb01676c02a257b14 15-Nov-2012 Daniel Jasper <djasper@google.com> Do not use data recursion in ASTMatchFinder.

The matchers rely on the complete AST being traversed as shown by the new test cases.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168022 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
11c98771ba5d7fb1ec5707f9e1c77a6cf65bbc59 11-Nov-2012 Daniel Jasper <djasper@google.com> Fix binding of nodes in case of forEach..() matchers.

When recursively visiting the generated matches, the aggregated bindings need
to be copied during the recursion. Otherwise, we they might not be properly
overwritten (which is shown by the test), or there might be bound nodes present
that were bound on a different matching branch.

Review: http://llvm-reviews.chandlerc.com/D112

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167695 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
c2fc67e0cf7dd061fda1aa90d81668f3e070d4cb 08-Nov-2012 David Blaikie <dblaikie@gmail.com> Fix a source range regression in C++ new expressions with call initializers.

Introduced in r167507, discovered in review by Abramo Bagnara.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167597 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
4c5750e0d1c1dfc091689e3daa96ed4ccfa36dca 08-Nov-2012 Abramo Bagnara <abramo.bagnara@bugseng.com> Fixed converted ConstantArrayTypeLoc range. Added a missing testcase for ConstructorDecl source range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167583 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
13fd684ee2c7578177b7c741e8eeec91ae628fcf 08-Nov-2012 Abramo Bagnara <abramo.bagnara@bugseng.com> Fixed range of implicit MemberExpr.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167581 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
5a78985de7a9e13b4971c99145c3abd6aed0347f 07-Nov-2012 David Blaikie <dblaikie@gmail.com> Test for source location range of new expressions fixed in r167507.

Patch by Philip Craig.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167538 91177308-0d34-0410-b5e6-96231b3b80d8
ST/SourceLocationTest.cpp
975a9491bb87cde0f17fe816b54a02b240ef7059 06-Nov-2012 Manuel Klimek <klimek@google.com> Add unit tests for source locations of AST nodes.

Patch by Philip Craig.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167470 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
ST/SourceLocationTest.cpp
7164095ea1c804740e00d54d05a7e8d1f876c674 03-Nov-2012 Benjamin Kramer <benny.kra@googlemail.com> Escape trigraphs in unittest.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167359 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PPCallbacksTest.cpp
e579328ec9a95acc7f181e04c58a747ba001d80f 02-Nov-2012 Manuel Klimek <klimek@google.com> Insert interception point onStartOfTranslationUnit.

Often users of the ASTMatchers want to add tasks that are done once per
translation unit, for example, cleaning up caches. Combined with the
interception point for the end of source file one can add to the factory
creation, this covers the cases we've seen users need.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167271 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
cfa1caa92611184f59c2f3e606c53ddcc726449a 01-Nov-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Make the FilenameRange of the InclusionDirective callback more accurate,
preserve the macro location of the range end if the filename came from a macro.

Patch by Kim Gräsman!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167239 91177308-0d34-0410-b5e6-96231b3b80d8
ex/CMakeLists.txt
ex/PPCallbacksTest.cpp
d1ce3c178b9c648687591b190e0d252124fc2459 30-Oct-2012 Daniel Jasper <djasper@google.com> Implement descendant matchers for NestedNamespecifiers

This implements has(), hasDescendant(), forEach() and
forEachDescendant() for NestedNameSpecifier and NestedNameSpecifierLoc
matchers.

Review: http://llvm-reviews.chandlerc.com/D86

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167017 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
452abbc76b775169dc01c359e94a7f666ebc8692 29-Oct-2012 Daniel Jasper <djasper@google.com> Fix ASTMatchersTests to not create an overloaded-virtual warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166921 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
a267cf6f87dc695143d65fc61ec1744564f55932 29-Oct-2012 Daniel Jasper <djasper@google.com> Implement has(), hasDescendant(), forEach() and forEachDescendant() for
Types, QualTypes and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D83

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166917 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
d9a2d5bdb747836917c2a5f7e12d075ec6762c77 25-Oct-2012 NAKAMURA Takumi <geek4civic@gmail.com> unittests/ToolingTest.cpp: Suppress newFrontendActionFactory.InjectsEndOfSourceFileCallback on Win32 for now. Investigating.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166674 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
9fb6b27e6d584ac339363357335f8d6de3a652ac 25-Oct-2012 Manuel Klimek <klimek@google.com> Adds the possibility to inject a callback that's called after each translation unit is processed.

This is important when one wants to deduplicate results during one run over a translation unit by pointer identity of AST nodes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166671 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
36a16498ff911a218f26c7955376bbe99ddb16df 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Teach the preprocessor to hold onto the preprocessor options.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166599 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PreprocessingRecordTest.cpp
b0985c86f7f75e780bfeb366afdbee7676c28948 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Update unit tests for HeaderSearch change

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166584 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PreprocessingRecordTest.cpp
3e2aa99e992b89bd421ac2a6bf79307114d257fc 24-Oct-2012 Manuel Klimek <klimek@google.com> Adds the possibility to run ASTMatchFinder over arbitrary AST nodes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166567 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
f27762b1beced898e47aeae1bcb557addd8a148d 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Tweak include order

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166521 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringCallbacksTest.cpp
99eb4a7920667d23a89df8fcc6429d12b36e4d57 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Buildbot debugging is fun

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166516 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
16a4abf5d98e62ef5cc1af4685dbffa593042709 24-Oct-2012 Douglas Gregor <dgregor@apple.com> One last unit-test fix

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166513 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PreprocessingRecordTest.cpp
3aeb34f5639ca03ba952bef7239028eaaec33281 24-Oct-2012 Douglas Gregor <dgregor@apple.com> More unit-test fixes

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166511 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
8e023611637905629b928915cbda22a90b2432c3 24-Oct-2012 Douglas Gregor <dgregor@apple.com> Fixup unit tests for DiagnosticOptions change

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166509 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
c711af2ddbbb1d46223cc9379d32a203fb5bc7f4 23-Oct-2012 Daniel Jasper <djasper@google.com> Make hasDeclaration() matcher work inside the memberExpr() matcher.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166479 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
70b9db9879c1cb8b8ca7d6c9809e35361cab83dc 23-Oct-2012 Manuel Klimek <klimek@google.com> Implements the thisExpr matcher.
Patch by Gabor Horvath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166477 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
c99a3ad8c2bf29da45a0c64b88d58bfbd2f78ef2 22-Oct-2012 Daniel Jasper <djasper@google.com> Implement hasParent()-matcher.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166421 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
262e60c1ccb5197e8e2ea49ada1196ed65183734 18-Oct-2012 Fariborz Jahanian <fjahanian@apple.com> [doc parsing] use getParamName to access parameter
for current(rewritten) comment and getParamNameAsWritten
to access param name coming with \param marker.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166231 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
a7a68b61e809a74fb5d34d57d7429fcc95e1ccad 18-Oct-2012 Fariborz Jahanian <fjahanian@apple.com> Patch for decl printer test of objective-c methods.
Patch by Dmitri Gribenko.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166209 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
1802daf8539f3320c369e442d3c8471b10ffd3cb 17-Oct-2012 Daniel Jasper <djasper@google.com> Fix tests, which accidentally matched implicit code on specific
platforms to make buildbots happy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166100 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
ce62007526cdf718faed10df5e9fc7c3cd160cde 17-Oct-2012 Daniel Jasper <djasper@google.com> First version of matchers for Types and TypeLocs.

Review: http://llvm-reviews.chandlerc.com/D47

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166094 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
07f8cf4ec3ffb6668b35e7b864354faa76167209 17-Oct-2012 Douglas Gregor <dgregor@apple.com> Fix the handling of target options in our unit tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166079 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
ex/PreprocessingRecordTest.cpp
6553c686cb419b22b4c79d05a422fb1e96f6e122 15-Oct-2012 Fariborz Jahanian <fjahanian@apple.com> structured document comment: patch to provide comment for overriding function
template when comment is comming from overridden declaration.
// rdar://12378793


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165953 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
bf967be66ea8c51b66c61659c23240f762a56dbe 10-Oct-2012 Fariborz Jahanian <fjahanian@apple.com> [Doc parsing] This patch searches overridden objc/c++
methods looking for documentation on a particular base
class inherited by any method that overrides the base class.
In case of redeclaration, as when objc method is defined
in the implementation, it also looks up for documentation
in class/class extension being redeclared.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165643 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
3201da38bdd7cea1d05700858d2af94287044887 08-Oct-2012 Daniel Jasper <djasper@google.com> CompilationDatabaseTest: Fix another Windows path issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165425 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
8a5e8c35e1beced2f098a775648e8648294967d2 08-Oct-2012 Daniel Jasper <djasper@google.com> CompilationDatabase: Use //net paths for tests, as they should be
considered absolute on all platforms.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165422 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
2dbe2fa7eb3ccf8eabae884a177b4570d3fb260d 08-Oct-2012 Daniel Jasper <djasper@google.com> FileNameMatchTrie: Use StringRef instead of Twines where possible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165412 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
d3420c906e3605d94c084e8b8b1f3fa490093c86 08-Oct-2012 Daniel Jasper <djasper@google.com> Support symlinks and relative paths in complilation databases.

Review: http://llvm-reviews.chandlerc.com/D30

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165392 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
1a00fee3933066024a2398f9456e5d6bc74344b9 01-Oct-2012 Daniel Jasper <djasper@google.com> Fix ASTMatchersTests in configurations where
"#include <initializer_list>" is unavailable for whatever reason.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164944 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
31f7c08a0d2b140bf31a08894d1948649de53c15 01-Oct-2012 Daniel Jasper <djasper@google.com> Add matchers for selected C++11 features.

Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D46

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164943 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
aaa8e45b8e392a1f1b7498e2f00c6ed66d41119a 29-Sep-2012 Daniel Jasper <djasper@google.com> Fix refersToDeclaration()-matcher and add missing test case. This was
broken as of r164656 as TemplateArgument::getAsDecl() now asserts
instead of returning NULL for other template arugment kinds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164896 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
1952354bd376062c3ab3d328c0fc6c36530c9309 29-Sep-2012 Dmitri Gribenko <gribozavr@gmail.com> Move the 'find macro by spelling' infrastructure to the Preprocessor class and
use it to suggest appropriate macro for __attribute__((deprecated)) in
-Wdocumentation-deprecated-sync.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164892 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
11e141d61637ac04f7de71141de9d371df728a38 24-Sep-2012 NAKAMURA Takumi <geek4civic@gmail.com> unittests/AST/StmtPrinterTest.cpp: Suppress a LP64-assumed test, "0x100000000i128 => 4294967296L", for now.

LONG_MAX is 2147483647L on common 32 bit and LLP64 (Windows x64).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164478 91177308-0d34-0410-b5e6-96231b3b80d8
ST/StmtPrinterTest.cpp
525394e6c2b0cd0ef4de47a402e82029402ff360 23-Sep-2012 Dmitri Gribenko <gribozavr@gmail.com> As a followup for r164303, add some tests for printing literals that test
printing directly rather than through a complicated machinery of ObjC rewriter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164477 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
ST/StmtPrinterTest.cpp
b54b7646b2d00a85d80e40adf7c49553f150c736 20-Sep-2012 Daniel Jasper <djasper@google.com> Add some matchers for basic AST nodes.

Patch by Gábor Horváth.
Review: http://llvm-reviews.chandlerc.com/D45

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164304 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
08f0c53175bba899e7af6c6cc2cab25caf64ef2a 18-Sep-2012 Daniel Jasper <djasper@google.com> Fix isDerivedFrom matcher.

Without this patch, the isDerivedFrom matcher asserts in the
"assert(ClassDecl != NULL);" in the new test, as a
DependentTemplateSpecilizationType is not a sub-type of
TemplateSpecializationType and also does not offer getAsCXXRecordDecl().

I am not sure why this did not cause problems before. It is now (after
the changed implementation of isDerivedFrom) easier to write a matcher
that actually gets into this branch of the code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164127 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
e6d2a96cc9689be584c3bfc09ac527a03a25b3bc 18-Sep-2012 Daniel Jasper <djasper@google.com> Add missing matcher for C-style cast expressions.

Patch by Gábor Horváth.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164123 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
3680b4f7494b6744b9c5a25f83b63cd8b7e434fc 18-Sep-2012 Daniel Jasper <djasper@google.com> Make all VariadicDynCast-Expr-matchers StatementMatchers

Having Expr-subclass-matchers being VariadicDynCast-Expr-matchers does
not provide additional type safety and just makes using them harder. In
the clang AST, expressions are always statements and an expression
matcher can be used anywhere, a statement matcher is expected. Any given
matcher definition still has at least one noun.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164121 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8c05da3fd8db98af482826ba059ab1ad6d58010f 14-Sep-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: don't parse comment marker followed by a digit as a command
since no Doxygen command starts with a digit.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163909 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
a7564433191601cb8851196b8dde39392c9c05ee 13-Sep-2012 Daniel Jasper <djasper@google.com> Create initial support for matching and binding NestedNameSpecifier(Loc)s.

Review: http://llvm-reviews.chandlerc.com/D39

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163794 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
63d88728d862f8a69b3291e533d193d1d8513f5a 12-Sep-2012 Daniel Jasper <djasper@google.com> Rename isA to isSameOrDerivedFrom.

There are two evils we can choose from:
- Name overlap between isA-matcher and llvm::isa<>()
- Bad name for what the isA-matcher currently does

After some discussion we have agreed to go with the latter evil.

Review: http://llvm-reviews.chandlerc.com/D40

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163740 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
e4330a302ac20b41b9800267ebd4b5b01f8553f8 10-Sep-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.

Now we have a list of all commands. This is a good thing in itself, but it
also enables us to easily implement typo correction for command names.

With this change we have objects that contain information about each command,
so it makes sense to resolve command name just once during lexing (currently we
store command names as strings and do a linear search every time some property
value is needed). Thus comment token and AST nodes were changed to contain a
command ID -- index into a tables of builtin and registered commands. Unknown
commands are registered during parsing and thus are also uniformly assigned an
ID. Using an ID instead of a StringRef is also a nice memory optimization
since ID is a small integer that fits into a common bitfield in Comment class.

This change implies that to get any information about a command (even a command
name) we need a CommandTraits object to resolve the command ID to CommandInfo*.
Currently a fresh temporary CommandTraits object is created whenever it is
needed since it does not have any state. But with this change it has state --
new commands can be registered, so a CommandTraits object was added to
ASTContext.

Also, in libclang CXComment has to be expanded to include a CXTranslationUnit
so that all functions working on comment AST nodes can get a CommandTraits
object. This breaks binary compatibility of CXComment APIs.

Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't
need TU parameter anymore, so it was removed. This is a source-incompatible
change for this C API.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163540 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
76dafa7e6487c0b51fadebd16bdefe0e0e23d595 07-Sep-2012 Daniel Jasper <djasper@google.com> Change the behavior of the isDerivedFrom-matcher to not match on the
class itself. This caused some confusion (intuitively, a class is not
derived from itself) and makes it hard to write certain matchers, e.g.
"match and bind any pair of base and subclass".

The original behavior can be achieved with a new isA-matcher. Similar
to all other matchers, this matcher has the same behavior and name as
the corresponding AST-entity - in this case the isa<>() function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163385 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
579b120038ca817e0ce423303ebc1b4e0c6cbbe1 07-Sep-2012 Manuel Klimek <klimek@google.com> Implements hasAncestor.

Implements the hasAncestor matcher. This builds
on the previous patch that introduced DynTypedNode to build up
a parent map for an additional degree of freedom in the AST traversal.

The map is only built once we hit an hasAncestor matcher, in order
to not slow down matching for cases where this is not needed.

We could implement some speed-ups for special cases, like building up
the parent map as we go and only building up the full map if we break
out of the already visited part of the tree, but that is probably
not going to be worth it, and would make the code significantly more
complex.

Major TODOs are:
- implement hasParent
- implement type traversal
- implement memoization in hasAncestor

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163382 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
a78d0d6203a990b88c9c3e4c4f2a277001e8bd46 05-Sep-2012 Manuel Klimek <klimek@google.com> Introduces DynTypedMatcher as a new concept that replaces the UntypedBaseMatcher and TypedMatcher.

Due to DynTypedNode the basic dynamically typed matcher interface can now be simplified.

Also switches the traversal interfaces to use DynTypedNode;
this is in preperation for the hasAncestor implementation, and
also allows us to need fewer changes when we want to add new
nodes to traverse, thus making the code a little more decoupled.

Main design concerns: I went back towards the original design
of getNodeAs to return a pointer, and switched DynTypedNode::get
to always return a pointer (in case of value types like QualType
the pointer points into the storage of DynTypedNode, thus allowing
us to treat all the nodes the same from the point of view of a
user of the DynTypedNodes.

Adding the QualType implementation for DynTypedNode was needed
for the recursive traversal interface changes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163212 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
305c613af6cfc40e519c75d9d2c84c6fa9a841c0 01-Sep-2012 Ted Kremenek <kremenek@apple.com> Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163050 91177308-0d34-0410-b5e6-96231b3b80d8
ST/Makefile
STMatchers/Makefile
rontend/Makefile
ooling/CMakeLists.txt
ooling/Makefile
ooling/RefactoringTest.cpp
ooling/RewriterTestContext.h
af503a6f218cbef8704609812668360b0cbd0b60 31-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Remove the useless CommentOptions class.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162986 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
976f118dc5a2a89be29e6fd01e00f5a188b77847 31-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter tests: simplify the code by using the new runToolOnCodeWithArgs
function from Tooling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162976 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
44470efba52b730fa1874eea9caacd2839a1af22 31-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter tests: since now some platforms use C++11 by default, make it
explicitly visible in test cases which language variant is used.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162974 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
66341c596f93d0c6475d839db94072b8ebd1cf5b 30-Aug-2012 Manuel Klimek <klimek@google.com> Fixes a bug for binding memoized match results.

Intorduces an abstraction for DynTypedNode which makes
is impossible to create in ways that introduced the bug;
also hides the implementation details of the template
magic away from the user and prepares the code for adding
QualType and TypeLoc bindings, as well as using DynTypedNode
instead of overloads for child and ancestor matching.

getNodeAs<T> was changed towards a non-pointer type, as
we'll want QualType and TypeLoc nodes to be returned
by value (the alternative would be to create new storage
which is prohibitively costly if we want to use it for
child / ancestor matching).

DynTypedNode is moved into a new header ASTTypeTraits.h,
as it is completely independent of the rest of the matcher
infrastructure - if the need comes up, we can move it to
a more common place.

The interface for users before the introduction of the
common storage change remains the same, minus the introduced
bug, for which a regression test was added.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162936 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
50f88b99c60c2ed31b339cd8bd484766cc9e916b 30-Aug-2012 Nico Weber <nicolasweber@gmx.de> Reland r160052: Default to -std=c++11 on Windows.

Also update the tests that rely on c++98 to explicitly mention that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162890 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
STMatchers/ASTMatchersTest.h
566698851d76416129cd20ceea02bdd697934c5c 30-Aug-2012 Nico Weber <nicolasweber@gmx.de> Tooling: Add a runToolOnCodeWithArgs() function that allows
passing additional parameters to a tool.

Use this to fix a FIXME in testing code.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162889 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/TestVisitor.h
29b1f682ac168d71370287a1e955311b4901681a 25-Aug-2012 NAKAMURA Takumi <geek4civic@gmail.com> ASTTests: Suppress TestCXXConstructorDecl11 on msvc for now. It seems incompatible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162631 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
e16acd3817e501ee2bcf5f631b6911021fa88ba7 25-Aug-2012 Sam Panzer <espanz@gmail.com> New matcher for MaterializeTemporaryExpr

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162609 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8268fe7c4bdfa341975a687a8a5e236c2c5b88a4 24-Aug-2012 James Dennett <jdennett@google.com> Allow RecursiveASTVisitor to visit CXXCtorInitializer objects for which
isWritten() returns false, if shouldVisitImplicitCode() returns true.
Previously those CXXCtorInitializers were always skipped.

In order to make this change easier to test, this patch also extends the
test class template ExpectedLocationVisitor to support arbitrary numbers
of expected matches and disallowed matches.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162544 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
ooling/TestVisitor.h
7fd90b03a28df0626fdb44d05be9ddcdb2562686 24-Aug-2012 Daniel Jasper <djasper@google.com> Use LLVM's plugin registry to enable registering new compilation
databases. Move JSONCompilationDatabase.h to its own files and
register it as plugin.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162541 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
ooling/CompilationDatabaseTest.cpp
2dc75ed2ef2fa3cbfd8b2ed88eb2369f3fcd98a9 24-Aug-2012 Daniel Jasper <djasper@google.com> Rename the ASTMatchers to better match AST nodes. Now, all
ASTMatchers have the same name as the corresponding AST nodes
but are lower case. The only exceptions are the "CXX" prefixes
which are not copied over to the matcher names as the goal is to
actually remove these prefixes from the AST node names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162536 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
STMatchers/ASTMatchersTest.cpp
ooling/RefactoringCallbacksTest.cpp
f6ec15a23d271b45f8c0296b7ac44e994119bb8e 24-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter tests: mark test case we get wrong currently with WRONG.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162512 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
c4684244c529284a1350d3cbc98615d1deab7f05 24-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter tests: add two more tests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162511 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
a8eaf008e92759142982f7b40720b2b2674bd663 23-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix undefined behavior: member function calls where 'this' is a null pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162430 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
834a5bd311b4a32f89937ca5b6dd2b4111891859 23-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: parse "<blah" as an HTML tag only if "blah" is a known tag
name. This should reduce the amount of warning false positives about bad HTML
in comments when the comment author intended to put a reference to a template.
This change will also enable us parse the comment as intended in these cases.

Fixes part 1 of PR13374.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162407 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
2e0b8d9c0b16c4f3e3bed992205ce43a0908915d 21-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter, terse mode: don't print function bodies


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162294 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
d1fc82efd53ffda30f4f16041399d78f3bf0705f 21-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Rename PrintingPolicy::DontRecurseInDeclContext to PrintingPolicy::TerseOutput
to reflect the intention, not the implementation.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162293 91177308-0d34-0410-b5e6-96231b3b80d8
ST/DeclPrinterTest.cpp
49795ae2c7cbb0845ed07b6626ac24275234e3d1 21-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> DeclPrinter: add terse output mode and lots of tests

Add a flag PrintingPolicy::DontRecurseInDeclContext to provide "terse" output
from DeclPrinter. The motivation is to use DeclPrinter to print declarations
in user-friendly format, without overwhelming user with inner detail of the
declaration being printed.

Also add many tests for DeclPrinter. There are quite a few things that we
print incorrectly: search for WRONG in DeclPrinterTest.cpp -- and these tests
check our output against incorrect output, so that we can fix/refactor/rewrite
the DeclPrinter later.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162245 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
ST/DeclPrinterTest.cpp
ST/Makefile
02ed37f95e49ceac0a90fb430d7040a876b2f5f6 18-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> AST Matchers tests: test that member() matches member allocation functions:
declare size_t in system-independent way.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162158 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
671a045cc61cabe0b5fee0d8a93337e771156e11 18-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> AST Matchers tests: test that member() matches member allocation functions.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162153 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
82b4550fb25ad578b6c8143b87a003fae7106cae 17-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Part of PR13618: visit the TypeLoc when RecursiveASTVisitor visits a CompoundLiteralExpr.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162133 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
ooling/TestVisitor.h
8456ae602783b615019a42f7d5c6f0e71639b11b 17-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> AST Matchers: introduce functionTemplate(), classTemplate() and
isExplicitTemplateSpecialization() matchers which do what their name says.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162115 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
0652c35a303a6186142eea566c88714c59bdc664 17-Aug-2012 Richard Smith <richard-llvm@metafoo.co.uk> Don't forget to apply #pragma pack to partial and explicit specializations of
class templates. This fixes misalignment issues in llvm/Support/Endian.h when
built by Clang.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162074 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
425f41b370a8795fbca9ffc3b35e9b0ccbb15d97 16-Aug-2012 Sam Panzer <espanz@gmail.com> Matchers related to DeclStmt for matching the count of declarations, a particular declaration within the statement, and single-Decl DeclStmts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162027 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
089e5b3bf2e57da0173b170ad501867b43395385 16-Aug-2012 Sam Panzer <espanz@gmail.com> Matchers which correspond to CastExpr, IgnoreImpCasts, IgnoreParenCasts, and IgnoreParenImpCasts

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162025 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
8cc7efa2da2c6be43cbd3d09a9ae01353bb921d2 15-Aug-2012 Daniel Jasper <djasper@google.com> Add ASTMatcher for matching extern "C" function declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161974 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
1a5d421c26e3dffce9dfc1aeca846167d7bb4068 09-Aug-2012 Chad Rosier <mcrosier@apple.com> [ms-inline asm] Add various MC components to clang build to support MS-style inline assembly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161594 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/CMakeLists.txt
rontend/CMakeLists.txt
ooling/CMakeLists.txt
aa58081902ad31927df02e8537d972eabe29d6df 09-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: extract TableGen'able pieces into new CommandTraits class.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161548 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
fa1d30ddb1bbb16d8c268f79890ac39101915b5c 08-Aug-2012 Chad Rosier <mcrosier@apple.com> Add various MC components to clang build to support MS-style inline assembly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161498 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Makefile
rontend/Makefile
ooling/Makefile
8a90393e7ca61d9753cb9a2f2bc64b2669393ffb 07-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: fix crash on \tparam followed immediately by another block
command, for example: \tparam\brief.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161361 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
d076e013b1d9afa26d9bf2fdc8ba579941037f8e 02-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parser tests: test that we allow placing no whitespace between \param
and [direction].


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161146 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
371f9391329d488d9bc4098adc7f5cf73aede1c1 01-Aug-2012 Daniel Jasper <djasper@google.com> Add missing tests for class template specialization and template
argument matchers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161102 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
96b098674908eaa59a9128f3305cda6fbbdad563 01-Aug-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: add support for \tparam command on all levels.

The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this
breaks libclang binary compatibility, but should not be a problem since API is
so new.

This also fixes PR13372 as a side-effect.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161087 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
3ccc173d6f1f9e43566c258289b7581d8aa523ad 30-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parser: add one more test


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160965 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
9bd2809085c2a84c980c40988896ee05065f14e4 30-Jul-2012 Daniel Jasper <djasper@google.com> Fix for ASTMatchFinder to visit a functions parameter declarations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160947 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
477a9f58c1b197f315befd03b42a8a0b3a2f0ff9 27-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Implement resolving of HTML character references (named: &amp;, decimal: &#42;,
hex: &#x1a;) during comment parsing.

Now internal representation of plain text in comment AST does not contain
character references, but the characters themselves.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160891 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
715c9568ee5d75f25dab98229c87bcec880daf5d 25-Jul-2012 Manuel Klimek <klimek@google.com> Introduces the 'decl' matcher which was missing for a while
and became necessary with the change to require BindableMatchers
for binding.

Also fixes PR 13445: "hasSourceExpression only works for implicit casts".



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160716 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
0c43a927d97c39c7d6de6a055af1d8f101d5a058 24-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: allow newlines between \param, direction specification (e.g.,
[in]), parameter name and description paragraph.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160682 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
fd939162ff99a0084ed22a08dd37c149a0883a2b 24-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: retokenized text tokens are now pushed back in correct (not
reverse) order


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160675 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
9f17408d50c1d76c5eab435e4ceb924cc10757ab 24-Jul-2012 Manuel Klimek <klimek@google.com> Introduces a new concept for binding results to matchers
as per Chandler's request:
- introduces a new matcher base type BindableMatcher that
provides the bind() call
- makes all dynamic-cast matcher creation functions return
BindableMatchers; the special case about dynamic-cast
matchers is that the node they match on and the node
their child matchers match on are the same node, just
casted to a different type; thus, there is no ambiguity
on what bind() matches on; additionally, those are the
matchers that we name with nouns in the matcher language,
so it's easy for users to intuitively know which matchers
are bindable

To make this change possible, we got rid of a non-orthogonal
implementation of thisPointerType, which had an implicit
dynamic-cast matcher from CallExpr to CXXMemberCallExpr; as
alternative, we now provide a memberCall dynamic-cast matcher
and thisPointerType is a predicate on CXXMemberCallExpr.

Last, the ArgumentAdaptingMatcher is actually not required
for the implementation of makeDynCastAllOfComposite - this
simplification makes it more obvious where the bind() call
can be used based on the matcher creation function types.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160673 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
e68c229386a741f3116fe14198651059999d971d 24-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parser unit tests: split a huge test case


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160649 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
debd16f75fdfa3fb0a498f89450ea574dfb3af4e 24-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parser unit tests: reduce code duplication


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160647 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
f919985b6e3be23ec840f2c9d35bdf49890fe545 23-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> add AST unittests to CMake build system


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160640 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
MakeLists.txt
9f08f49929324ec6863e81b22a43fb2e8575b433 20-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Fix PR13411: Comment parsing: failed assertion on unterminated verbatim block.

The assertion was wrong in case we have a verbatim block without a closing
command.

Also add tests for closing command name in a verbatim block, since now it can
be empty in such cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160568 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
64da4e55c111f4733135e1780216609569767351 19-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: don't parse whitespace before \endverbatim as a separate line of whitespace.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160464 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
7c077027287e9beeaa263b1c80467164a638908c 17-Jul-2012 Daniel Jasper <djasper@google.com> Fix unit test dependency in Makefile and remove unneccessary dependency
again.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160358 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CMakeLists.txt
ooling/Makefile
62fb1e31b000e032610e883f216707ccb603ce89 17-Jul-2012 Daniel Jasper <djasper@google.com> Add missing dependency for unit test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160356 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CMakeLists.txt
8ee04480df468a11667dbfad1049d2b08c4b9482 17-Jul-2012 Daniel Jasper <djasper@google.com> Finishing the move of RefactoringCallbacks and fixing the corresponding
buildbot failures.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160355 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RefactoringCallbacksTest.cpp
d5c66dd664b005866c9f7fc91eb0d49164bca36f 17-Jul-2012 Daniel Jasper <djasper@google.com> Move RefactoringCallbacks to Tooling to avoid dependency from
ASTMatchers (lower level abstraction) to Tooling (higher level
abstraction).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160351 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/CMakeLists.txt
STMatchers/RefactoringCallbacksTest.cpp
ooling/CMakeLists.txt
ooling/RefactoringCallbacksTest.cpp
20b802d186dfc5db9b4a9ce83e9f31fa5aa4efcc 17-Jul-2012 Daniel Jasper <djasper@google.com> Make the isDerivedFrom matcher more generic.

It now accepts an arbitrary inner matcher but is fully backwards
compatible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160348 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
fe7beeb421b90f66b4a96c2358c5a838c376a0a8 16-Jul-2012 Daniel Jasper <djasper@google.com> Add refactoring callbacks to make common kinds of refactorings easy.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160255 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/CMakeLists.txt
STMatchers/RefactoringCallbacksTest.cpp
ff2fcb8db242a54f72bbb4e5595261e12672ed66 15-Jul-2012 Daniel Jasper <djasper@google.com> Fix spelling of anyOf matcher and add missing test.

Patch by Sam Panzer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160233 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
0eaf69d9a10149f0f344238183915912c2dca392 13-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment AST nodes: rename getXXXCount() methods to getNumXXXs() to be in line with Statement AST nodes.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160182 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentParser.cpp
a3c70966babdd6c63623470fbba9bb4ec37de4a5 13-Jul-2012 Manuel Klimek <klimek@google.com> Allows retrieving all files in a CompilationDatabase.

Patch by Tobias Koenig, some test changes by myself.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160167 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
3f38bf2d441fac379c427f86153fbb0cb41256c6 13-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment parsing: repaint the bikesched: rename 'HTML open tags' to 'HTML start tags' and 'HTML close tags' to 'HTML end tags' according to HTML spec.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160153 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
6a12449ec8862211856447d3df4c082a346339f2 12-Jul-2012 Daniel Jasper <djasper@google.com> This commit combines three patches to the ASTMatchers.

One adds matchers for the various parts of a for loop (initializer, condition,
increment), as well as extending the hasBody matcher to work for while and
do-while loops. The second patch adds an isInteger matcher for types.
The third patch fixes a bug in allOf, where a few of the name chages
(AllOf --> allOf) had been missed.

All matchers come with unit tests.

Patches by Sam Panzer!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160115 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
a5ef44ff5d93a3be6ca67782828157a71894cf0c 11-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Enable comment parsing and semantic analysis to emit diagnostics. A few
diagnostics implemented -- see testcases.

I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file. But I don't feel strongly about it.

This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).

In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to. There is no easy way to find a decl by
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments. If we do --
then we do the usual comment-finding process.

It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.

Added -Wdocumentation-html flag for semantic HTML errors to allow the user to
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160078 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
ST/Makefile
e0e6b9e79a0c4edae92abd3928263875c78e23aa 10-Jul-2012 Daniel Jasper <djasper@google.com> Add more matchers and do cleanups.

Reviewers: klimek

Differential Revision: http://ec2-50-18-127-156.us-west-1.compute.amazonaws.com/D2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160013 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
78a0ce4ed3d6cf3ad98e1b07fb1cd43b47793598 10-Jul-2012 Benjamin Kramer <benny.kra@googlemail.com> Disable death tests on platforms which don't support them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160000 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
e265c877934dd24d11d85e991ede7d0742178495 10-Jul-2012 Manuel Klimek <klimek@google.com> Fixes the MSVC build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159992 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
a99ec107ba6b5abaf27c6cc9318e65689163f2a1 09-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Comment lexing: fix lexing to actually work in non-error cases.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159963 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
28c82ee1aee75bfe4e700b97b01891f80c076d19 06-Jul-2012 Manuel Klimek <klimek@google.com> Another fix for the configure build: correct order of dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159809 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Makefile
c76dfb451aac08b52ab5858fbfade28c7e091e2f 06-Jul-2012 Manuel Klimek <klimek@google.com> Build-fix: Remove non-existent directories from Makefiles.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159807 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/Makefile
4da216637fa1ad4bdfd31bc265edb57ca35c2c12 06-Jul-2012 Manuel Klimek <klimek@google.com> Adds the AST Matcher library, which provides a in-C++ DSL to express
matches on interesting parts of the AST, and callback mechanisms to
act on them.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159805 91177308-0d34-0410-b5e6-96231b3b80d8
STMatchers/ASTMatchersTest.cpp
STMatchers/ASTMatchersTest.h
STMatchers/CMakeLists.txt
STMatchers/Makefile
MakeLists.txt
akefile
8d3ba23f2d9e6c87794d059412a0808c9cbacb25 06-Jul-2012 Dmitri Gribenko <gribozavr@gmail.com> Implement AST classes for comments, a real parser for Doxygen comments and a
very simple semantic analysis that just builds the AST; minor changes for lexer
to pick up source locations I didn't think about before.

Comments AST is modelled along the ideas of HTML AST: block and inline content.

* Block content is a paragraph or a command that has a paragraph as an argument
or verbatim command.
* Inline content is placed within some block. Inline content includes plain
text, inline commands and HTML as tag soup.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159790 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
ST/CommentParser.cpp
e6df0ce08fcdf9f906556d98cca96d38ab440bba 05-Jul-2012 Manuel Klimek <klimek@google.com> Adapts the FrontendAction convenience functions so that it can be
used with classes that generate ASTConsumers; this allows decoupling
the ASTConsumer generation from the Frontend library (like, for example,
the MatchFinder in the upcoming ASTMatcher patch).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159760 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/TestVisitor.h
ooling/ToolingTest.cpp
a13d2bceaea04cb7c16b4cfbeb06f12f8e90c6c9 04-Jul-2012 Benjamin Kramer <benny.kra@googlemail.com> Update unittests for include change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159724 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/FrontendActionTest.cpp
ooling/RefactoringTest.cpp
ooling/TestVisitor.h
5676d32a23faf0506f5c295980c2876c862488d5 28-Jun-2012 Dmitri Gribenko <gribozavr@gmail.com> Fix an infinite loop in comment lexer: we were not advancing in the input character stream when we saw a '<' that is not a start of an HTML tag.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159303 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
962668d2c192dd02f75b8ec3628a89964bfb738b 27-Jun-2012 Dmitri Gribenko <gribozavr@gmail.com> Remove unsigned and a pointer from a comment token (so that each token can have only one semantic string value attached to it), at a cost of adding an additional token.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159270 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CommentLexer.cpp
2d44d77fed3200e2eff289f55493317e90d3398c 26-Jun-2012 Dmitri Gribenko <gribozavr@gmail.com> Implement a lexer for structured comments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159223 91177308-0d34-0410-b5e6-96231b3b80d8
ST/CMakeLists.txt
ST/CommentLexer.cpp
ST/Makefile
akefile
8f35d23977bf7e70bab98545db0f687da997f20f 25-Jun-2012 Matt Beaumont-Gay <matthewbg@google.com> Appease -Wnon-virtual-dtor and fix a typo in a comment

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159151 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/TestVisitor.h
bc9e5582467e70ec38b9fc5d3605152e86e2a5f8 25-Jun-2012 Richard Smith <richard-llvm@metafoo.co.uk> Add testing for CommentHandler, and fix a bug where trailing comments in #else
and #endif in non-skipped blocks were not passed to the CommentHandler. Patch
by Andy Gibbs!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159119 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CMakeLists.txt
ooling/CommentHandlerTest.cpp
ooling/RecursiveASTVisitorTest.cpp
ooling/TestVisitor.h
0c750ec837f7ae06f0a64d3da56d7578d923b3cf 21-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Clang side of a refactoring of the CMake unit test build strategy.

The fundamental change is to put a CMakeLists.txt file in the unittest
directory, with a single test binary produced from it. This has several
advantages.

Among other fundamental advantages, we start to get the checking logic
for when a file is missing from the CMake build, and this caught one
missing file already! More fun details in the LLVM commit corresponding
to this one.

Note that the LLVM commit and this one most both be applied, or neither.
Sorry for any skew issues.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158910 91177308-0d34-0410-b5e6-96231b3b80d8
asic/CMakeLists.txt
MakeLists.txt
rontend/CMakeLists.txt
ex/CMakeLists.txt
ooling/CMakeLists.txt
1071ba9c324d831b437870a1fe63bf2ecdc4e9e4 21-Jun-2012 Daniel Jasper <djasper@google.com> Make the RecursiveASTVisitor visit the body of a range-based for loop
again. This was broken in r158395.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158907 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
20e4129bd088da0a3bb7ea4941242802096cfcfc 21-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Switch Clang to re-use the the newly factored common LLVM
implementation. Yay for '-' lines in CMake!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158897 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
f96b9ce9d9bc8f11c7ec0ab856e592059c0f830a 21-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Simplify the Clang unittest function in the CMake build, and make it
match the LLVM implemenation. This also simplifies the name management
and splits the custom library management out from the unittest specific
management. It finally drops the dependency on parsing cmake arguments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158894 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
b0d8671f95fe08a220118bca29063ba4d11a9dac 21-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Remove a goofy CMake hack and use the standard CMake facilities to
express library-level dependencies within Clang.

This is no more verbose really, and plays nicer with the rest of the
CMake facilities. It should also have no change in functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158888 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
caba856a867c058f6c69ec0d5f3ea8169776fb9a 21-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Remove an unused feature of the clang unittest macro.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158884 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
f95d4125c01fa7b98722ae8cfbceac4a87d037b4 20-Jun-2012 Chandler Carruth <chandlerc@gmail.com> Fix a big layering violation introduced by r158771.

That commit added a new library just to hold the RawCommentList. I've
started a discussion on the commit thread about whether that is really
meritted -- it certainly doesn't seem necessary at this stage.

However, the immediate problem is that the AST library has a hard
dependency on the Comment library, but the dependencies were set up
completely backward. In addition to the layering violation, this had an
unfortunate effect if scattering the Comments library dependency
throughout the build system, but inconsistently so -- several parts of
the CMake dependencies were missing and only showed up due to transitive
deps or the fact that the target wasn't being built by tho bots.

It turns out that the Comments library can't (currently) be a well
formed layer *below* the AST library either, as it has an API that
accepts an ASTContext. That parameter is currently unused, so maybe that
was a mistake?

Anyways, it really seems like this is logically part of the AST --
that's the whole point of the ASTContext providing access to it as far
as I can tell -- so I've merged it into the AST library to solve the
immediate layering violation problems and remove some of the churn from
our library dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158807 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
ooling/Makefile
aa0cd85838f2a024e589ea4e8c2094130065af21 20-Jun-2012 Dmitri Gribenko <gribozavr@gmail.com> Structured comment parsing, first step.

* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158771 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
ooling/Makefile
2e413f977d13d83b5baf7b5e4e93fe7c390959ca 19-Jun-2012 Jordan Rose <jordan_rose@apple.com> Fix the location of the fixit for -Wnewline-eof.

It turns out SourceManager treating the "one-past-the-end" location as invalid,
but then failing to set the invalid flag properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158699 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
8f19037d2b0aab8690e82273578c3b675ae55cd4 16-Jun-2012 NAKAMURA Takumi <geek4civic@gmail.com> ToolingTest.cpp: Fix r158592, runToolOnCode.FindsNoTopLevelDeclOnEmptyCode on msvc. LangOpts.MicrosoftExt still appends "class type_info;".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158595 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
c5613b26a24a33d7450e3d0bf315c6ccc920ce7b 16-Jun-2012 Meador Inge <meadori@codesourcery.com> Explicitly build __builtin_va_list.

The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158592 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
52ec0c0357ce970ca52a27c1086626450f0967e7 13-Jun-2012 Daniel Jasper <djasper@google.com> Rename shouldVisitImplicitDeclarations to shouldVisitImplicitCode.
Fix RecursiveASTVisitor to visit CXXForRangeStmts accordingly to visit
implicit or explicit code.

The key bug that inspired this was the Visitor not visiting the range
initializer of such a loop, which is explicit code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158395 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
c2a50d49e58bfec24ca4a9072bcbefda31830b96 07-Jun-2012 Benjamin Kramer <benny.kra@googlemail.com> Move sideeffecting call out of assert().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158146 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
7b699ac3ac8ce48cf9e9387f6b6830f3a8d409d5 06-Jun-2012 Manuel Klimek <klimek@google.com> Switches the RewriterTestContext away from PathV1.
Now the ToolingTests all work on Windows, and they also clean up their temporary directory if they don't crash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158112 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
d6f6569bf693da3f8efd8ce7ae93fbbfccf09753 05-Jun-2012 Manuel Klimek <klimek@google.com> Fixes the refactoring library test in VS2010.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158019 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
c28a335184207a47f34eb9d1707dc8d7c6c7b8b6 05-Jun-2012 Richard Smith <richard-llvm@metafoo.co.uk> RecursiveASTVisitor: add ability to visit implicit declarations. Patch by
James Dennett!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158002 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
8f4c4ca0ce5545df7f04e1d1efb40782163b7960 02-Jun-2012 NAKAMURA Takumi <geek4civic@gmail.com> Revert r157819, "#ifdef out a broken test on win32"

FYI, LLVM_ON_WIN32 is useless.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157890 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
29fbfc21924a692155ac8e4e281f17438fe27d63 01-Jun-2012 Alexander Kornienko <alexfh@google.com> #ifdef out a broken test on win32


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157819 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
5f60f606093019174a11fcfd3ae36634dc44e8c9 01-Jun-2012 Alexander Kornienko <alexfh@google.com> Added a test for ToolInvocation::mapVirtualFile method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157812 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ToolingTest.cpp
6fada8e820f2fd1b4cd38e48c8986110e87c5915 31-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> Only visit default arguments for template declarations when visiting the template declaration which introduced them. Patch by Yang Chen!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157723 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
e966beaa6ef3eb7ced09203f748e6042f81b2a6c 30-May-2012 Daniel Jasper <djasper@google.com> Test commit - Fix typo in comment.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157674 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
4f85274e5447e3b1f71c2750304b5f1af11bc96b 27-May-2012 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests/Tooling/RewriterTestContext.h: Don't try to remove TemporaryDirectory.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157530 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RewriterTestContext.h
f9d4cbd3dd1eb4cf3ec3c5ec7acc310415beeefd 23-May-2012 Manuel Klimek <klimek@google.com> Adds the Refactoring library, which is a layer on top of the Tooling library
that allows easy refactoring across translation units.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157331 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/RefactoringTest.cpp
bf78267de5e77e110124d2fcacc73777c97625f5 22-May-2012 Manuel Klimek <klimek@google.com> Fixes the autoconf build.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157266 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/Makefile
bfbfee51ec8f20f3f1b9f8329705d816b67438e7 22-May-2012 Manuel Klimek <klimek@google.com> Adds a method overwriteChangedFiles to the Rewriter. This is implemented by
first writing the changed files to a temporary location and then overwriting
the original files atomically.

Also adds a RewriterTestContext to aid unit testing rewrting logic in general.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157260 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/RewriterTest.cpp
ooling/RewriterTestContext.h
1a8d6861278051b2109c98baf6a7478a6f3f98aa 15-May-2012 Manuel Klimek <klimek@google.com> Fixes crasher bug in JSONCompilationDatabase for invalid input.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156814 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
06cd51a83577019ea26661b7d570ae9aef06f674 10-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> RecursiveASTVisitor:

We don't create any declaration to mark the explicit instantiation of function
templates other than the instantiation itself, so visit that when traversing
the function template decl.

This is a temporary fix, pending the creation of a Decl node to represent the
explicit instantiation.

Patch by Daniel Jasper!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156522 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
c8c222830a1d8df8ed05bedfcac868fe6838fba8 02-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> Unrevert r155951, reverted in r155962, with two changes:
* Work around build failures due to gcc 4.2 bugs.
* Remove BodyIndexer::TraverseCXXOperatorCallExpr, which was not being called
prior to this change, and whose presence disables a RecursiveASTVisitor
stack space optimization after this change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155969 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
b51c7f3fe619de753146ffd167f1c6b1df8bf443 02-May-2012 Andrew Trick <atrick@apple.com> Revert "Fix RecursiveASTVisitor's data recursion to call the Traverse* functions if they"

FAIL: Clang :: Index/index-many-call-ops.cpp

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155962 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
e3ba2987b9d55fdc976362ddccdb8c5a73d19fc9 01-May-2012 Richard Smith <richard-llvm@metafoo.co.uk> Fix RecursiveASTVisitor's data recursion to call the Traverse* functions if they
have been overridden in the derived class. Also, remove a non-functional
implementation of an incorrect optimization for ParenExprs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155951 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
e002631101d3bafbc90ed8589ffc615f04dc245b 26-Apr-2012 David Blaikie <dblaikie@gmail.com> Fix file name in comment.

Patch by Yang Chen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155658 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
a313b2fbba86c901e58dc58df036e731f24fdaee 26-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> RecursiveASTVisitor: When in 'shouldVisitTemplateInstantiations' mode, visit
all instantiations of a template when we visit the canonical declaration of the
primary template, rather than trying to match them up to the partial
specialization from which they are instantiated. This fixes a bug where we
failed to visit instantiations of partial specializations of member templates of
class templates, and naturally extends to allow us to visit instantiations where
we have instantiated only a declaration.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155597 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
5482dc3a88fce51307b5e1e19bdf72dea1562040 24-Apr-2012 Richard Smith <richard-llvm@metafoo.co.uk> RecursiveASTVisitor: Visit instantiations of member templates of class
templates. In an implicit instantiation of a member class, any member
templates don't get instantiated, so the existing check which only visited
the instantiations of a defined template skipped these templates'
instantiations.

Since there is only a single declaration of a member template of a class
template specialization, just use that to determine whether to visit the
instantiations. This introduces a slight inconsistency in that we will
visit the instantiations of such templates whether or not they are
defined, but we never visit a declared-but-not-defined instantiation, so
this turns out to not matter.

Patch by Daniel Jasper!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155487 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
9f99d06e0d22380b9d1f0609a083dbfbd8b37c10 23-Apr-2012 Manuel Klimek <klimek@google.com> Fix PR12608. Patch contributed by Yang Chen.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155355 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
dab28942c4ebd04e279535207c366faedea260a6 20-Apr-2012 Manuel Klimek <klimek@google.com> No need to put the SourceManager in with the ASTContext, as the ASTContext
already contains the SourceManager.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155198 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/RecursiveASTVisitorTest.cpp
fad7f85553da052559077f28c6937a8dd704b28d 19-Apr-2012 Manuel Klimek <klimek@google.com> Adds a unit test for the RecursiveASTVisitor.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155108 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/RecursiveASTVisitorTest.cpp
30318e6df9c8c24d080211dfb92ef8065fa7381c 18-Apr-2012 Manuel Klimek <klimek@google.com> Adds a FixedCompilationDatabase to be able to specify tool parameters
at the command line.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154989 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/CompilationDatabaseTest.cpp
ba8be8c422064b9bda68bdfa28d7f2775e9147f4 13-Apr-2012 Douglas Gregor <dgregor@apple.com> Kill the last vestiges of clangIndex

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154675 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
29b815cde2d7ac27dcac353902c7817e59ba0921 04-Apr-2012 Benjamin Kramer <benny.kra@googlemail.com> clangFrontend depends on clangEdit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154010 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/Makefile
cb971c6726d16e12ecd2a340941d7f5c06698332 04-Apr-2012 Manuel Klimek <klimek@google.com> Adds a tooling library.

Provides an API to run clang tools (FrontendActions) as standalone tools,
or repeatedly in-memory in a process. This is useful for unit-testing,
map-reduce style applications, source transformation daemons or command line
tools.

The ability to run over multiple translation units with different command
line arguments enables building up refactoring tools that need to apply
transformations across translation unit boundaries.

See tools/clang-check/ClangCheck.cpp for an example.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154008 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
akefile
ooling/CompilationDatabaseTest.cpp
ooling/Makefile
ooling/ToolingTest.cpp
db81d38d9cd468a9eeffe8ab092be4d48e43888e 27-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Handle correctly inclusion directives that have macro expansions, e.g
"#include MACRO(STUFF)".

-As an inclusion position for the included file, use the file location of the file where it
was included but *after* the macro expansions. We want the macro expansions to be considered
as before-in-translation-unit for everything in the included file.

-In the preprocessing record take into account that only inclusion directives can be encountered
as "out-of-order" (by comparing the start of the range which for inclusions is the hash location)
and use binary search if there is an extreme number of macro expansions in the include directive.

Fixes rdar://11111779

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153527 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
1c31ee8f9bf8c4de29cd8ca42dfe0fb37aa2bf52 06-Mar-2012 Fariborz Jahanian <fjahanian@apple.com> get rid of an unsued variable warning.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152146 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
30660a898545416f0fea2d717f16f75640001e38 06-Mar-2012 Ted Kremenek <kremenek@apple.com> Add new code migrator support for migrating existing Objective-C code to use
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.

This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator. We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152141 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
ex/LexerTest.cpp
c6c54521f95760a5eaf29b668d4bf41fe2af49d7 05-Mar-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> [preprocessor] Enhance PreprocessingRecord to keep track of locations of conditional directives.

Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns
true if a given range intersects with a conditional directive block.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152018 91177308-0d34-0410-b5e6-96231b3b80d8
ex/PreprocessingRecordTest.cpp
c93dc7889644293e318e19d82830ea2acc45b678 20-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> Basic: import IntrusiveRefCntPtr<> into clang namespace

The class name is long enough without the llvm:: added.
Also bring in RefCountedBase and RefCountedBaseVPTR.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150958 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
36d592718ff342f762e32cbde73d1113f88cb275 13-Feb-2012 Dylan Noblesmith <nobled@dreamwidth.org> drop more llvm:: prefixes on SmallString<>

More cleanup after r149799.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150380 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
8fe83e1df954d72c0f4ffc15d20a5222ec151c21 04-Feb-2012 Benjamin Kramer <benny.kra@googlemail.com> Move a method from IdentifierTable.h out of line and remove the SmallString include.

Fix all the transitive include users.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149783 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
a83f4d2315dbeb3914868f1ccb8e74fb2ccdbb0c 03-Feb-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Change Lexer::makeFileCharRange() to have it accept a CharSourceRange
instead of a SourceRange, and handle the case where the range is
a char (not token) range.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149677 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
dc58aa71026cce539ca9b5c2c52cc4efc7bd77fe 30-Jan-2012 Douglas Gregor <dgregor@apple.com> Thread a TargetInfo through to the module map; we'll need it for
target-specific module requirements.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149224 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
ex/LexerTest.cpp
7f6cf9764b33381e03fcf7c44f7985a333212b06 23-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Improve Lexer::getImmediateMacroName to take into account inner macros
of macro arguments.

For "MAC1( MAC2(foo) )" and location of 'foo' token it would return
"MAC1" instead of "MAC2".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148704 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
d9806c912ae3e870a733acfd83c26e8a1f6a5ffc 20-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Enhance Lexer::makeFileCharRange to check for ranges inside a macro argument
expansion, in which case it returns a file range in the location where the
argument was spelled.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148551 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
eabcf7e1d4c2be34653a936cff93d0872fe929dd 20-Jan-2012 Douglas Gregor <dgregor@apple.com> Fix broken unit test

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148547 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/FrontendActionTest.cpp
65eccf007d1275f571f596ca68c9ad6abc906c46 19-Jan-2012 Benjamin Kramer <benny.kra@googlemail.com> Silence set-but-unused warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148496 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
e64d9037658a1b95c79ea275af6167a110b3c563 19-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce Lexer::getSourceText() that returns a string for the source
that the given source range encompasses.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148481 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
11b652d41d0d97380ab321a1dba48ecb044f9de8 19-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Introduce Lexer::makeFileCharRange() that accepts a token source range
and returns a character range with file locations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148480 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
69bda4c027671df7163619f215209529eb236620 19-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> For Lexer's isAt[Start/End]OfMacroExpansion add an out parameter for the macro
start/end location.

It is commonly needed after calling the function; with this way we avoid
recalculating it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148479 91177308-0d34-0410-b5e6-96231b3b80d8
ex/LexerTest.cpp
19d5aea478b4f542e1ef7c36741e719c660bcc20 19-Jan-2012 Argyrios Kyrtzidis <akyrtzi@gmail.com> Add unit testing for Lexer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148478 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ex/LexerTest.cpp
ex/Makefile
akefile
18383f0eabc67c94ac986c86a2d757ddc3dcee44 31-Dec-2011 NAKAMURA Takumi <geek4civic@gmail.com> clang/unittests/Basic/SourceManagerTest.cpp: Fixup corresponding to r147387.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147388 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
cee5ec9df479994e4ba27fb65b7ded5bb5a980eb 21-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> Fix bugs in SourceManager::computeMacroArgsCache() and add a unit test for it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147057 91177308-0d34-0410-b5e6-96231b3b80d8
asic/SourceManagerTest.cpp
d7711ec430fde5706f85ba6c4b85283a8e743ff7 21-Dec-2011 Argyrios Kyrtzidis <akyrtzi@gmail.com> For SourceManager::isBeforeInTranslationUnit(), have it consider macro arg expanded
token locations as coming before the closing ')' of a function macro expansion.

Include a unit test for SourceManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147056 91177308-0d34-0410-b5e6-96231b3b80d8
asic/Makefile
asic/SourceManagerTest.cpp
MakeLists.txt
08d6e032a2a0a8656d12b3b7b93942987bb12eb7 16-Dec-2011 Richard Smith <richard-llvm@metafoo.co.uk> C++11 constexpr: Add note stacks containing backtraces if constant evaluation
fails within a call to a constexpr function. Add -fconstexpr-backtrace-limit
argument to driver and frontend, to control the maximum number of notes so
produced (default 10). Fix APValue printing to be able to pretty-print all
APValue types, and move the testing for this functionality from a unittest to
a -verify test now that it's visible in clang's output.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146749 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
ST/Makefile
MakeLists.txt
akefile
2587ede84d7de6e8ad5b0de9c4ee5eca070a3fd1 29-Sep-2011 Douglas Gregor <dgregor@apple.com> Attempt to fix unit tests

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140748 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
40847cfb58acc3cac7d68727df9455ac45f2e118 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename DiagnosticInfo to Diagnostic as per issue 5397


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140493 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
78ad0b98848c17a0a11847fa1d456e2dfec8aa2f 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename DiagnosticClient to DiagnosticConsumer as per issue 5397


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140479 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
d6471f7c1921c7802804ce3ff6fe9768310f72b9 26-Sep-2011 David Blaikie <dblaikie@gmail.com> Rename Diagnostic to DiagnosticsEngine as per issue 5397


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140478 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
d01fb36600642d2539b6a97bf2ae308cc44a9f46 23-Sep-2011 NAKAMURA Takumi <geek4civic@gmail.com> unittests/Basic/FileManagerTest.cpp: Suppress warnings on gcc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140364 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
5b106a872d66f57522b1cc6d1b67f93704409114 18-Jul-2011 Jeffrey Yasskin <jyasskin@google.com> Define DiagnosticBuilder<<APValue so it's easy to include APValues in
diagnostics.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135398 91177308-0d34-0410-b5e6-96231b3b80d8
ST/APValueTest.cpp
ST/Makefile
MakeLists.txt
akefile
8e27eb7ebf00dc24ca135698459c68ceb30c3963 24-Jun-2011 NAKAMURA Takumi <geek4civic@gmail.com> unittests/Basic/FileManagerTest.cpp: Unbreak Win32, mingw and msvc.

LLVM_ON_WIN32 is defined in llvm/Config/config.h.
IMO, it might be enough with _WIN32 in most cases, LLVM_ON_xxx could be deprecated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133794 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
72069b2f6facedfc5be5834f00590ae884c0be25 16-Jun-2011 John McCall <rjmccall@apple.com> This random unit test also depends on ARCMigrate.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133148 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
8f0e8d22960d56f8390f4971e2c0f2f0a0884602 16-Jun-2011 John McCall <rjmccall@apple.com> The ARC Migration Tool. All the credit goes to Argyrios and Fariborz
for this.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133104 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
16f213142f8f8f5410672205a19f79ed3c232929 02-Jun-2011 Manuel Klimek <klimek@google.com> Reverts the Tooling changes as requested by Chris.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132462 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/ASTMatchersTest.cpp
ooling/JsonCompileCommandLineDatabaseTest.cpp
ooling/ToolingTest.cpp
7264ab76f2039403bac61f503a99720f516e4d60 01-Jun-2011 Manuel Klimek <klimek@google.com> Fix broken test on windows. To get operator new working, we need size_t, for which we need to figure out a way to resolve standard include paths in the test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132386 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/ASTMatchersTest.cpp
64cbdf370984783911bb6d3bc25ec35a8b59e998 01-Jun-2011 Manuel Klimek <klimek@google.com> This patch implements an AST matching framework that allows to write
tools that match on the C++ ASTs. The main interface is in ASTMatchers.h,
an example implementation of a tool that removes redundant .c_str() calls
is in the example RemoveCStrCalls.cpp.

Various contributions:
Zhanyong Wan, Chandler Carruth, Marcin Kowalczyk, Wei Xu, James Dennett.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132374 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/ASTMatchersTest.cpp
c5cd252aba2ce3d3a6719d487bfea03f47e1785b 11-May-2011 Oscar Fuentes <ofv@wanadoo.es> Handle gcc-compatible compilers (such as clang) the same way we handle
gcc.

Fixes PR9886.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131182 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
850dd809534d172b66328d9827ae27880885ac5b 02-May-2011 Manuel Klimek <klimek@google.com> Adds a test for the command line parser when a quoted string is not closed by a quote.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130704 91177308-0d34-0410-b5e6-96231b3b80d8
ooling/JsonCompileCommandLineDatabaseTest.cpp
9a05fa97df4d5e64f740848a7759ecae5e1ed162 27-Apr-2011 Manuel Klimek <klimek@google.com> This is the next step in building the standalone tools infrastructure:
This patch simplifies writing of standalone Clang tools. As an
example, we add clang-check, a tool that runs a syntax only frontend
action over a .cc file. When you integrate this into your favorite
editor, you get much faster feedback on your compilation errors, thus
reducing your feedback cycle especially when writing new code.

The tool depends on integration of an outstanding patch to CMake to
work which allows you to always have a current compile command
database in your cmake output directory when you set
CMAKE_EXPORT_COMPILE_COMMANDS.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130306 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/JsonCompileCommandLineDatabaseTest.cpp
ooling/ToolingTest.cpp
cf3ce5d89628b3955c638fb102c8dc4c24e1986d 21-Apr-2011 Manuel Klimek <klimek@google.com> Adds a function to run FrontendActions over in-memory code. This is
the first step towards a standalone Clang tool infrastructure.
The plan is to make it easy to build command line tools that run over
the AST of source files in a project outside of the build system.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129924 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
ooling/ToolingTest.cpp
a3f787c32b84a5c66d48e1b9713bdd66d3866f57 20-Feb-2011 Oscar Fuentes <ofv@wanadoo.es> Put targets on folders, if the IDE supports the feature.

Requires CMake 2.8.3 or newer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126094 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
4b93d660c6326ec79b5e369317d1051cf826c2f3 20-Feb-2011 Peter Collingbourne <peter@pcc.me.uk> Re-instate r125819 and r125820 with no functionality change

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126060 91177308-0d34-0410-b5e6-96231b3b80d8
asic/Makefile
rontend/FrontendActionTest.cpp
rontend/Makefile
96b1d4b4eb6b18dd6df7a2c0833332b45840580f 19-Feb-2011 Rafael Espindola <rafael.espindola@gmail.com> Revert 125820 and 125819 to fix PR9266.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126050 91177308-0d34-0410-b5e6-96231b3b80d8
asic/Makefile
rontend/FrontendActionTest.cpp
rontend/Makefile
f91ae524c01488ef2e525e5d73fa61424948e6c6 19-Feb-2011 Jeffrey Yasskin <jyasskin@google.com> Use PARSE_ARGUMENTS to clean up add_clang_unittest's calling convention.

It would be nice to propagate this into the other functions to replace
LLVM_LINK_COMPONENTS and friends, but I don't plan to do that.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126032 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
effc48d217bfe5c12635e957030803bde1c4a64f 19-Feb-2011 Jeffrey Yasskin <jyasskin@google.com> Remove support and mc from the clang unittests' dependencies because they're not
needed or provided by the libraries under test.

The next step is to import http://www.itk.org/Wiki/CMakeMacroParseArguments to
make the empty string parameter unnecessary.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126024 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
906c73ffbc78542ad333becb6e013dd9efc299b6 18-Feb-2011 Peter Collingbourne <peter@pcc.me.uk> Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction

This removes the final dependency edge from any lib outside of CodeGen
to core. As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125820 91177308-0d34-0410-b5e6-96231b3b80d8
asic/Makefile
MakeLists.txt
rontend/FrontendActionTest.cpp
rontend/Makefile
c515d18023e952357d5dee645e6e3539b7b3d992 16-Feb-2011 Zhanyong Wan <wan@google.com> Adds a CMake target for the Basic lib's unit tests. Reviewed by
jyasskin and chapuni.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125657 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
05cb9f2d61a0c5efa78ea43bc87685fd85c81c6c 16-Feb-2011 Zhanyong Wan <wan@google.com> Improves CMakeLists.txt for Clang's unit tests: make "linked
components" and "used libs" arguments of add_clang_unittest().
Reviewed by jyasskin and chapuni.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125652 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
483651c907726b216760edef91d8a961378dfc26 15-Feb-2011 Zhanyong Wan <wan@google.com> Moves FileManagerTest.cpp to unittests/Basic such that the unit test
directory structure matches the library structure. Reviewed by jyasskin.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125600 91177308-0d34-0410-b5e6-96231b3b80d8
asic/FileManagerTest.cpp
asic/Makefile
ileManager/FileManagerTest.cpp
ileManager/Makefile
akefile
718b01d077748989f860bd21ee3402852ed0ed86 15-Feb-2011 Jeffrey Yasskin <jyasskin@google.com> Add CMake support to the clang unittests.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125561 91177308-0d34-0410-b5e6-96231b3b80d8
MakeLists.txt
9b555ea217565ac0f8bf7255b29496916cb03476 11-Feb-2011 Zhanyong Wan <wan@google.com> Improves Clang's virtual file handling.

This patch contains:

- making some of the existing comments more accurate in the presence
of virtual files/directories.

- renaming some private data members of FileManager to match their roles better.

- creating 'DirectorEntry's for the parent directories of virtual
files, such that we can tell whether two virtual files are from the
same directory. This is useful for injecting virtual files whose
directories don't exist in the real file system.

- minor clean-ups and adding comments for class
FileManager::UniqueDirContainer and FileManager::UniqueFileContainer.

- adding statistics on virtual files to FileManager::PrintStats().

- adding unit tests to verify the existing and new behavior of FileManager.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125384 91177308-0d34-0410-b5e6-96231b3b80d8
ileManager/FileManagerTest.cpp
ileManager/Makefile
akefile
f0ed580ea5cdc171973c1ac259a9ee21badb80d8 09-Feb-2011 Zhanyong Wan <wan@google.com> Fix a typo in a comment in tools/clang/unittests/Frontend/Makefile.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125182 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/Makefile
9acd0d92f4135bfb6a31eaad067b2972d6e1b62c 04-Feb-2011 Daniel Dunbar <daniel@zuster.org> build: Prevent duplicate inclusion of Makefile.rules, which causes make to warn
like crazy.
- How no one else is bothered by this I can't understand!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124873 91177308-0d34-0410-b5e6-96231b3b80d8
akefile
7a17889829b3f3655c47e2b01e282832fdb466d6 03-Feb-2011 Jeffrey Yasskin <jyasskin@google.com> Add gTest unittests to clang, and write the first one.
This is the Makefile version only; the cmake implementation is coming soon.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124777 91177308-0d34-0410-b5e6-96231b3b80d8
rontend/FrontendActionTest.cpp
rontend/Makefile
akefile