]> granicus.if.org Git - clang/log
clang
11 years ago[analyzer; new edges] In for(;;), use the ForStmt itself for loop notes.
Jordan Rose [Thu, 30 May 2013 01:05:58 +0000 (01:05 +0000)]
[analyzer; new edges] In for(;;), use the ForStmt itself for loop notes.

Most loop notes (like "entering loop body") are attached to the condition
expression guarding a loop or its equivalent. For loops may not have a
condition expression, though. Rather than crashing, just use the entire
ForStmt as the location. This is probably the best we can do.

<rdar://problem/14016063>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182904 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[libclang] When indexing a @synthesize, don't consider that it defines a getter/sette...
Argyrios Kyrtzidis [Wed, 29 May 2013 23:58:31 +0000 (23:58 +0000)]
[libclang] When indexing a @synthesize, don't consider that it defines a getter/setter if one is already defined by the user.

Fixes rdar://13925258

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182895 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDocument -fno-sanitize-recover and -fsanitize-undefined-trap-on-error and attempt...
Richard Smith [Wed, 29 May 2013 22:57:31 +0000 (22:57 +0000)]
Document -fno-sanitize-recover and -fsanitize-undefined-trap-on-error and attempt to explain the difference between them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182890 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFixes error when splitting block comments.
Manuel Klimek [Wed, 29 May 2013 22:06:18 +0000 (22:06 +0000)]
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

11 years agoSplit off casts to void* for -Wint-to-pointer-cast to subgroup -Wint-to-void-pointer...
Ted Kremenek [Wed, 29 May 2013 21:50:46 +0000 (21:50 +0000)]
Split off casts to void* for -Wint-to-pointer-cast to subgroup -Wint-to-void-pointer-cast.

This change is motivated from user feedback that some APIs use
void* as an opaque "context" object that may not really be a pointer.
Such users want an ability to turn off the warning for casts
to void* while preserving the warning for other cases.

Implements <rdar://problem/14016721>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182884 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd another test case for r182814.
David Majnemer [Wed, 29 May 2013 21:09:52 +0000 (21:09 +0000)]
Add another test case for r182814.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182882 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTurn CLANG_ENABLE_{ARCMT,REWRITER,STATIC_ANALYZER} into proper options so that
Roman Divacky [Wed, 29 May 2013 21:09:18 +0000 (21:09 +0000)]
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

11 years ago[analyzer] Accept references to variables declared "extern void" (C only).
Jordan Rose [Wed, 29 May 2013 20:50:34 +0000 (20:50 +0000)]
[analyzer] Accept references to variables declared "extern void" (C only).

In C, 'void' is treated like any other incomplete type, and though it is
never completed, you can cast the address of a void-typed variable to do
something useful. (In C++ it's illegal to declare a variable with void type.)

Previously we asserted on this code; now we just treat it like any other
incomplete type.

And speaking of incomplete types, we don't know their extent. Actually
check that in TypedValueRegion::getExtent, though that's not being used
by any checkers that are on by default.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182880 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove unused field.
Rafael Espindola [Wed, 29 May 2013 19:51:12 +0000 (19:51 +0000)]
Remove unused field.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182874 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[libclang] For "@import .." code-completion results, associate a CXCursor_ModuleImpor...
Argyrios Kyrtzidis [Wed, 29 May 2013 18:50:15 +0000 (18:50 +0000)]
[libclang] For "@import .." code-completion results, associate a CXCursor_ModuleImportDecl cursor instead of CXCursor_NotImplemented.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182871 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[ms-cxxabi] Implement MSVC virtual base adjustment
Reid Kleckner [Wed, 29 May 2013 18:02:47 +0000 (18:02 +0000)]
[ms-cxxabi] Implement MSVC virtual base adjustment

While we can't yet emit vbtables, this allows us to find virtual bases
of objects constructed in other TUs.

This make iostream hello world work, since basic_ostream virtually
inherits from basic_ios.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182870 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[ms-cxxabi] Fix r182865 to have an actual Itanium-style key function
Reid Kleckner [Wed, 29 May 2013 16:51:17 +0000 (16:51 +0000)]
[ms-cxxabi] Fix r182865 to have an actual Itanium-style key function

Peter pointed out that C::f() is not a key function.  C's key function
is actually C::~C().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182866 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[ms-cxxabi] There are no key functions in the Microsoft C++ ABI
Reid Kleckner [Wed, 29 May 2013 16:18:30 +0000 (16:18 +0000)]
[ms-cxxabi] There are no key functions in the Microsoft C++ ABI

MSVC's class data is always comdat, so clang's should always be
linkonce_odr in LLVM IR.

Reviewers: pcc

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182865 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTooling: Call back for both begin and end of sources
Edwin Vane [Wed, 29 May 2013 16:01:10 +0000 (16:01 +0000)]
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

11 years agoUse a non-recursive implementation to reconstruct line breaks.
Manuel Klimek [Wed, 29 May 2013 15:10:11 +0000 (15:10 +0000)]
Use a non-recursive implementation to reconstruct line breaks.

Now that the TokenAnnotator does not require stack space anymore,
reconstructing the lines has become the limiting factor. This patch
fixes that problem, allowing large files with multiple megabytes of
single unwrapped lines to be formatted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182861 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoThe second step in the token refactoring.
Manuel Klimek [Wed, 29 May 2013 14:47:47 +0000 (14:47 +0000)]
The second step in the token refactoring.

Gets rid of AnnotatedToken, putting everything into FormatToken.
FormatTokens are created once, and only referenced by pointer.  This
enables multiple future features, like having tokens shared between
multiple UnwrappedLines (while there's still work to do to fully enable
that).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182859 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd return missing in r182855.
Daniel Jasper [Wed, 29 May 2013 14:09:17 +0000 (14:09 +0000)]
Add return missing in r182855.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182856 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoLeave some macros on their own line
Daniel Jasper [Wed, 29 May 2013 13:16:10 +0000 (13:16 +0000)]
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

11 years agoAdd option to always break template declarations.
Daniel Jasper [Wed, 29 May 2013 12:07:31 +0000 (12:07 +0000)]
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

11 years agoDon't compute the visibility unless we really have to.
Rafael Espindola [Wed, 29 May 2013 04:55:30 +0000 (04:55 +0000)]
Don't compute the visibility unless we really have to.

This brings the number of linkage computations in "clang -cc1" in SemaExpr.ii
from 58426 to 43134. With -emit-llvm the number goes from 161045 to 145461.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182823 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix bad indentation.
Jakob Stoklund Olesen [Wed, 29 May 2013 03:57:23 +0000 (03:57 +0000)]
Fix bad indentation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182821 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd a testcase from pr16059.
Rafael Espindola [Wed, 29 May 2013 03:10:01 +0000 (03:10 +0000)]
Add a testcase from pr16059.

It was fixed back in r182750, but this is a nice testcase to have.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182818 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDisallow extern decls of type void in C++ mode
David Majnemer [Wed, 29 May 2013 00:56:45 +0000 (00:56 +0000)]
Disallow extern decls of type void in C++ mode

C++ and C differ with respect to the handling of extern void
declarations. Enforce the C++ behavior in C++ mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182814 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjective-C [qoi]: Improve on diagnostic when a method used
Fariborz Jahanian [Tue, 28 May 2013 23:49:32 +0000 (23:49 +0000)]
Objective-C [qoi]: Improve on diagnostic when a method used
in an @selector expression has no implementation.
// rdar://14002507

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182812 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove links to old checker builds.
Ted Kremenek [Tue, 28 May 2013 23:30:24 +0000 (23:30 +0000)]
Remove links to old checker builds.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182811 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Use the expression’s type instead of region’s type in ArrayToPointer decay...
Anna Zaks [Tue, 28 May 2013 23:24:01 +0000 (23:24 +0000)]
[analyzer] Use the expression’s type instead of region’s type in ArrayToPointer decay evaluation

This gives slightly better precision, specifically, in cases where a non-typed region represents the array
or when the type is a non-array type, which can happen when an array is a result of a reinterpret_cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182810 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Re-enable reasoning about CK_LValueBitCast
Anna Zaks [Tue, 28 May 2013 22:32:08 +0000 (22:32 +0000)]
[analyzer] Re-enable reasoning about CK_LValueBitCast

It’s important for us to reason about the cast as it is used in std::addressof. The reason we did not
handle the cast previously was a crash on a test case (see commit r157478). The crash was in
processing array to pointer decay when the region type was not an array. Address the issue, by
just returning an unknown in that case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182808 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCheck the linkage cache at every recursive step.
Rafael Espindola [Tue, 28 May 2013 19:43:11 +0000 (19:43 +0000)]
Check the linkage cache at every recursive step.

Before this patch the linkage cache was only used by the entry level function
(getLinkage). The function that does the actual computation (getLVForDecl),
never looked at it.

This means that we would not reuse an entry in the cache when getLVForDecl did
a recursive call. This patch fixes that by adding another computation enum
value for when we don't care about the linkage at all and having getLVForDecl
check the cache in that case.

When running "clang -cc1" over SemaExpr.ii this brings the number of linkage
computations from 93749 to 58426. When running "clang -cc1 -emit-llvm -O3" it
goes from 198708 to 161444.

For SemaExpr.ii at least linkage computation is a small enough percentage of
the work that the time difference was in the noise.

When asserts are enabled this patch also causes clang to check the linkage
cache even on recursive calls.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182799 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd an overridable MatchCallback::onEndOfTranslationUnit() function.
Peter Collingbourne [Tue, 28 May 2013 19:21:51 +0000 (19:21 +0000)]
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

11 years agoRemove obsolete variable as discovered in post-commit review.
Daniel Jasper [Tue, 28 May 2013 19:11:43 +0000 (19:11 +0000)]
Remove obsolete variable as discovered in post-commit review.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182796 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSupport uniform inits in braced lists.
Daniel Jasper [Tue, 28 May 2013 18:50:02 +0000 (18:50 +0000)]
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

11 years agoPatch to issue error when target of MacOS and iOS
Fariborz Jahanian [Tue, 28 May 2013 17:37:39 +0000 (17:37 +0000)]
Patch to issue error when target of MacOS and iOS
does not support large load/store of atomic objects.
// rdar://13973577

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182781 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Use a more generic MemRegion.getAsOffset to evaluate bin operators on...
Anna Zaks [Tue, 28 May 2013 17:31:43 +0000 (17:31 +0000)]
[analyzer] Use a more generic MemRegion.getAsOffset to evaluate bin operators on MemRegions

In addition to enabling more code reuse, this suppresses some false positives by allowing us to
compare an element region to its base. See the ptr-arith.cpp test cases for an example.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182780 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix formatting regression regarding pointers to arrays.
Daniel Jasper [Tue, 28 May 2013 15:27:10 +0000 (15:27 +0000)]
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

11 years agoFix a crash when we were trying to compute the linkage too early.
Rafael Espindola [Tue, 28 May 2013 14:09:46 +0000 (14:09 +0000)]
Fix a crash when we were trying to compute the linkage too early.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182773 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMake UnwrappedLines and AnnotatedToken contain pointers to FormatToken.
Manuel Klimek [Tue, 28 May 2013 13:42:28 +0000 (13:42 +0000)]
Make UnwrappedLines and AnnotatedToken contain pointers to FormatToken.

The FormatToken is now not copyable any more.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182772 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoclang/test/Driver/dyld-prefix.c: Exclude MSYS bash.
NAKAMURA Takumi [Tue, 28 May 2013 12:18:56 +0000 (12:18 +0000)]
clang/test/Driver/dyld-prefix.c: Exclude MSYS bash.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182769 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoA first step towards giving format tokens pointer identity.
Manuel Klimek [Tue, 28 May 2013 11:55:06 +0000 (11:55 +0000)]
A first step towards giving format tokens pointer identity.

With this patch, we create all tokens in one go before parsing and pass
an ArrayRef<FormatToken*> to the UnwrappedLineParser. The
UnwrappedLineParser is switched to use pointer-to-token internally.

The UnwrappedLineParser still copies the tokens into the UnwrappedLines.
This will be fixed in an upcoming patch.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182768 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoInitial support for designated initializers.
Daniel Jasper [Tue, 28 May 2013 11:30:49 +0000 (11:30 +0000)]
Initial support for designated initializers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182767 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDisable tab expansion when counting the columns in block comments.
Manuel Klimek [Tue, 28 May 2013 10:01:59 +0000 (10:01 +0000)]
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

11 years agoFixes indentation of empty lines in block comments.
Manuel Klimek [Tue, 28 May 2013 08:55:01 +0000 (08:55 +0000)]
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

11 years agoClean up formatting of function types.
Daniel Jasper [Tue, 28 May 2013 08:33:00 +0000 (08:33 +0000)]
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

11 years agoFix formatting of expressions containing ">>".
Daniel Jasper [Tue, 28 May 2013 07:42:44 +0000 (07:42 +0000)]
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

11 years agoBuild correct coercion types in SparcV9ABIInfo.
Jakob Stoklund Olesen [Tue, 28 May 2013 04:57:37 +0000 (04:57 +0000)]
Build correct coercion types in SparcV9ABIInfo.

The coercion type serves two purposes:

 1. Pad structs to a multiple of 64 bits, so they are passed
    'left-aligned' in registers.

 2. Expose aligned floating point elements as first-level elements, so
    the code generator knows to pass them in floating point registers.

We also compute the InReg flag which indicates that the struct contains
aligned 32-bit floats. This flag is used by the code generator to pick
the right registers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182753 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPropagate VisibleNoLinkage down to class members.
Rafael Espindola [Tue, 28 May 2013 02:22:10 +0000 (02:22 +0000)]
Propagate VisibleNoLinkage down to class members.

Fixes PR16114.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182750 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agouse getLVForDecl for consistency.
Rafael Espindola [Tue, 28 May 2013 02:13:28 +0000 (02:13 +0000)]
use getLVForDecl for consistency.

No intended functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182749 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd a SparcV9ABIInfo class for handling the standard SPARC v9 ABI.
Jakob Stoklund Olesen [Mon, 27 May 2013 21:48:25 +0000 (21:48 +0000)]
Add a SparcV9ABIInfo class for handling the standard SPARC v9 ABI.

- All integer arguments smaller than 64 bits are extended.
- Large structs are passed indirectly, not using 'byval'.
- Structs up to 32 bytes in size are returned in registers.

Some things are not implemented yet:

- EmitVAArg can be implemented in terms of the va_arg instruction.
- When structs are passed in registers, float members require special
  handling because they are passed in the floating point registers.
- Structs are left-aligned when passed in registers. This may require
  padding.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182745 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDriver: implement --dyld-prefix option.
Peter Collingbourne [Mon, 27 May 2013 21:40:20 +0000 (21:40 +0000)]
Driver: implement --dyld-prefix option.

This option is used to select a dynamic loader prefix to be used
at runtime. Currently this is implemented for the Linux toolchain.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182744 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove unreachable return
David Blaikie [Mon, 27 May 2013 20:43:54 +0000 (20:43 +0000)]
Remove unreachable return

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182742 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImprove formatting of templates.
Daniel Jasper [Mon, 27 May 2013 16:36:33 +0000 (16:36 +0000)]
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

11 years agoMajor refactoring of BreakableToken.
Manuel Klimek [Mon, 27 May 2013 15:23:34 +0000 (15:23 +0000)]
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

11 years agoFix the linkage of local types in inline VisibleNoLinkage functions.
Rafael Espindola [Mon, 27 May 2013 14:50:21 +0000 (14:50 +0000)]
Fix the linkage of local types in inline VisibleNoLinkage functions.

We were handling only local types in inline External functions before.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182737 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMove 3 helper function to Linkage.h
Rafael Espindola [Mon, 27 May 2013 14:14:42 +0000 (14:14 +0000)]
Move 3 helper function to Linkage.h

This removes a duplicate from Decl.cpp and a followup patch will use
isExternallyVisible.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182735 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImprove indentation of assignments.
Daniel Jasper [Mon, 27 May 2013 12:45:09 +0000 (12:45 +0000)]
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

11 years agoAddress post-review comment from dblakie.
Manuel Klimek [Mon, 27 May 2013 12:36:28 +0000 (12:36 +0000)]
Address post-review comment from dblakie.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182732 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix hacky way of preventing a certain type of line break.
Daniel Jasper [Mon, 27 May 2013 11:50:16 +0000 (11:50 +0000)]
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(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)
        .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

11 years agoAdd -fsanitize=leak to driver options.
Sergey Matveev [Mon, 27 May 2013 11:17:01 +0000 (11:17 +0000)]
Add -fsanitize=leak to driver options.

If -fsanitize=leak is specified, link the program with the
LeakSanitizer runtime. Ignore this option when -fsanitize=address is specified,
because AddressSanitizer has this functionality built in.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182729 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTests and status for DR51-99.
Richard Smith [Sun, 26 May 2013 22:03:53 +0000 (22:03 +0000)]
Tests and status for DR51-99.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182720 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFormatter/ObjC: In dictionary literals, break after ':', not before it.
Nico Weber [Sun, 26 May 2013 05:39:26 +0000 (05:39 +0000)]
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

11 years agoFix linkage computation for derived types in inline functions.
Rafael Espindola [Sat, 25 May 2013 17:16:20 +0000 (17:16 +0000)]
Fix linkage computation for derived types in inline functions.

John noticed that the fix for pr15930 (r181981) didn't handle indirect
uses of local types. For example, a pointer to local struct, or a
function that returns it.

One way to implement this would be to recursively look for local
types. This would look a lot like the linkage computation itself for
types.

To avoid code duplication and utilize the existing linkage cache, this
patch just makes the computation of "type with no linkage but
externally visible because it is from an inline function"  part of the
linkage computation itself.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182711 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix comment type pointed out by Kim Gräsman.
Duncan Sands [Sat, 25 May 2013 02:22:10 +0000 (02:22 +0000)]
Fix comment type pointed out by Kim Gräsman.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182702 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[Preprocessor] Prevent expansion of y in x ## y when x is empty
Argyrios Kyrtzidis [Sat, 25 May 2013 01:35:18 +0000 (01:35 +0000)]
[Preprocessor] Prevent expansion of y in x ## y when x is empty

When x is empty, x ## is suppressed, and when y gets expanded, the fact that it follows ## is not
available in the macro expansion result. The macro definition can be checked instead, the ## will
be available there regardless of what x expands to.

Fixes http://llvm.org/PR12767

Patch by Harald van Dijk!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182699 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMake isBeforeInTranslationUnit consistent in the face of failures to get a valid...
Argyrios Kyrtzidis [Sat, 25 May 2013 01:03:03 +0000 (01:03 +0000)]
Make isBeforeInTranslationUnit consistent in the face of failures to get a valid FileID (V2).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182698 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoIncrease the portability of this script a bit: use /usr/bin/env to find bash,
Richard Smith [Fri, 24 May 2013 23:54:21 +0000 (23:54 +0000)]
Increase the portability of this script a bit: use /usr/bin/env to find bash,
rather than assuming it lives in the path. Patch by Eitan Adler!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182696 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMake isBeforeInTranslationUnit consistent in the face of failures to get a valid...
Argyrios Kyrtzidis [Fri, 24 May 2013 23:47:43 +0000 (23:47 +0000)]
Make isBeforeInTranslationUnit consistent in the face of failures to get a valid FileID.

Suggested by Jordan.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182695 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoWarn on va_start() when called with a reference parameter.
Nico Weber [Fri, 24 May 2013 23:31:57 +0000 (23:31 +0000)]
Warn on va_start() when called with a reference parameter.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1905.pdf 18.7p3
explicitly calls this (and some other things) out as undefined.

Also move 2 other existing warnings behind the new -Wvarargs flag.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182694 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[libclang] Add logging for clang_createTranslationUnit.
Argyrios Kyrtzidis [Fri, 24 May 2013 22:24:07 +0000 (22:24 +0000)]
[libclang] Add logging for clang_createTranslationUnit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182682 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd some safety checks in a couple of SourceManager functions.
Argyrios Kyrtzidis [Fri, 24 May 2013 22:24:04 +0000 (22:24 +0000)]
Add some safety checks in a couple of SourceManager functions.

This is to address crash in rdar://13932308

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182681 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Fix test for r182677.
Jordan Rose [Fri, 24 May 2013 21:49:58 +0000 (21:49 +0000)]
[analyzer] Fix test for r182677.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182678 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Treat analyzer-synthesized function bodies like implicit bodies.
Jordan Rose [Fri, 24 May 2013 21:43:11 +0000 (21:43 +0000)]
[analyzer] Treat analyzer-synthesized function bodies like implicit bodies.

When generating path notes, implicit function bodies are shown at the call
site, so that, say, copying a POD type in C++ doesn't jump you to a header
file. This is especially important when the synthesized function itself
calls another function (or block), in which case we should try to jump the
user around as little as possible.

By checking whether a called function has a body in the AST, we can tell
if the analyzer synthesized the body, and if we should therefore collapse
the call down to the call site like a true implicitly-defined function.

<rdar://problem/13978414>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182677 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer; new edges] Properly set location after exiting an inlined call.
Jordan Rose [Fri, 24 May 2013 21:43:05 +0000 (21:43 +0000)]
[analyzer; new edges] Properly set location after exiting an inlined call.

The new edge algorithm would keep track of the previous location in each
location context, so that it could draw arrows coming in and out of each
inlined call. However, it tried to access the location of the call before
it was actually set (at the CallEnter node). This only affected
unterminated calls at the end of a path; calls with visible exit nodes
already had a valid location.

This patch ditches the location context map, since we're processing the
nodes in order anyway, and just unconditionally updates the PrevLoc
variable after popping out of an inlined call.

<rdar://problem/13983470>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182676 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoReplace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.
Michael J. Spencer [Fri, 24 May 2013 21:42:04 +0000 (21:42 +0000)]
Replace Count{Leading,Trailing}Zeros_{32,64} with count{Leading,Trailing}Zeros.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182675 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDebugInfo: Rename CreatePointerType to getOrCreateTypeDeclaration
David Blaikie [Fri, 24 May 2013 21:33:22 +0000 (21:33 +0000)]
DebugInfo: Rename CreatePointerType to getOrCreateTypeDeclaration

To make this more consistent with 'getOrCreateType' & clarify the
distinction between the two. The only thing I couldn't quite communicate
in the name is that getOrCreateTypeDeclaration may actually produce a
full definition (in -fno-limit-debug-info) but the point is to call it
whenever only a declaration is needed & the implementation can choose
whether to provide a declaration or definition.

(also, unfortunately, getOrCreateType can produce declarations too - we
should sure this up by making it not do that - any caller that can
tolerate a declaration should be calling getOrCreateTypeDeclaration
instead)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182674 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPR16091: Error when attempting to emit debug info for undeduced auto return types
David Blaikie [Fri, 24 May 2013 21:24:35 +0000 (21:24 +0000)]
PR16091: Error when attempting to emit debug info for undeduced auto return types

Perhaps we should just suppress this, rather than erroring, but since we
have the infrastructure for it I figured I'd use it - if this is
determined to be not the right thing we should probably remove that
infrastructure entirely. I guess it's lying around from the early days
of implementing debug info support.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182673 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[PATCH] Generate cold attribute for functions marked __atribute__((cold))
Diego Novillo [Fri, 24 May 2013 20:18:15 +0000 (20:18 +0000)]
[PATCH] Generate cold attribute for functions marked __atribute__((cold))

This removes a FIXME in CodeGenModule::SetLLVMFunctionAttributesForDefinition.
When a function is declared cold we can now generate the IR attribute in
addition to marking the function to be optimized for size.

I tried adding a separate CHECK in the existing test, but it was
failing.  I suppose CHECK matches one line exactly once?  This would be
a problem if the attributes are listed in a different order, though they
seem to be sorted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182666 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agotypo.
Adrian Prantl [Fri, 24 May 2013 18:38:08 +0000 (18:38 +0000)]
typo.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182660 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[ms-inline asm] Don't diagnose an empty lookup for inline assmebly. This happen
Chad Rosier [Fri, 24 May 2013 18:32:55 +0000 (18:32 +0000)]
[ms-inline asm] Don't diagnose an empty lookup for inline assmebly.  This happen
for labels in inline assembly that aren't in the lookup tables.  E.g.,

  __asm {
   a:
   jmp a
  }

rdar://13983623

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182659 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoIgnore contents of #if 0 blocks.
Alexander Kornienko [Fri, 24 May 2013 18:24:24 +0000 (18:24 +0000)]
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

11 years agoFix printing CXXTemporaryObjectExpr with default args.
Rafael Espindola [Fri, 24 May 2013 16:11:44 +0000 (16:11 +0000)]
Fix printing CXXTemporaryObjectExpr with default args.

Patch by Will Wilson.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182651 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSuffixing #pragma comment(lib) library names with .lib if necessary. This matches...
Aaron Ballman [Fri, 24 May 2013 15:06:56 +0000 (15:06 +0000)]
Suffixing #pragma comment(lib) library names with .lib if necessary.  This matches MSVC behavior, as well as allows us to properly link libraries such as the ones provided by the MSDN examples.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182647 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd -lrt to sanitizer link arguments.
Evgeniy Stepanov [Fri, 24 May 2013 14:28:03 +0000 (14:28 +0000)]
Add -lrt to sanitizer link arguments.

Sanitizer runtime intercepts functions from librt. Not doing this will fail
if the librt dependency is not present at program startup (ex. comes from a
dlopen()ed library).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182645 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix comment typo pointed out by maslen on IRC.
Duncan Sands [Fri, 24 May 2013 13:41:43 +0000 (13:41 +0000)]
Fix comment typo pointed out by maslen on IRC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182642 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUser correct case for 'FileCheck'.
Argyrios Kyrtzidis [Fri, 24 May 2013 05:54:31 +0000 (05:54 +0000)]
User correct case for 'FileCheck'.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182632 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[modules] If we hit a failure while loading a PCH/module, abort parsing instead of...
Argyrios Kyrtzidis [Fri, 24 May 2013 05:44:08 +0000 (05:44 +0000)]
[modules] If we hit a failure while loading a PCH/module, abort parsing instead of trying to continue in an invalid state.

Also don't let libclang create a PCH with such an error.

Fixes rdar://13953768

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182629 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUpdate static analyzer build to checker-275.
Ted Kremenek [Fri, 24 May 2013 00:50:01 +0000 (00:50 +0000)]
Update static analyzer build to checker-275.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182626 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix crash-on-invalid if list-initialization works, but we bail out when
Richard Smith [Thu, 23 May 2013 23:20:04 +0000 (23:20 +0000)]
Fix crash-on-invalid if list-initialization works, but we bail out when
building the resulting expression because it invokes a deleted constructor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182624 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoConstify the 'dump' method so that it can be called by a const object.
Bill Wendling [Thu, 23 May 2013 23:10:23 +0000 (23:10 +0000)]
Constify the 'dump' method so that it can be called by a const object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182620 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix assert on temporary std::initializer_list.
Richard Smith [Thu, 23 May 2013 21:54:14 +0000 (21:54 +0000)]
Fix assert on temporary std::initializer_list.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182615 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMore tests and a fix for braced init lists.
Daniel Jasper [Thu, 23 May 2013 21:35:49 +0000 (21:35 +0000)]
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

11 years ago[analyzer; alternate edges] Add a new test case file to regression test the new arrow...
Ted Kremenek [Thu, 23 May 2013 21:33:12 +0000 (21:33 +0000)]
[analyzer; alternate edges] Add a new test case file to regression test the new arrows algorithm.

This essentially combines the tests in plist-output.m and plist-alternate-output.m.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182612 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix aligning of comments.
Manuel Klimek [Thu, 23 May 2013 20:46:07 +0000 (20:46 +0000)]
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

11 years agoFix aligning of comments that are at the start of the line.
Manuel Klimek [Thu, 23 May 2013 19:54:43 +0000 (19:54 +0000)]
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

11 years agoAdd caveat to __builtin_readcyclecounter documentation.
Tim Northover [Thu, 23 May 2013 19:14:12 +0000 (19:14 +0000)]
Add caveat to __builtin_readcyclecounter documentation.

The ARM cycle-counter can be restricted by the operating system; it's
worth warning potential users of this issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182604 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoIncrease test coverage for braced init lists.
Daniel Jasper [Thu, 23 May 2013 18:29:16 +0000 (18:29 +0000)]
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

11 years agoImprove formatting of braced lists.
Daniel Jasper [Thu, 23 May 2013 18:05:18 +0000 (18:05 +0000)]
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

11 years agoclang-format integration for git.
Daniel Jasper [Thu, 23 May 2013 17:53:42 +0000 (17:53 +0000)]
clang-format integration for git.

Put this somewhere on your path and use:

git clang-format

Awesome work by Mark Lodato. Many thanks!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182596 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMake helper functions static.
Benjamin Kramer [Thu, 23 May 2013 15:53:44 +0000 (15:53 +0000)]
Make helper functions static.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182589 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoStop aligning trailing comments which are aligned with the next line.
Manuel Klimek [Thu, 23 May 2013 11:42:52 +0000 (11:42 +0000)]
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

11 years agoUse a SourceRange for the whitespace location in FormatToken.
Manuel Klimek [Thu, 23 May 2013 10:56:37 +0000 (10:56 +0000)]
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

11 years agoImprove formatting of braced lists.
Daniel Jasper [Thu, 23 May 2013 10:15:45 +0000 (10:15 +0000)]
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