]> granicus.if.org Git - clang/log
clang
11 years agoMultiprecision subtraction builtins.
Michael Gottesman [Mon, 14 Jan 2013 21:44:30 +0000 (21:44 +0000)]
Multiprecision subtraction builtins.

We lower these into 2x chained usub.with.overflow intrinsics.

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

11 years agoTopologically sort the link options generated for modules based on
Douglas Gregor [Mon, 14 Jan 2013 20:53:57 +0000 (20:53 +0000)]
Topologically sort the link options generated for modules based on
module-import dependencies, so we'll get the link order correct for
those silly linkers that need it.

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

11 years agoWhen forming the link options for an imported module, also include the
Douglas Gregor [Mon, 14 Jan 2013 19:00:05 +0000 (19:00 +0000)]
When forming the link options for an imported module, also include the
link options for the modules it imports.

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

11 years ago[analyzer] Add ProgramStatePartialTrait<const void *>.
Jordan Rose [Mon, 14 Jan 2013 18:58:42 +0000 (18:58 +0000)]
[analyzer] Add ProgramStatePartialTrait<const void *>.

This should fix cast-away-const warnings reported by David Greene.

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

11 years ago[analyzer] Fix cast-away-const warning by using const_cast.
Jordan Rose [Mon, 14 Jan 2013 18:58:38 +0000 (18:58 +0000)]
[analyzer] Fix cast-away-const warning by using const_cast.

Patch by David Greene, modified by me.

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

11 years ago[analyzer] -drain is not an alias for -release.
Jordan Rose [Mon, 14 Jan 2013 18:58:33 +0000 (18:58 +0000)]
[analyzer] -drain is not an alias for -release.

This was previously added to support -[NSAutoreleasePool drain], which
behaves like -release under non-GC and "please collect" under GC. We're
not currently modeling the autorelease pool stack, though, so we can
just take this out entirely.

Fixes PR14927.

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

11 years agoSwitch autolinking metadata format over to actual linker options, e.g.,
Douglas Gregor [Mon, 14 Jan 2013 18:28:43 +0000 (18:28 +0000)]
Switch autolinking metadata format over to actual linker options, e.g.,

  !0 = metadata !{metadata !"-lautolink"}
  !1 = metadata !{metadata !"-framework", metadata !"autolink_framework"}

referenced from llvm.module.linkoptions, e.g.,

  !llvm.module.linkoptions = !{!0, !1, !2, !3}

This conceptually moves the logic for figuring out the syntax the
linker will accept from LLVM into Clang. Moreover, it makes it easier
to support MSVC's

  #pragma comment(linker, "some option")

in the future, should anyone care to do so.

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

11 years agoInfer "link" lines for top-level frameworks. Essentially, a framework
Douglas Gregor [Mon, 14 Jan 2013 17:57:51 +0000 (17:57 +0000)]
Infer "link" lines for top-level frameworks. Essentially, a framework
will have a shared library with the same name as its framework (and no
suffix!) within its .framework directory. Detect this both when
inferring the whole top-level framework and when parsing a module map.

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

11 years agoThis patch addresses varargs processing for small complex types under
Bill Schmidt [Mon, 14 Jan 2013 17:45:36 +0000 (17:45 +0000)]
This patch addresses varargs processing for small complex types under
the 64-bit PowerPC ELF ABI.

The ABI requires that the real and imaginary parts of a complex argument
each occupy their own doubleword.  Arguments smaller than 8 bytes are
right-adjusted within the doubleword.

Clang expects EmitVAARG() to return a pointer to a structure in which
the real and imaginary parts are packed adjacently in memory.  To accomplish
this, we generate code to load the code appropriately from the varargs
location and pack the values into a temporary variable in the form Clang
expects, returning a pointer to that structure.

The test case demonstrates correct code generation for all "small" complex
types on PPC64:  int, short, char, and float.

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

11 years agoImplement parsing, AST, (de-)serialization, and placeholder global
Douglas Gregor [Mon, 14 Jan 2013 17:21:00 +0000 (17:21 +0000)]
Implement parsing, AST, (de-)serialization, and placeholder global
metadata for linking against the libraries/frameworks for imported
modules.

The module map language is extended with a new "link" directive that
specifies what library or framework to link against when a module is
imported, e.g.,

  link "clangAST"

or

  link framework "MyFramework"

Importing the corresponding module (or any of its submodules) will
eventually link against the named library/framework.

For now, I've added some placeholder global metadata that encodes the
imported libraries/frameworks, so that we can test that this
information gets through to the IR. The format of the data is still
under discussion.

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

11 years agoFixes formatting of nested brace initializers.
Manuel Klimek [Mon, 14 Jan 2013 16:41:43 +0000 (16:41 +0000)]
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

11 years agoMake single-line if statements optional.
Daniel Jasper [Mon, 14 Jan 2013 16:24:39 +0000 (16:24 +0000)]
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

11 years agoFix a bug in the line merging.
Daniel Jasper [Mon, 14 Jan 2013 16:02:06 +0000 (16:02 +0000)]
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

11 years agoFix bug that would lead to joining preprocessor directives.
Daniel Jasper [Mon, 14 Jan 2013 15:52:06 +0000 (15:52 +0000)]
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

11 years agoPut simple preprocessor directives on a single line.
Daniel Jasper [Mon, 14 Jan 2013 15:40:57 +0000 (15:40 +0000)]
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

11 years agoTurns out there is a simpler way of getting a set difference in bash than parsing...
Benjamin Kramer [Mon, 14 Jan 2013 15:00:48 +0000 (15:00 +0000)]
Turns out there is a simpler way of getting a set difference in bash than parsing diff output.

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

11 years agoPut short if statements on a single line.
Daniel Jasper [Mon, 14 Jan 2013 14:14:23 +0000 (14:14 +0000)]
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

11 years agoDump comments in -ast-dump.
Alexander Kornienko [Mon, 14 Jan 2013 14:07:11 +0000 (14:07 +0000)]
Dump comments in -ast-dump.
http://llvm-reviews.chandlerc.com/D269

"Added dumping of declaration comments in ASTDumper. This required moving the
comment dumping code from CommentDumper so that the indentation is correct."

Patch by Philip Craig!

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

11 years agoclang/test/SemaCXX/cxx11-gnu-attrs.cpp: Add explicit -triple x86_64-unknown-unknown...
NAKAMURA Takumi [Mon, 14 Jan 2013 13:16:02 +0000 (13:16 +0000)]
clang/test/SemaCXX/cxx11-gnu-attrs.cpp: Add explicit -triple x86_64-unknown-unknown, or it doesn't work for targetting win32.

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

11 years agoRefactor datastructure used in clang-format.
Daniel Jasper [Mon, 14 Jan 2013 13:08:07 +0000 (13:08 +0000)]
Refactor datastructure used in clang-format.

Main difference, add an AnnotatedLine class to hold information about a
line while formatting. At the same time degrade the UnwrappedLine class
to a class solely used for communicating between the UnwrappedLineParser
and the Formatter.

No functional changes intended.

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

11 years agoImprove understanding post increment and decrement.
Daniel Jasper [Mon, 14 Jan 2013 12:18:19 +0000 (12:18 +0000)]
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

11 years agoCustom DiagnosticConsumer parameter of reformat() + silence diagnostics in unit tests.
Alexander Kornienko [Mon, 14 Jan 2013 11:34:14 +0000 (11:34 +0000)]
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

11 years agoAdds some more tests for * and &.
Manuel Klimek [Mon, 14 Jan 2013 10:58:01 +0000 (10:58 +0000)]
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

11 years agoAdd extra tests for [[gnu::...]] attributes, missed from r172382.
Richard Smith [Mon, 14 Jan 2013 08:57:42 +0000 (08:57 +0000)]
Add extra tests for [[gnu::...]] attributes, missed from r172382.

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

11 years agoFix regression in r172376. Don't try to detect missing 'constexpr' specifiers
Richard Smith [Mon, 14 Jan 2013 08:00:39 +0000 (08:00 +0000)]
Fix regression in r172376. Don't try to detect missing 'constexpr' specifiers
on redeclarations, since that makes us pick wrong prior declarations under
some circumstances.

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

11 years agoAccept [[gnu::*]] for all __attribute__((*))s which are:
Richard Smith [Mon, 14 Jan 2013 07:53:01 +0000 (07:53 +0000)]
Accept [[gnu::*]] for all __attribute__((*))s which are:
 1) Supported by Clang, and
 2) Supported by GCC, and
 3) Documented in GCC's manual.

g++ allows its C++11-style attributes to appertain only to the entity being
declared, and never to a type (even for a type attribute), so we do the same.

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

11 years agoFormatter: Add a test for bitfields.
Nico Weber [Mon, 14 Jan 2013 05:49:49 +0000 (05:49 +0000)]
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

11 years agoPR12008: defer adding the implicit 'const' to a constexpr member function until
Richard Smith [Mon, 14 Jan 2013 05:37:29 +0000 (05:37 +0000)]
PR12008: defer adding the implicit 'const' to a constexpr member function until
we know whether it is static.

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

11 years ago*this is const in a trailing-return-type for a constexpr member function.
Richard Smith [Mon, 14 Jan 2013 01:55:13 +0000 (01:55 +0000)]
*this is const in a trailing-return-type for a constexpr member function.

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

11 years agolibclang: remove a few const_casts
Dmitri Gribenko [Mon, 14 Jan 2013 00:46:27 +0000 (00:46 +0000)]
libclang: remove a few const_casts

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

11 years agoConstify argument of Preprocessor::getMacroInfoHistory and propagate to
Dmitri Gribenko [Mon, 14 Jan 2013 00:36:42 +0000 (00:36 +0000)]
Constify argument of Preprocessor::getMacroInfoHistory and propagate to
callers, removing unneeded const_cast

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

11 years agoRemove an unneeded const_cast
Dmitri Gribenko [Mon, 14 Jan 2013 00:25:25 +0000 (00:25 +0000)]
Remove an unneeded const_cast

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

11 years agoArrayRef'ize Sema APIs related to format string checking
Dmitri Gribenko [Sun, 13 Jan 2013 20:46:02 +0000 (20:46 +0000)]
ArrayRef'ize Sema APIs related to format string checking

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

11 years agoDocument behavior of -Wformat-nonliteral, it is different from GCC
Dmitri Gribenko [Sun, 13 Jan 2013 16:37:18 +0000 (16:37 +0000)]
Document behavior of -Wformat-nonliteral, it is different from GCC

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

11 years agoStronger respect the input codes line breaks wrt. comments.
Daniel Jasper [Sun, 13 Jan 2013 16:10:20 +0000 (16:10 +0000)]
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

11 years agoFix LLP64 build.
Michael J. Spencer [Sun, 13 Jan 2013 16:00:51 +0000 (16:00 +0000)]
Fix LLP64 build.

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

11 years agoFormat unions like structs and classes.
Daniel Jasper [Sun, 13 Jan 2013 14:39:04 +0000 (14:39 +0000)]
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

11 years agoRefactor the x86 CPU name logic in the driver and pass -march and -mcpu
Chandler Carruth [Sun, 13 Jan 2013 11:46:33 +0000 (11:46 +0000)]
Refactor the x86 CPU name logic in the driver and pass -march and -mcpu
flag information down from the Clang driver into the Gold linker plugin
for LTO. This allows specifying -march on the linker commandline and
should hopefully have it pass all the way through to the LTO optimizer.

Fixes PR14697.

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

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