]> granicus.if.org Git - clang/log
clang
11 years agoCGBuiltin.cpp: Fix abuse of ArrayRef in EmitOverflowIntrinsic().
NAKAMURA Takumi [Sun, 13 Jan 2013 11:26:44 +0000 (11:26 +0000)]
CGBuiltin.cpp: Fix abuse of ArrayRef in EmitOverflowIntrinsic().

In ArrayRef<T>(X), X should not be temporary value. It could be rewritten more redundantly;

  llvm::Type *XTy = X->getType();
  ArrayRef<llvm::Type *> Ty(XTy);
  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, Ty);

Since it is safe if both XTy and Ty are temporary value in one statement, it could be shorten;

  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, ArrayRef<llvm::Type*>(X->getType()));

ArrayRef<T> has an implicit constructor to create uni-entry of T;

  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());

MSVC-generated clang.exe crashed.

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

11 years agoAlways put a space after ",".
Daniel Jasper [Sun, 13 Jan 2013 08:19:51 +0000 (08:19 +0000)]
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

11 years agoDon't put spaces around hyphens in include paths.
Daniel Jasper [Sun, 13 Jan 2013 08:12:18 +0000 (08:12 +0000)]
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

11 years agoImprove identification of c-style casts.
Daniel Jasper [Sun, 13 Jan 2013 08:01:36 +0000 (08:01 +0000)]
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

11 years agoUpdated documentation to reflect new multiprecision builtin functions.
Michael Gottesman [Sun, 13 Jan 2013 04:35:31 +0000 (04:35 +0000)]
Updated documentation to reflect new multiprecision builtin functions.

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

11 years agoclang/test/CodeGen/builtins-multiprecision.c: Enhance for each test to run on theree...
NAKAMURA Takumi [Sun, 13 Jan 2013 03:55:21 +0000 (03:55 +0000)]
clang/test/CodeGen/builtins-multiprecision.c: Enhance for each test to run on theree targets, i686, amd64, win64.

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

11 years agoFixed spelling of test name: builtins-multipercision.c => builtins-multiprecision.c.
Michael Gottesman [Sun, 13 Jan 2013 03:44:31 +0000 (03:44 +0000)]
Fixed spelling of test name: builtins-multipercision.c => builtins-multiprecision.c.

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

11 years agoAdded a triple to the test builtins-multiprecision.c.
Michael Gottesman [Sun, 13 Jan 2013 03:40:23 +0000 (03:40 +0000)]
Added a triple to the test builtins-multiprecision.c.

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

11 years agoAdded builtins for multiprecision adds.
Michael Gottesman [Sun, 13 Jan 2013 02:22:39 +0000 (02:22 +0000)]
Added builtins for multiprecision adds.

We lower all of these intrinsics into a 2x chained usage of
uadd.with.overflow.

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

11 years agoRemove some duplication in the handling of __attribute__((ext_vector_size(N))).
Richard Smith [Sun, 13 Jan 2013 02:11:23 +0000 (02:11 +0000)]
Remove some duplication in the handling of __attribute__((ext_vector_size(N))).

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

11 years agoFormatter: Don't insert a space before unary operators after selector names.
Nico Weber [Sat, 12 Jan 2013 23:48:49 +0000 (23:48 +0000)]
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

11 years agoFormatter: Add a test for @selector in an ObjC method expression, which happens to...
Nico Weber [Sat, 12 Jan 2013 23:41:33 +0000 (23:41 +0000)]
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

11 years agoFormatter: Remove debugging junk I accidentally landed in r172333.
Nico Weber [Sat, 12 Jan 2013 22:51:13 +0000 (22:51 +0000)]
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

11 years agoFormatter: Prefer breaking before ObjC selector names over breaking at their ':'
Nico Weber [Sat, 12 Jan 2013 22:48:47 +0000 (22:48 +0000)]
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

11 years agoAdd a comment to test to clarify the intention here
Dmitri Gribenko [Sat, 12 Jan 2013 22:39:30 +0000 (22:39 +0000)]
Add a comment to test to clarify the intention here

Comment is taken from the commit message of r151080, by Jean-Daniel Dupas

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

11 years agoPrune an unused diagnostic, detected after improving the script in r172330
Dmitri Gribenko [Sat, 12 Jan 2013 21:58:21 +0000 (21:58 +0000)]
Prune an unused diagnostic, detected after improving the script in r172330

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

11 years agoSpeed up find-unused-diagnostics. Now runs in less than a second instead of more...
Benjamin Kramer [Sat, 12 Jan 2013 21:39:06 +0000 (21:39 +0000)]
Speed up find-unused-diagnostics. Now runs in less than a second instead of more than a minute.

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

11 years agoRemove unused diagnostics
Dmitri Gribenko [Sat, 12 Jan 2013 20:32:43 +0000 (20:32 +0000)]
Remove unused diagnostics

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

11 years agoRemove useless 'llvm::' qualifier from names like StringRef and others that are
Dmitri Gribenko [Sat, 12 Jan 2013 19:30:44 +0000 (19:30 +0000)]
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

11 years agoFix spurious output in JSONCompilationDatabase
Arnaud A. de Grandmaison [Sat, 12 Jan 2013 18:37:52 +0000 (18:37 +0000)]
Fix spurious output in JSONCompilationDatabase

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

11 years agoAdd missing includes and forward declarations so that headers don't depend on
Dmitri Gribenko [Sat, 12 Jan 2013 16:54:37 +0000 (16:54 +0000)]
Add missing includes and forward declarations so that headers don't depend on
other headers included before them.

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

11 years agocomment
Rafael Espindola [Sat, 12 Jan 2013 15:27:44 +0000 (15:27 +0000)]
comment

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

11 years agobar
Rafael Espindola [Sat, 12 Jan 2013 15:27:43 +0000 (15:27 +0000)]
bar

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

11 years agoRemove unused private field.
Rafael Espindola [Sat, 12 Jan 2013 14:22:42 +0000 (14:22 +0000)]
Remove unused private field.

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

11 years agoFix incorrect comparison operator causing loooong formatting times.
Daniel Jasper [Sat, 12 Jan 2013 07:36:22 +0000 (07:36 +0000)]
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

11 years agoFormatter: Remove an always-false condition.
Nico Weber [Sat, 12 Jan 2013 07:05:25 +0000 (07:05 +0000)]
Formatter: Remove an always-false condition.

canBreakBefore() does not allow breaking after ':' for LT_ObjCMethodDecl lines,
so if Newline is true in addTokenToState() for ':' then LT_ObjCMethodDecl
cannot be set. No functionality change.

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

11 years agoFormatter: Remove a redundant CurrentLineType check.
Nico Weber [Sat, 12 Jan 2013 07:00:16 +0000 (07:00 +0000)]
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

11 years agoDisable caching of visibility.
Rafael Espindola [Sat, 12 Jan 2013 06:42:30 +0000 (06:42 +0000)]
Disable caching of visibility.

The testcase in pr14929 shows that this is extremely hard to do. If we choose
to apply the attribute, that causes the visibility of some decls to change and
that can happen really late (during codegen).

Current gcc warns and ignores the attribute in this testcase with a warning.
This suggest that the correct solution is to find a point in the compilation
where we can compute the visibility and
* assert it was never computed before
* reject any attempts to compute it again in the future (with warnings).

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

11 years agoFormatter: Initial support for formatting Objective-C method expressions.
Nico Weber [Sat, 12 Jan 2013 06:18:40 +0000 (06:18 +0000)]
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

11 years agoFormatter: * and & are binary operators before ( and [.
Nico Weber [Sat, 12 Jan 2013 05:50:48 +0000 (05:50 +0000)]
Formatter: * and & are binary operators before ( and [.

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

11 years agoFormatter: * and & are binary operators after ) and ].
Nico Weber [Sat, 12 Jan 2013 05:47:16 +0000 (05:47 +0000)]
Formatter: * and & are binary operators after ) and ].

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

11 years agoFormatter: + and - after { are unary operators.
Nico Weber [Sat, 12 Jan 2013 05:41:23 +0000 (05:41 +0000)]
Formatter: + and - after { are unary operators.

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

11 years agoclang/unittests: Fixup corresponding to r172290.
NAKAMURA Takumi [Sat, 12 Jan 2013 02:16:29 +0000 (02:16 +0000)]
clang/unittests: Fixup corresponding to r172290.

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

11 years agoFix a regression from 171193: main cannot be overloaded.
Rafael Espindola [Sat, 12 Jan 2013 01:47:40 +0000 (01:47 +0000)]
Fix a regression from 171193: main cannot be overloaded.
Thanks Eli Friedman for noticing it.

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

11 years agoProvide Decl::getOwningModule(), which determines the (sub)module in
Douglas Gregor [Sat, 12 Jan 2013 01:29:50 +0000 (01:29 +0000)]
Provide Decl::getOwningModule(), which determines the (sub)module in
which a particular declaration resides. Use this information to
customize the "definition of 'blah' must be imported from another
module" diagnostic with the module the user actually has to
import. Additionally, recover by importing that module, so we don't
complain about other names in that module.

Still TODO: coming up with decent Fix-Its for these cases, and expand
this recovery approach for other name lookup failures.

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

11 years agoFormatter: add a test for :? in []
Nico Weber [Sat, 12 Jan 2013 01:28:06 +0000 (01:28 +0000)]
Formatter: add a test for :? in []

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

11 years agoOnly produce one -Wc++98-compat warning when initializing a reference from an init...
Richard Smith [Sat, 12 Jan 2013 01:05:20 +0000 (01:05 +0000)]
Only produce one -Wc++98-compat warning when initializing a reference from an init list with multiple elements.

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

11 years agoAdd a test from pr14898.
Rafael Espindola [Sat, 12 Jan 2013 01:01:06 +0000 (01:01 +0000)]
Add a test from pr14898.

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

11 years agoFix -Wunused-comparison for comparisons in arguments to function-like macros.
Matt Beaumont-Gay [Sat, 12 Jan 2013 00:54:16 +0000 (00:54 +0000)]
Fix -Wunused-comparison for comparisons in arguments to function-like macros.

Previously, -Wunused-comparison ignored comparisons in both macro bodies and
macro arguments, but we would still emit a -Wunused-value warning for either.
Now we correctly emit -Wunused-comparison for expressions in macro arguments.

Also, add isMacroBodyExpansion to SourceManager, to go along with
isMacroArgExpansion.

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

11 years agocomment parsing: when property accessors don't have comment
Fariborz Jahanian [Sat, 12 Jan 2013 00:28:34 +0000 (00:28 +0000)]
comment parsing: when property accessors don't have comment
of their own (or are syntheszed), use prperty's comment.
for them. // rdar://12791315

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

11 years agoRefine analyzer's handling of unary '!' and floating types to not assert.
Ted Kremenek [Fri, 11 Jan 2013 23:36:25 +0000 (23:36 +0000)]
Refine analyzer's handling of unary '!' and floating types to not assert.

Fixes PR 14634 and <rdar://problem/12903080>.

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

11 years agoFixed a bug that caused the AST importer to erroneously
Sean Callanan [Fri, 11 Jan 2013 23:17:47 +0000 (23:17 +0000)]
Fixed a bug that caused the AST importer to erroneously
import incomplete definitions for RecordDecls and then
mark the resulting definition as complete.

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

11 years agolibclang: use C++ casts in CXString.cpp
Dmitri Gribenko [Fri, 11 Jan 2013 23:13:36 +0000 (23:13 +0000)]
libclang: use C++ casts in CXString.cpp

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

11 years agolibclang: constness for CXString
Dmitri Gribenko [Fri, 11 Jan 2013 23:08:18 +0000 (23:08 +0000)]
libclang: constness for CXString

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

11 years agoCorrectly propagate uninitialized values within logical expressions.
Ted Kremenek [Fri, 11 Jan 2013 22:35:39 +0000 (22:35 +0000)]
Correctly propagate uninitialized values within logical expressions.

Fixes assertion failure reported in PR 14635 and
<rdar://problem/12902945> respectively.

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

11 years ago[PCH] Make the const_cast explicit to silence a compiler warning.
Argyrios Kyrtzidis [Fri, 11 Jan 2013 22:29:49 +0000 (22:29 +0000)]
[PCH] Make the const_cast explicit to silence a compiler warning.

Patch by David Greene.

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

11 years ago[libclang] Add some constness in CXSourceLocation and CXSourceRange.
Argyrios Kyrtzidis [Fri, 11 Jan 2013 22:29:47 +0000 (22:29 +0000)]
[libclang] Add some constness in CXSourceLocation and CXSourceRange.

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

11 years ago[libclang] In ASTUnit::getMainFileName() Invocation may be null because the ASTUnit
Argyrios Kyrtzidis [Fri, 11 Jan 2013 22:11:14 +0000 (22:11 +0000)]
[libclang] In ASTUnit::getMainFileName() Invocation may be null because the ASTUnit
came from loading a PCH/module.

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

11 years agoSet process return code of 1 in set-xcode-analyzer when Xcode needs to be quit. ...
Ted Kremenek [Fri, 11 Jan 2013 21:49:36 +0000 (21:49 +0000)]
Set process return code of 1 in set-xcode-analyzer when Xcode needs to be quit.  Fixes <rdar://problem/12983031>.

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

11 years agoFormatter: Format ObjC static and instance methods consistently, add a test for that.
Nico Weber [Fri, 11 Jan 2013 21:14:08 +0000 (21:14 +0000)]
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

11 years agolibclang: remove unneeded casts
Dmitri Gribenko [Fri, 11 Jan 2013 21:06:06 +0000 (21:06 +0000)]
libclang: remove unneeded casts

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

11 years agolibclang: change CXCursor to store 'const void *' pointers for
Dmitri Gribenko [Fri, 11 Jan 2013 21:01:49 +0000 (21:01 +0000)]
libclang: change CXCursor to store 'const void *' pointers for
const-correctness, and update all users

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

11 years agoConstify parameter of clang::getCursorKindForDecl
Dmitri Gribenko [Fri, 11 Jan 2013 20:32:41 +0000 (20:32 +0000)]
Constify parameter of clang::getCursorKindForDecl

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

11 years agoReject incompatible redeclarations of extern C symbols.
Rafael Espindola [Fri, 11 Jan 2013 19:34:23 +0000 (19:34 +0000)]
Reject incompatible redeclarations of extern C symbols.

Before we were only checking if the new declaration itself was marked extern
C. Fixes prpr14766.

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

11 years agoImprove diagnostic per Richard's suggestion
Fariborz Jahanian [Fri, 11 Jan 2013 19:33:54 +0000 (19:33 +0000)]
Improve diagnostic per Richard's suggestion
(which may yet change if we move the diagnostic
 outside case value).

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

11 years agolibclang: use getCursorTU and getCursorASTUnit instead of explicit casts
Dmitri Gribenko [Fri, 11 Jan 2013 19:28:44 +0000 (19:28 +0000)]
libclang: use getCursorTU and getCursorASTUnit instead of explicit casts

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

11 years agoFix crashes in UnwrappedLineParser on missing parens.
Manuel Klimek [Fri, 11 Jan 2013 19:23:05 +0000 (19:23 +0000)]
Fix crashes in UnwrappedLineParser on missing parens.

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

11 years agoFix single-line optimization for ObjC.
Manuel Klimek [Fri, 11 Jan 2013 19:17:44 +0000 (19:17 +0000)]
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

11 years agoFix crash on invalid.
Manuel Klimek [Fri, 11 Jan 2013 18:28:36 +0000 (18:28 +0000)]
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

11 years agoFix parsing of initializer lists with elaborated type specifier.
Manuel Klimek [Fri, 11 Jan 2013 18:13:04 +0000 (18:13 +0000)]
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

11 years agoImplements pulling simple blocks into a single line.
Manuel Klimek [Fri, 11 Jan 2013 17:54:10 +0000 (17:54 +0000)]
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

11 years agoAdd -std=c++98 to the test and minor improvment in addition.
Fariborz Jahanian [Fri, 11 Jan 2013 17:33:57 +0000 (17:33 +0000)]
Add -std=c++98 to the test and minor improvment in addition.

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

11 years agoAllow RefactoringTool to write to memory instead of always to disk
Edwin Vane [Fri, 11 Jan 2013 17:04:55 +0000 (17:04 +0000)]
Allow RefactoringTool to write to memory instead of always to disk

RefactoringTool::run() always writes the result of rewrites to disk.
Instead, make this optional and provide a method for getting the
refactoring results in a memory buffer instead.

Also made ClangTool polymorphic so RefactoringTool could inherit from it
to properly express the IS-A relationship. This change also provides
access to ClangTool's public interface, e.g. mapVirtualFile() which is
important once refactored buffers start living in memory instead of on
disk.

Reviewers: klimek

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

11 years agoCorrect spacing around new and delete.
Daniel Jasper [Fri, 11 Jan 2013 16:09:04 +0000 (16:09 +0000)]
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

11 years agoclang-format: a bit nicer error message.
Alexander Kornienko [Fri, 11 Jan 2013 16:03:45 +0000 (16:03 +0000)]
clang-format: a bit nicer error message.

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

11 years agoEnable the new (more C++-like, less broken) EH model when targeting the GNUstep
David Chisnall [Fri, 11 Jan 2013 15:33:01 +0000 (15:33 +0000)]
Enable the new (more C++-like, less broken) EH model when targeting the GNUstep
Objective-C runtime 1.7 or greater.

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

11 years agoFixed an assertion failure triggered by invalid code.
Enea Zaffanella [Fri, 11 Jan 2013 14:34:39 +0000 (14:34 +0000)]
Fixed an assertion failure triggered by invalid code.

Set invalid type of declarator after emitting error diagnostics,
so that it won't be later considered when instantiating the template.
Added test5_inst in test/SemaCXX/condition.cpp for non-regression.

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

11 years agoImprove handling of trailing declaration annotations.
Daniel Jasper [Fri, 11 Jan 2013 14:23:32 +0000 (14:23 +0000)]
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

11 years agoImproved formatting of constructor initializers
Daniel Jasper [Fri, 11 Jan 2013 11:37:55 +0000 (11:37 +0000)]
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

11 years agoTest commit.
Enea Zaffanella [Fri, 11 Jan 2013 11:37:08 +0000 (11:37 +0000)]
Test commit.

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

11 years agoRefactor IndentState into two classes.
Daniel Jasper [Fri, 11 Jan 2013 10:22:12 +0000 (10:22 +0000)]
Refactor IndentState into two classes.

As we keep adding more stuff to it, this structure is easier to
maintain. At one point we might think about making it an actual
class with specific accessors, etc.

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

11 years agoPass false instead of 0 since isStar parameter of getArray has type bool. No function...
Nikola Smiljanic [Fri, 11 Jan 2013 08:33:05 +0000 (08:33 +0000)]
Pass false instead of 0 since isStar parameter of getArray has type bool. No functionality change.

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

11 years agoFix spelling error and remove the part about CMake having experimental Ninja support...
Nikola Smiljanic [Fri, 11 Jan 2013 07:23:53 +0000 (07:23 +0000)]
Fix spelling error and remove the part about CMake having experimental Ninja support since 2.8.9 has been released some time ago.

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

11 years agoRevert the line ending mess I made.
Nikola Smiljanic [Fri, 11 Jan 2013 07:14:58 +0000 (07:14 +0000)]
Revert the line ending mess I made.

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

11 years agoFix spelling error and remove the part about CMake having experimental Ninja support...
Nikola Smiljanic [Fri, 11 Jan 2013 07:09:00 +0000 (07:09 +0000)]
Fix spelling error and remove the part about CMake having experimental Ninja support since 2.8.9 has been released some time ago.

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

11 years ago[analyzer] Rename the warning: state the issue before the hint of how it
Anna Zaks [Fri, 11 Jan 2013 03:52:44 +0000 (03:52 +0000)]
[analyzer] Rename the warning: state the issue before the hint of how it
can be fixed

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

11 years ago[analyzer]Recognize ivar invalidation protocol even if it was redeclared
Anna Zaks [Fri, 11 Jan 2013 03:52:40 +0000 (03:52 +0000)]
[analyzer]Recognize ivar invalidation protocol even if it was redeclared

This will get rid of some false positives as well as false negatives.

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

11 years ago[analyzer] Ivar invalidation: track ivars declared in categories.
Anna Zaks [Fri, 11 Jan 2013 03:52:37 +0000 (03:52 +0000)]
[analyzer] Ivar invalidation: track ivars declared in categories.

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

11 years agoRevert "tg-fixits.td: fixup for Linux"
Jordan Rose [Fri, 11 Jan 2013 02:37:47 +0000 (02:37 +0000)]
Revert "tg-fixits.td: fixup for Linux"

It's better to show no caret/ranges/fixits than to show them misaligned.
(It scares me a bit that Clang is going to show them misaligned on
systems without a proper llvm::sys::locale::columnWidth.) See PR14910.

This reverts commit a03cc72bedd015b7eb76e9ac650992f58a48549d.

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

11 years agoReplace more usages of __func__ with LLVM_FUNCTION_NAME
Dmitri Gribenko [Fri, 11 Jan 2013 02:23:13 +0000 (02:23 +0000)]
Replace more usages of __func__ with LLVM_FUNCTION_NAME

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

11 years agolibclang logging: fixup for MSVC, which does not have __func__
Dmitri Gribenko [Fri, 11 Jan 2013 01:15:02 +0000 (01:15 +0000)]
libclang logging: fixup for MSVC, which does not have __func__

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

11 years agoImprove on my last test for patch for // rdar://12897704
Fariborz Jahanian [Fri, 11 Jan 2013 00:55:44 +0000 (00:55 +0000)]
Improve on my last test for patch for // rdar://12897704

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

11 years agotg-fixits.td: fixup for Linux, which does not have a correct implementation of
Dmitri Gribenko [Fri, 11 Jan 2013 00:37:33 +0000 (00:37 +0000)]
tg-fixits.td: fixup for Linux, which does not have a correct implementation of
llvm::sys::locale::columnWidth()

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

11 years agoTruth in advertising: LocallyScopedExternalDecls actually only contains
Richard Smith [Thu, 10 Jan 2013 23:43:47 +0000 (23:43 +0000)]
Truth in advertising: LocallyScopedExternalDecls actually only contains
external declarations with C language linkage.

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

11 years ago[analyzer] Allow IvarInvalidation checker to suppress warnings via
Anna Zaks [Thu, 10 Jan 2013 23:34:16 +0000 (23:34 +0000)]
[analyzer] Allow IvarInvalidation checker to suppress warnings via
assertions.

To ensure that custom assertions/conditional would also be supported,
just check if the ivar that needs to be invalidated or set to nil is
compared against 0.

Unfortunately, this will not work for code containing 'assert(IvarName)'

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

11 years agoc++ IRGen. In trivial cases that object is going into static
Fariborz Jahanian [Thu, 10 Jan 2013 23:28:43 +0000 (23:28 +0000)]
c++ IRGen. In trivial cases that object is going into static
storage and thus is implicitly zero-initialized, no need to
do C++11 memory model. This patch unconditionally detects
such condition and zeroinitializer's the variable.
Patch has been commented on and OKed by Doug off-line.
// rdar://12897704

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

11 years agoFormatter: Remove a fixme, Jordy says @synthesize is good as is.
Nico Weber [Thu, 10 Jan 2013 23:12:29 +0000 (23:12 +0000)]
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

11 years agoFormatter: Put spaces in ObjC method decls in the right place for Google style.
Nico Weber [Thu, 10 Jan 2013 23:11:41 +0000 (23:11 +0000)]
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

11 years ago[analyzer] Fix non-determinizm introduced in r172104.
Anna Zaks [Thu, 10 Jan 2013 22:44:16 +0000 (22:44 +0000)]
[analyzer] Fix non-determinizm introduced in r172104.

In some cases, we just pick any ivar that needs invalidation and attach
the warning to it. Picking the first from DenseMap of pointer keys was
triggering non-deterministic output.

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

11 years agoToolChains: Minor touchup to use correct type, avoid truncation.
Will Dietz [Thu, 10 Jan 2013 22:20:02 +0000 (22:20 +0000)]
ToolChains: Minor touchup to use correct type, avoid truncation.

Truncation happens regularly when find_first_not_of returns npos,
strings long enough to trigger bug here are implausible.

No functionality change intended (ignoring absurd string lengths).

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

11 years agoDeclare +new instead of -new in test.
Fariborz Jahanian [Thu, 10 Jan 2013 22:17:49 +0000 (22:17 +0000)]
Declare +new instead of -new in test.

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

11 years ago[ms-inline asm] Add test case for r172121.
Chad Rosier [Thu, 10 Jan 2013 22:11:28 +0000 (22:11 +0000)]
[ms-inline asm] Add test case for r172121.
Part of rdar://12991541

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

11 years ago[ms-inline asm] Extend the inline asm Sema lookup interface to determine if the
Chad Rosier [Thu, 10 Jan 2013 22:10:16 +0000 (22:10 +0000)]
[ms-inline asm] Extend the inline asm Sema lookup interface to determine if the
Decl is a VarDecl.
Part of rdar://12991541

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

11 years agoFormatter: No spaces around '=' in @property lines.
Nico Weber [Thu, 10 Jan 2013 21:30:42 +0000 (21:30 +0000)]
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

11 years ago[analyzer] Add more checks to the ObjC Ivar Invalidation checker.
Anna Zaks [Thu, 10 Jan 2013 20:59:51 +0000 (20:59 +0000)]
[analyzer] Add more checks to the ObjC Ivar Invalidation checker.

Restructured the checker so that it could easily find two new classes of
issues:
 - when a class contains an invalidatable ivar, but no declaration of an
invalidation method
 - when a class contains an invalidatable ivar, but no definition of an
invalidation method in the @implementation.

The second case might trigger some false positives, for example, when
the method is defined in a category.

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

11 years agoIn my last patch use InGroup<Switch> (per Dmitri's comment).
Fariborz Jahanian [Thu, 10 Jan 2013 20:47:57 +0000 (20:47 +0000)]
In my last patch use InGroup<Switch> (per Dmitri's comment).

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

11 years agoProvide a better warning when case value overflows.
Fariborz Jahanian [Thu, 10 Jan 2013 20:26:42 +0000 (20:26 +0000)]
Provide a better warning when case value overflows.
// rdar://11577384

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

11 years agoFormatter: Land header change I forgot to land in r172099.
Nico Weber [Thu, 10 Jan 2013 20:19:27 +0000 (20:19 +0000)]
Formatter: Land header change I forgot to land in r172099.

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

11 years agoFormatter: Add test for template and protocol parameters in ObjC method declarations.
Nico Weber [Thu, 10 Jan 2013 20:18:33 +0000 (20:18 +0000)]
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

11 years agoFormatting: In @implementation etc lines, put a space before protocol lists.
Nico Weber [Thu, 10 Jan 2013 20:12:55 +0000 (20:12 +0000)]
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