]> granicus.if.org Git - clang/log
clang
11 years agoCollect both normal and static data members of a class in source
Eric Christopher [Wed, 16 Jan 2013 01:22:32 +0000 (01:22 +0000)]
Collect both normal and static data members of a class in source
order. Describe static data members to metadata using new interfaces.

Part of PR14471.

Patch by Paul Robinson!

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

11 years agoDocumentation: fix typo
Dmitri Gribenko [Wed, 16 Jan 2013 01:17:05 +0000 (01:17 +0000)]
Documentation: fix typo

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

11 years agoDocument the redeclaration and overriding restrictions on the
Douglas Gregor [Wed, 16 Jan 2013 01:12:31 +0000 (01:12 +0000)]
Document the redeclaration and overriding restrictions on the
availability attribute.

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

11 years agoOne can have an unavailable method overridden by an available method,
Douglas Gregor [Wed, 16 Jan 2013 00:54:48 +0000 (00:54 +0000)]
One can have an unavailable method overridden by an available method,
but not vice-versa. Fix bug introduced in r172567 and noticed by
Jordan, thanks!

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

11 years agoApply adjustment to function- and array-typed non-type template
Douglas Gregor [Wed, 16 Jan 2013 00:52:15 +0000 (00:52 +0000)]
Apply adjustment to function- and array-typed non-type template
parameters (per C++ [temp.param]p8) when computing the type of a
reference to a non-type template parameter. Fixes <rdar://problem/13000548>.

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

11 years agoFix signed/unsigned Compare
David Greene [Tue, 15 Jan 2013 23:13:49 +0000 (23:13 +0000)]
Fix signed/unsigned Compare

Do some casting to avoid a signed/unsigned compare.

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

11 years agoAvoid unsigned Compare to int
David Greene [Tue, 15 Jan 2013 23:13:47 +0000 (23:13 +0000)]
Avoid unsigned Compare to int

Cast arithmetic results to avoid comparison of an unsigned to an int.

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

11 years agoWhen checking availability attributes for consistency between an
Douglas Gregor [Tue, 15 Jan 2013 22:43:08 +0000 (22:43 +0000)]
When checking availability attributes for consistency between an
overriding and overridden method, allow the overridden method to have
a narrower contract (introduced earlier, deprecated/obsoleted later)
than the overriding method. Fixes <rdar://problem/12992023>.

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

11 years agoFix Casting
David Greene [Tue, 15 Jan 2013 22:09:51 +0000 (22:09 +0000)]
Fix Casting

Use const_cast<> to avoid a cast-away-const error.

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

11 years agoFix Casting
David Greene [Tue, 15 Jan 2013 22:09:49 +0000 (22:09 +0000)]
Fix Casting

Use const_cast<> to avoid a cast-away-const error.

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

11 years agoFix Casting
David Greene [Tue, 15 Jan 2013 22:09:48 +0000 (22:09 +0000)]
Fix Casting

Use const_cast<> to avoid a cast-away-const error.

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

11 years agoFix Casting
David Greene [Tue, 15 Jan 2013 22:09:46 +0000 (22:09 +0000)]
Fix Casting

Use const_cast<> to avoid a cast-away-const error.

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

11 years agoFix Cast
David Greene [Tue, 15 Jan 2013 22:09:45 +0000 (22:09 +0000)]
Fix Cast

Properly use const_cast to fix a cast-away-const error.

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

11 years agoFix Casting
David Greene [Tue, 15 Jan 2013 22:09:43 +0000 (22:09 +0000)]
Fix Casting

Make the const_cast explicit to silence a compiler warning.

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

11 years agoFix Const Cast
David Greene [Tue, 15 Jan 2013 22:09:41 +0000 (22:09 +0000)]
Fix Const Cast

Do proper casting to avoid a cast-away-const error.

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

11 years agoFix Cast
David Greene [Tue, 15 Jan 2013 22:09:40 +0000 (22:09 +0000)]
Fix Cast

Avoid a cast-away-const error by properly using const_cast<>.

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

11 years agoFix Cast Code
David Greene [Tue, 15 Jan 2013 22:09:39 +0000 (22:09 +0000)]
Fix Cast Code

Eliminate a cast and resulting cast-qual warning by using a temporary
as the target of memcpy.

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

11 years agoTypo correction; no functional change.
Aaron Ballman [Tue, 15 Jan 2013 21:59:46 +0000 (21:59 +0000)]
Typo correction; no functional change.

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

11 years ago[driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /".
Daniel Dunbar [Tue, 15 Jan 2013 20:33:56 +0000 (20:33 +0000)]
[driver/Darwin] Adjust SDKROOT handling code to not generate "-isysroot /".

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

11 years agoAdd a test for -Wsemicolon-before-method-body fixit
Dmitri Gribenko [Tue, 15 Jan 2013 18:29:04 +0000 (18:29 +0000)]
Add a test for -Wsemicolon-before-method-body fixit

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

11 years agoDo not traverse the break-state when we know we cannot break anyway.
Manuel Klimek [Tue, 15 Jan 2013 16:41:02 +0000 (16:41 +0000)]
Do not traverse the break-state when we know we cannot break anyway.

This is an optimization that djasper spottet. For now, we do not format
anything after the first token that belongs to such an implicit string
literal. All our state is not made for handling that anyway, so we'll
revisit this if we find a problem.

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

11 years agoFix formatting of preprocessor directives (incluces, warnings & errors).
Manuel Klimek [Tue, 15 Jan 2013 15:50:27 +0000 (15:50 +0000)]
Fix formatting of preprocessor directives (incluces, warnings & errors).

Treat tokens inside <> for includes and everything from the second token
of a warning / error on as an implicit string literal, e.g. do not
change its whitespace at all.

Now correctly formats:
 #include < path with space >
 #error Leave     all         white!!!!! space* alone!

Note that for #error and #warning we still format the space up to the
first token of the text, so:
   #  error   Text
will become
 #error Text

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

11 years agoImprove operator kind detection in presence of comments.
Daniel Jasper [Tue, 15 Jan 2013 14:27:39 +0000 (14:27 +0000)]
Improve operator kind detection in presence of comments.

We used to incorrectly identify some operators (*, &, +, -, etc.) if
there were comments around them.

Example:
Before: int a = /**/ - 1;
After:  int a = /**/ -1;

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

11 years agoFixes various bugs around the keywords class, struct and union.
Manuel Klimek [Tue, 15 Jan 2013 13:38:33 +0000 (13:38 +0000)]
Fixes various bugs around the keywords class, struct and union.

This switches to parsing record definitions only if we can clearly
identify them. We're specifically allowing common patterns for
visibility control through macros and attributes, but we cannot
currently fix all instances. This fixes all known bugs we have though.

Before:
static class A f() {
  return g();
} int x;

After:
static class A f() {
  return g();
}
int x;

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

11 years agoResolved merge error with r172323 (llvm::X -> X)
Alexander Kornienko [Tue, 15 Jan 2013 12:20:21 +0000 (12:20 +0000)]
Resolved merge error with r172323 (llvm::X -> X)

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

11 years agoDon't crash when binding a reference to a temporary pointer created from
Richard Smith [Tue, 15 Jan 2013 07:58:29 +0000 (07:58 +0000)]
Don't crash when binding a reference to a temporary pointer created from
resolving an overloaded function reference within an initializer list.
Previously we would try to resolve the overloaded function reference without
first stripping off the InitListExpr wrapper.

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

11 years agoPR14950: Fix out-of-bounds function parameter access in literal operator lookup.
Richard Smith [Tue, 15 Jan 2013 07:12:59 +0000 (07:12 +0000)]
PR14950: Fix out-of-bounds function parameter access in literal operator lookup.

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

11 years agoPR14918: Don't confuse braced-init-lists after template variable declarations
Richard Smith [Tue, 15 Jan 2013 06:49:38 +0000 (06:49 +0000)]
PR14918: Don't confuse braced-init-lists after template variable declarations
with function definitions.

We really should remove Parser::isDeclarationAfterDeclarator entirely, since
it's meaningless in C++11 (an open brace could be either a function definition
or an initializer, which is what it's trying to differentiate between). The
other caller of it happens to be correct right now...

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

11 years agoAdd -fopenmp -cc1 option and wire it up to define _OPENMP, from Alexey Bataev!
Douglas Gregor [Tue, 15 Jan 2013 06:45:29 +0000 (06:45 +0000)]
Add -fopenmp -cc1 option and wire it up to define _OPENMP, from Alexey Bataev!

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

11 years agoFix behavior of [[gnu::]] function attributes. Per g++'s behavior, these
Richard Smith [Tue, 15 Jan 2013 02:48:13 +0000 (02:48 +0000)]
Fix behavior of [[gnu::]] function attributes. Per g++'s behavior, these
attributes appertain to a declaration, even though they would be much more
naturally modelled as appertaining to a function type. Previously, we would
try to distribute them from the declarator to the function type, then
reject them for being at an incorrect location. Now, we just distribute them
as far as the declarator; the existing attribute handling code can actually
apply them there just fine.

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

11 years ago[driver] Warnings for warning options are handled by the frontend. The driver needs...
Chad Rosier [Tue, 15 Jan 2013 01:21:53 +0000 (01:21 +0000)]
[driver] Warnings for warning options are handled by the frontend.  The driver needs to process the
warning options to setup diagnostic state, but should not be emitting warnings as these would be
rudndant with what the frontend emits.
rdar://13001556

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

11 years agoDocument that we should recognize attributes supported by gcc with C++11
Dmitri Gribenko [Mon, 14 Jan 2013 22:44:07 +0000 (22:44 +0000)]
Document that we should recognize attributes supported by gcc with C++11
[[gnu::...]] syntax

Pointed out by Richard Smith on the mailing list.

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

11 years agoRefactor to call ActOnFinishFullExpr on every full expression. Teach
Richard Smith [Mon, 14 Jan 2013 22:39:08 +0000 (22:39 +0000)]
Refactor to call ActOnFinishFullExpr on every full expression. Teach
ActOnFinishFullExpr that some of its checks only apply to discarded-value
expressions. This adds missing checks for unexpanded variadic template
parameter packs to a handful of constructs.

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

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