Commit Graph

42880 Commits

Author SHA1 Message Date
Daniel Jasper f1e4b7d750 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.

llvm-svn: 172403
2013-01-14 13:08:07 +00:00
Daniel Jasper 13f23e17c7 Improve understanding post increment and decrement.
Before: (a->f()) ++;
        a[42] ++;
After:  (a->f())++;
        a[42]++;
llvm-svn: 172400
2013-01-14 12:18:19 +00:00
Alexander Kornienko 116ba68220 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

llvm-svn: 172399
2013-01-14 11:34:14 +00:00
Manuel Klimek 557811fe6c 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.

llvm-svn: 172396
2013-01-14 10:58:01 +00:00
Richard Smith b5b5320bff Add extra tests for [[gnu::...]] attributes, missed from r172382.
llvm-svn: 172391
2013-01-14 08:57:42 +00:00
Richard Smith 59b8e701d3 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.

llvm-svn: 172384
2013-01-14 08:00:39 +00:00
Richard Smith 368ca52cd9 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.

llvm-svn: 172382
2013-01-14 07:53:01 +00:00
Nico Weber 7769a9044e 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.

llvm-svn: 172377
2013-01-14 05:49:49 +00:00
Richard Smith 574f4f6a1d PR12008: defer adding the implicit 'const' to a constexpr member function until
we know whether it is static.

llvm-svn: 172376
2013-01-14 05:37:29 +00:00
Richard Smith 01141a95a5 *this is const in a trailing-return-type for a constexpr member function.
llvm-svn: 172375
2013-01-14 01:55:13 +00:00
Dmitri Gribenko 9c256e379e libclang: remove a few const_casts
llvm-svn: 172373
2013-01-14 00:46:27 +00:00
Dmitri Gribenko 049a4ffcb8 Constify argument of Preprocessor::getMacroInfoHistory and propagate to
callers, removing unneeded const_cast

llvm-svn: 172372
2013-01-14 00:36:42 +00:00
Dmitri Gribenko aaf7f2978c Remove an unneeded const_cast
llvm-svn: 172370
2013-01-14 00:25:25 +00:00
Dmitri Gribenko 765396f2f0 ArrayRef'ize Sema APIs related to format string checking
llvm-svn: 172367
2013-01-13 20:46:02 +00:00
Dmitri Gribenko dc81f51d37 Document behavior of -Wformat-nonliteral, it is different from GCC
llvm-svn: 172362
2013-01-13 16:37:18 +00:00
Daniel Jasper 942ee72aff 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>

llvm-svn: 172361
2013-01-13 16:10:20 +00:00
Michael J. Spencer 7d1b7c4c38 Fix LLP64 build.
llvm-svn: 172357
2013-01-13 16:00:51 +00:00
Daniel Jasper 22cf462234 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;
llvm-svn: 172355
2013-01-13 14:39:04 +00:00
Chandler Carruth 953fb087e5 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.

llvm-svn: 172354
2013-01-13 11:46:33 +00:00
NAKAMURA Takumi 7ab4fbf5c2 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.

llvm-svn: 172352
2013-01-13 11:26:44 +00:00
Daniel Jasper 48cb3b97c7 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));
llvm-svn: 172351
2013-01-13 08:19:51 +00:00
Daniel Jasper 5ef433fc0c Don't put spaces around hyphens in include paths.
Before: #include <a - a>
After:  #include <a-a>
llvm-svn: 172350
2013-01-13 08:12:18 +00:00
Daniel Jasper ef906a9c67 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 *) {}
llvm-svn: 172349
2013-01-13 08:01:36 +00:00
Michael Gottesman c5cc9f154d Updated documentation to reflect new multiprecision builtin functions.
llvm-svn: 172345
2013-01-13 04:35:31 +00:00
NAKAMURA Takumi 4b7d1ce9c1 clang/test/CodeGen/builtins-multiprecision.c: Enhance for each test to run on theree targets, i686, amd64, win64.
llvm-svn: 172344
2013-01-13 03:55:21 +00:00
Michael Gottesman 987226696e Fixed spelling of test name: builtins-multipercision.c => builtins-multiprecision.c.
llvm-svn: 172343
2013-01-13 03:44:31 +00:00
Michael Gottesman 0cd8b78916 Added a triple to the test builtins-multiprecision.c.
llvm-svn: 172342
2013-01-13 03:40:23 +00:00
Michael Gottesman 54398015bf Added builtins for multiprecision adds.
We lower all of these intrinsics into a 2x chained usage of
uadd.with.overflow.

llvm-svn: 172341
2013-01-13 02:22:39 +00:00
Richard Smith 1f5a4323e9 Remove some duplication in the handling of __attribute__((ext_vector_size(N))).
llvm-svn: 172340
2013-01-13 02:11:23 +00:00
Nico Weber 2827a7ec6b 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];

llvm-svn: 172337
2013-01-12 23:48:49 +00:00
Nico Weber 5c8709bc5e Formatter: Add a test for @selector in an ObjC method expression, which happens to work already.
llvm-svn: 172335
2013-01-12 23:41:33 +00:00
Nico Weber 92c0539135 Formatter: Remove debugging junk I accidentally landed in r172333.
llvm-svn: 172334
2013-01-12 22:51:13 +00:00
Nico Weber c9d7361173 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])) {

llvm-svn: 172333
2013-01-12 22:48:47 +00:00
Dmitri Gribenko 813985b073 Add a comment to test to clarify the intention here
Comment is taken from the commit message of r151080, by Jean-Daniel Dupas

llvm-svn: 172332
2013-01-12 22:39:30 +00:00
Dmitri Gribenko 4b84153da2 Prune an unused diagnostic, detected after improving the script in r172330
llvm-svn: 172331
2013-01-12 21:58:21 +00:00
Benjamin Kramer 6590abb384 Speed up find-unused-diagnostics. Now runs in less than a second instead of more than a minute.
llvm-svn: 172330
2013-01-12 21:39:06 +00:00
Dmitri Gribenko e392a9f2b0 Remove unused diagnostics
llvm-svn: 172326
2013-01-12 20:32:43 +00:00
Dmitri Gribenko f857950d39 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h

llvm-svn: 172323
2013-01-12 19:30:44 +00:00
Arnaud A. de Grandmaison 3128a11ee8 Fix spurious output in JSONCompilationDatabase
llvm-svn: 172321
2013-01-12 18:37:52 +00:00
Dmitri Gribenko 1737bd3a92 Add missing includes and forward declarations so that headers don't depend on
other headers included before them.

llvm-svn: 172320
2013-01-12 16:54:37 +00:00
Rafael Espindola 6239e05adc comment
llvm-svn: 172317
2013-01-12 15:27:44 +00:00
Rafael Espindola c48f7341cc bar
llvm-svn: 172316
2013-01-12 15:27:43 +00:00
Rafael Espindola 8f1187a11b Remove unused private field.
llvm-svn: 172314
2013-01-12 14:22:42 +00:00
Daniel Jasper 7b7877ad7d Fix incorrect comparison operator causing loooong formatting times.
llvm-svn: 172308
2013-01-12 07:36:22 +00:00
Nico Weber cb465dcb1d 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.

llvm-svn: 172307
2013-01-12 07:05:25 +00:00
Nico Weber c7a56342bd Formatter: Remove a redundant CurrentLineType check.
The containing if checks for this already. No functionality change.

llvm-svn: 172306
2013-01-12 07:00:16 +00:00
Rafael Espindola 19de5613ea 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).

llvm-svn: 172305
2013-01-12 06:42:30 +00:00
Nico Weber a7252d836a 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];

llvm-svn: 172304
2013-01-12 06:18:40 +00:00
Nico Weber eee7b81a16 Formatter: * and & are binary operators before ( and [.
llvm-svn: 172303
2013-01-12 05:50:48 +00:00
Nico Weber 5dafd4a7ae Formatter: * and & are binary operators after ) and ].
llvm-svn: 172302
2013-01-12 05:47:16 +00:00
Nico Weber 63a54eb766 Formatter: + and - after { are unary operators.
llvm-svn: 172301
2013-01-12 05:41:23 +00:00
NAKAMURA Takumi e73d2a9fff clang/unittests: Fixup corresponding to r172290.
llvm-svn: 172295
2013-01-12 02:16:29 +00:00
Rafael Espindola 7cf35ef8f6 Fix a regression from 171193: main cannot be overloaded.
Thanks Eli Friedman for noticing it.

llvm-svn: 172292
2013-01-12 01:47:40 +00:00
Douglas Gregor c147b0bc31 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.

llvm-svn: 172290
2013-01-12 01:29:50 +00:00
Nico Weber 4a5030c72f Formatter: add a test for :? in []
llvm-svn: 172289
2013-01-12 01:28:06 +00:00
Richard Smith a7edaad3b6 Only produce one -Wc++98-compat warning when initializing a reference from an init list with multiple elements.
llvm-svn: 172285
2013-01-12 01:05:20 +00:00
Rafael Espindola d60589ad39 Add a test from pr14898.
llvm-svn: 172283
2013-01-12 01:01:06 +00:00
Matt Beaumont-Gay b1e71a7d0c 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.

llvm-svn: 172279
2013-01-12 00:54:16 +00:00
Fariborz Jahanian 37494a176c comment parsing: when property accessors don't have comment
of their own (or are syntheszed), use prperty's comment.
for them. // rdar://12791315

llvm-svn: 172278
2013-01-12 00:28:34 +00:00
Ted Kremenek 4e9a2dbde5 Refine analyzer's handling of unary '!' and floating types to not assert.
Fixes PR 14634 and <rdar://problem/12903080>.

llvm-svn: 172274
2013-01-11 23:36:25 +00:00
Sean Callanan 19dfc93912 Fixed a bug that caused the AST importer to erroneously
import incomplete definitions for RecordDecls and then
mark the resulting definition as complete.

llvm-svn: 172273
2013-01-11 23:17:47 +00:00
Dmitri Gribenko 037f9d18ae libclang: use C++ casts in CXString.cpp
llvm-svn: 172272
2013-01-11 23:13:36 +00:00
Dmitri Gribenko ec3a16fc8c libclang: constness for CXString
llvm-svn: 172270
2013-01-11 23:08:18 +00:00
Ted Kremenek 039fac0347 Correctly propagate uninitialized values within logical expressions.
Fixes assertion failure reported in PR 14635 and
<rdar://problem/12902945> respectively.

llvm-svn: 172263
2013-01-11 22:35:39 +00:00
Argyrios Kyrtzidis c57e503c48 [PCH] Make the const_cast explicit to silence a compiler warning.
Patch by David Greene.

llvm-svn: 172262
2013-01-11 22:29:49 +00:00
Argyrios Kyrtzidis 49d9d02947 [libclang] Add some constness in CXSourceLocation and CXSourceRange.
llvm-svn: 172261
2013-01-11 22:29:47 +00:00
Argyrios Kyrtzidis 928e1fdecc [libclang] In ASTUnit::getMainFileName() Invocation may be null because the ASTUnit
came from loading a PCH/module.

llvm-svn: 172259
2013-01-11 22:11:14 +00:00
Ted Kremenek 632af24eb8 Set process return code of 1 in set-xcode-analyzer when Xcode needs to be quit. Fixes <rdar://problem/12983031>.
llvm-svn: 172256
2013-01-11 21:49:36 +00:00
Nico Weber a21aaae7b3 Formatter: Format ObjC static and instance methods consistently, add a test for that.
llvm-svn: 172254
2013-01-11 21:14:08 +00:00
Dmitri Gribenko 7a7284d881 libclang: remove unneeded casts
llvm-svn: 172253
2013-01-11 21:06:06 +00:00
Dmitri Gribenko ba2f746fea libclang: change CXCursor to store 'const void *' pointers for
const-correctness, and update all users

llvm-svn: 172252
2013-01-11 21:01:49 +00:00
Dmitri Gribenko bdc80de74c Constify parameter of clang::getCursorKindForDecl
llvm-svn: 172249
2013-01-11 20:32:41 +00:00
Rafael Espindola 46afb35181 Reject incompatible redeclarations of extern C symbols.
Before we were only checking if the new declaration itself was marked extern
C. Fixes prpr14766.

llvm-svn: 172243
2013-01-11 19:34:23 +00:00
Fariborz Jahanian 70ae634f87 Improve diagnostic per Richard's suggestion
(which may yet change if we move the diagnostic
 outside case value).

llvm-svn: 172242
2013-01-11 19:33:54 +00:00
Dmitri Gribenko 2c173b4806 libclang: use getCursorTU and getCursorASTUnit instead of explicit casts
llvm-svn: 172241
2013-01-11 19:28:44 +00:00
Manuel Klimek 9fa8d5578d Fix crashes in UnwrappedLineParser on missing parens.
llvm-svn: 172239
2013-01-11 19:23:05 +00:00
Manuel Klimek 2acb7b7bb1 Fix single-line optimization for ObjC.
Puts blocks always into multiple lines when they start with an ObjC
keyword or minus.

llvm-svn: 172238
2013-01-11 19:17:44 +00:00
Manuel Klimek adededff26 Fix crash on invalid.
if { foo; }
would previously crash clang-format.

llvm-svn: 172232
2013-01-11 18:28:36 +00:00
Manuel Klimek d5e5f8f2a4 Fix parsing of initializer lists with elaborated type specifier.
Now we correctly parse and format:
verifyFormat("struct foo a = { bar };
int n;

llvm-svn: 172229
2013-01-11 18:13:04 +00:00
Manuel Klimek f4ab9ef34c Implements pulling simple blocks into a single line.
void f() { return 42; }

The final change that implements the feature.

llvm-svn: 172225
2013-01-11 17:54:10 +00:00
Fariborz Jahanian 1e8a3c8ebd Add -std=c++98 to the test and minor improvment in addition.
llvm-svn: 172221
2013-01-11 17:33:57 +00:00
Edwin Vane 5038ac0fb8 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
llvm-svn: 172219
2013-01-11 17:04:55 +00:00
Daniel Jasper d6a947f75f Correct spacing around new and delete.
This fixes llvm.org/PR14913.

Before:  A *a = new(placement) A;
After:   A *a = new (placement) A;
llvm-svn: 172212
2013-01-11 16:09:04 +00:00
Alexander Kornienko 2cc2d60451 clang-format: a bit nicer error message.
llvm-svn: 172211
2013-01-11 16:03:45 +00:00
David Chisnall 2ec1b10d8e Enable the new (more C++-like, less broken) EH model when targeting the GNUstep
Objective-C runtime 1.7 or greater.

llvm-svn: 172207
2013-01-11 15:33:01 +00:00
Enea Zaffanella 29e1c4b03e 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.

llvm-svn: 172201
2013-01-11 14:34:39 +00:00
Daniel Jasper fd8c4b1321 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.

llvm-svn: 172200
2013-01-11 14:23:32 +00:00
Daniel Jasper 2408a8c755 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.

llvm-svn: 172196
2013-01-11 11:37:55 +00:00
Enea Zaffanella 392291f7dc Test commit.
llvm-svn: 172195
2013-01-11 11:37:08 +00:00
Daniel Jasper 337816e48a 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.

llvm-svn: 172188
2013-01-11 10:22:12 +00:00
Nikola Smiljanic c531dcc837 Pass false instead of 0 since isStar parameter of getArray has type bool. No functionality change.
llvm-svn: 172185
2013-01-11 08:33:05 +00:00
Nikola Smiljanic 9d22fb11ba Fix spelling error and remove the part about CMake having experimental Ninja support since 2.8.9 has been released some time ago.
llvm-svn: 172182
2013-01-11 07:23:53 +00:00
Nikola Smiljanic 7835e3d1fe Revert the line ending mess I made.
llvm-svn: 172179
2013-01-11 07:14:58 +00:00
Nikola Smiljanic f1bb07f1d8 Fix spelling error and remove the part about CMake having experimental Ninja support since 2.8.9 has been released some time ago.
llvm-svn: 172177
2013-01-11 07:09:00 +00:00
Anna Zaks 39a7692091 [analyzer] Rename the warning: state the issue before the hint of how it
can be fixed

llvm-svn: 172170
2013-01-11 03:52:44 +00:00
Anna Zaks ca49e535ae [analyzer]Recognize ivar invalidation protocol even if it was redeclared
This will get rid of some false positives as well as false negatives.

llvm-svn: 172169
2013-01-11 03:52:40 +00:00
Anna Zaks 2975cf27e4 [analyzer] Ivar invalidation: track ivars declared in categories.
llvm-svn: 172168
2013-01-11 03:52:37 +00:00
Jordan Rose 78dd388afb 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.

llvm-svn: 172163
2013-01-11 02:37:47 +00:00
Dmitri Gribenko 5ca49f71fd Replace more usages of __func__ with LLVM_FUNCTION_NAME
llvm-svn: 172161
2013-01-11 02:23:13 +00:00
Dmitri Gribenko 9f08be0272 libclang logging: fixup for MSVC, which does not have __func__
llvm-svn: 172158
2013-01-11 01:15:02 +00:00
Fariborz Jahanian 00ccbdce21 Improve on my last test for patch for // rdar://12897704
llvm-svn: 172154
2013-01-11 00:55:44 +00:00
Dmitri Gribenko a237126fc6 tg-fixits.td: fixup for Linux, which does not have a correct implementation of
llvm::sys::locale::columnWidth()

llvm-svn: 172152
2013-01-11 00:37:33 +00:00
Richard Smith 78165b53bf Truth in advertising: LocallyScopedExternalDecls actually only contains
external declarations with C language linkage.

llvm-svn: 172150
2013-01-10 23:43:47 +00:00
Anna Zaks a96a9ef716 [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)'

llvm-svn: 172147
2013-01-10 23:34:16 +00:00
Fariborz Jahanian cc7f008b85 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

llvm-svn: 172144
2013-01-10 23:28:43 +00:00
Nico Weber 71f95e05ec Formatter: Remove a fixme, Jordy says @synthesize is good as is.
llvm-svn: 172141
2013-01-10 23:12:29 +00:00
Nico Weber 9efe291fa8 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

llvm-svn: 172140
2013-01-10 23:11:41 +00:00
Anna Zaks 640123de5e [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.

llvm-svn: 172134
2013-01-10 22:44:16 +00:00
Will Dietz a38608b43f 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).

llvm-svn: 172127
2013-01-10 22:20:02 +00:00
Fariborz Jahanian 54c3907484 Declare +new instead of -new in test.
llvm-svn: 172126
2013-01-10 22:17:49 +00:00
Chad Rosier 97b5895029 [ms-inline asm] Add test case for r172121.
Part of rdar://12991541

llvm-svn: 172122
2013-01-10 22:11:28 +00:00
Chad Rosier 8a11f77cf3 [ms-inline asm] Extend the inline asm Sema lookup interface to determine if the
Decl is a VarDecl.
Part of rdar://12991541

llvm-svn: 172120
2013-01-10 22:10:16 +00:00
Nico Weber a2a8495e19 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).

llvm-svn: 172110
2013-01-10 21:30:42 +00:00
Anna Zaks 0aeb60d79d [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.

llvm-svn: 172104
2013-01-10 20:59:51 +00:00
Fariborz Jahanian 9409e46714 In my last patch use InGroup<Switch> (per Dmitri's comment).
llvm-svn: 172103
2013-01-10 20:47:57 +00:00
Fariborz Jahanian 941827931e Provide a better warning when case value overflows.
// rdar://11577384

llvm-svn: 172102
2013-01-10 20:26:42 +00:00
Nico Weber 35496eea98 Formatter: Land header change I forgot to land in r172099.
llvm-svn: 172101
2013-01-10 20:19:27 +00:00
Nico Weber d6f962f151 Formatter: Add test for template and protocol parameters in ObjC method declarations.
llvm-svn: 172100
2013-01-10 20:18:33 +00:00
Nico Weber a608775ba2 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.

llvm-svn: 172099
2013-01-10 20:12:55 +00:00
Manuel Klimek 51bd6ec142 Refactoring the outermost structure of the formatter.
This is the last step of pure shuffling stuff around, the next step will
be the actual feature.

llvm-svn: 172098
2013-01-10 19:49:59 +00:00
Argyrios Kyrtzidis 1489ed2b68 [libclang] Address some coding style issues pointed out by Dmitri.
llvm-svn: 172096
2013-01-10 19:43:44 +00:00
Nico Weber a1a5abd5b1 Formatter: Don't put a space in ObjC number literals like @+50
Before:
@ -4.5

Now:
@-4.5

llvm-svn: 172095
2013-01-10 19:36:35 +00:00
Ted Kremenek 4a800f876a ccc-analyzer: Forward -msse* options to the compiler.
llvm-svn: 172094
2013-01-10 19:29:31 +00:00
Nico Weber 2bb0074232 Formatter: Add space before '(' in @implemenation, @interface, @protocol lines
The first token in @implementation, @interface, and @protocol lines is now
marked TT_ObjCDecl, and lines starting with a TT_ObjCDecl token are now marked
LT_ObjCMethodDecl.

llvm-svn: 172093
2013-01-10 19:19:14 +00:00
Manuel Klimek b2c6dbec52 Pull calculation whether a line fits one level up.
This is the next step towards being able to configure multiple unwrapped
lines into one.

llvm-svn: 172092
2013-01-10 19:17:33 +00:00
Fariborz Jahanian 1eab052a7f objectiveC++: When throwing c++ exception of
an objectiveC object, use objc_exception_throw
to raise the exception. // rdar://12605907

llvm-svn: 172091
2013-01-10 19:02:56 +00:00
Argyrios Kyrtzidis f036f1a630 [libclang] Add missing header file
llvm-svn: 172090
2013-01-10 18:58:44 +00:00
Argyrios Kyrtzidis ea47435861 [libclang] Enhance logging capabilities of libclang.
-provide a "raw_ostream'ish" class to make it convenient to output logging info.
-use macros to automate a bit the logging functionality inside libclang functions
-when logging, print a stack trace if "LIBCLANG_LOGGING=2" environment is set.
-add logging to more functions.

llvm-svn: 172089
2013-01-10 18:54:52 +00:00
Jordan Rose d12618f6db Diagnostics: name all implicit groups used more than once.
This will be a new style requirement going forwards: a diagnostic can only
use the implicit InGroup<DiagGroup<"foo">> syntax if "foo" is not used by
any other diagnostics; as soon as it is, it needs an explicit group.

This also brings some stray "conversion" diagnostics into the
"Value Conversion Issue" category, instead of the more generic
"Semantic Issue" category. I consider this an improvement!
- warn_impcast_complex_scalar
- warn_impcast_float_integer
- warn_impcast_float_precision
- warn_impcast_integer_precision
- warn_impcast_vector_scalar

llvm-svn: 172088
2013-01-10 18:50:51 +00:00
Jordan Rose c3b23aa848 Error if an anonymous DiagGroup is referenced multiple times.
Not only is this inefficient for TableGen, it's annoying for maintenance
when renaming warning flags (unusual) or adding those flags to a group
(more likely).

This uses the new fix-it infrastructure for LLVM's SourceMgr/SMDiagnostic,
as well as a few changes to TableGen to track more source information.

llvm-svn: 172087
2013-01-10 18:50:46 +00:00
Manuel Klimek 0b689fd68d Pulling formatFirstToken one level up.
This prepares the code for single line optimizations and changes the
dependencies between single-line-formats to the indent of the first
token.

Conceptually, the first token is "between" the lines anyway, as the
whitespace for the first token includes the previous end-of-line, which
needs to be escaped when inside a preprocessor directive.

llvm-svn: 172083
2013-01-10 18:45:26 +00:00
Manuel Klimek 0ddd57a17b Fixes layout of right braces.
We now decide whether a newline should go before the closing brace
depending on whether a newline was inserted after the opening brace.

For example, we now insert a newline before '};' in:
static SomeClass WithALoooooooooooooooooooongName = {
  100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"
};
... while not inserting a newline here:
static SomeClass = { a, b, c, d, e, f, g, h, i, j,
                     looooooooooooooooooooooooooooooooooongname,
                     looooooooooooooooooooooooooooooong };

Also fixes the formating of (column limit 25):
int x = {
  avariable,
  b(alongervariable)
};

llvm-svn: 172076
2013-01-10 15:58:26 +00:00
Alexander Kornienko 5b7157ac8d Basic support for diagnostics.
Summary: Uses DiagnosticsEngine to output diagnostics.

Reviewers: djasper, klimek

Reviewed By: djasper

CC: cfe-commits

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

llvm-svn: 172071
2013-01-10 15:05:09 +00:00
Manuel Klimek 73a2fdf232 Fixes formatting of function calls etc inside an initializer list.
We're now formatting (column limit 25):
int x = {
  avariable,
  b(alongervariable) };

This also fixes:
Aaa({
  int i;
}, aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
                                    ccccccccccccccccc));
... where we would previously break after the '},'.

Putting the closing curly into an extra line when there's a break
directly after the first curly will be done in a subsequent patch.

Paired with djasper.

llvm-svn: 172070
2013-01-10 14:36:46 +00:00
Manuel Klimek e7d10a1f50 Do not add newline in empty blocks.
void f() {}
now gets formatted in one line.

llvm-svn: 172067
2013-01-10 13:24:24 +00:00
Daniel Jasper c1fa281325 Improvements to function type and ObjC block formatting.
Before: int (^myBlock) (int) = ^(int num) {}
        A<void ()>;
	int (*b)(int);

After:  int (^myBlock)(int) = ^(int num) {}
        A<void()>;
	int(*b)(int);

For function types and function pointer types, this patch only makes
the behavior consistent (for types that are keywords and other types).
For the latter function pointer type declarations, we'll probably
want to add a space after "int".

Also added LangOpts.Bool = 1, so we handle "A<bool()>" appropriately
Moved the LangOpts-settings to a public place for use by tests
and clang-format binary.

llvm-svn: 172065
2013-01-10 13:08:12 +00:00
Simon Atanasyan 81c423cc97 [Mips] Pass a combination of +soft-float and -mips16-hard-float flags to
the backend if hard float ABI is selected under -mips16 mode.

llvm-svn: 172062
2013-01-10 12:36:19 +00:00
Manuel Klimek 8e07a1b64b Fix layout of blocks inside statements.
Previously, we would not indent:
SOME_MACRO({
  int i;
});
correctly. This is fixed by adding the trailing }); to the unwrapped
line starting with SOME_MACRO({, so the formatter can correctly match
the braces and indent accordingly.

Also fixes incorrect parsing of initializer lists, like:
int a[] = { 1 };

llvm-svn: 172058
2013-01-10 11:52:21 +00:00
Daniel Jasper 7194e1818e Improve clang-format's understanding of casts.
This fixes llvm.org/PR14684.

Before: int *pa = (int *) & a;
After:  int *pa = (int *)&a;

We still don't understand all kinds of casts. I added a FIXME to
address that.

llvm-svn: 172056
2013-01-10 11:14:08 +00:00
David Tweed c38f11de40 r172047 lacked a test (due to incomplete OpenCL support in clang). Use a modified
version of a test by Joey Gouly to use attributes to materialise the unsupported
types and test vector shifts.

llvm-svn: 172053
2013-01-10 10:42:08 +00:00
Guy Benyei 03e61960c8 Enable intel_ocl_bicc for x86_64 target only. Remove fix from 171969 that enabled this extension for multiple targets.
llvm-svn: 172052
2013-01-10 10:41:05 +00:00
Manuel Klimek fba4bb114b Introduce a define to switch on debug output.
After re-writing the same loop multiple times, we deicided it's time to
add this as an optional debugging help.

llvm-svn: 172050
2013-01-10 10:05:08 +00:00
Daniel Jasper 83a54d23d3 Do more error checking for '{}'.
This fixes llvm.org/PR14883, where clang-format would run into an
assertion on:

void f() { return } 42

llvm-svn: 172049
2013-01-10 09:26:47 +00:00
David Tweed 9fb566c076 Testing with a full OpenCL compiler (based on clang) reveals r71734 missed
difference between type widths of a vector and the width of one of its elements
in the case of vector shifts. Use correct witdth in the vector case.

llvm-svn: 172047
2013-01-10 09:11:33 +00:00
NAKAMURA Takumi eacd667238 clang-c/Index.h: Clarify empty argument with (void) for C89.
llvm-svn: 172037
2013-01-10 02:12:38 +00:00
Douglas Gregor 0f2b4635be Be more careful about updating the failed-modules set
llvm-svn: 172035
2013-01-10 02:04:18 +00:00
Nick Lewycky 230203c949 Don't assert in codegen on static data members which have NoLinkage. Fixes
PR14825!

llvm-svn: 172031
2013-01-10 01:46:29 +00:00
Douglas Gregor 4ddf2221b4 Rework the realpath nonsense for framework lookups to deal more
uniformly with symlinks between top-level and embedded frameworks.

llvm-svn: 172030
2013-01-10 01:43:00 +00:00
Nico Weber bbe28b3d80 Formatter: Remove unused @-formatting code.
@optional @property is put on two different unwrapped lines now, so this is no
longer necessary.

llvm-svn: 172024
2013-01-10 00:42:07 +00:00
Nico Weber 51306d232e Formatter: @optional and @required go on their own line.
Previously:
@protocol myProtocol
- (void)mandatoryWithInt:(int)i;
@optional - (void) optional;
@required - (void) required;
@end

Now:
@protocol myProtocol
- (void)mandatoryWithInt:(int)i;
@optional
- (void)optional;
@required
- (void)required;
@end

llvm-svn: 172023
2013-01-10 00:25:19 +00:00
Nico Weber 2ce0ac5a8c Formatter: Add support for @implementation.
Just reuse the @interface code for this. It accepts slightly more than
necessary (@implementation cannot have protocol lists), but that's ok.

llvm-svn: 172019
2013-01-09 23:25:37 +00:00
Argyrios Kyrtzidis eb994f4064 [PreprocessingRecord] A macro expansion can be reported out-of-order in cases when
there are macro expansions inside macro arguments where the arguments are
not expanded in the same order as listed; don't assert that all macro expansions
are in source order.

rdar://12397063

llvm-svn: 172018
2013-01-09 23:22:20 +00:00
Argyrios Kyrtzidis 9f89bffc25 [utils/ClangDataFormat.py] Don't use lldb.frame directly, get the frame from the value.
Some lldb changes made lldb.frame not set until a script is invoked, which made the
formatters not working after a restart.

llvm-svn: 172017
2013-01-09 23:22:08 +00:00
Fariborz Jahanian 8b115b7872 Issue warning when case value is too large to fit
in case condition type. // rdar://11577384.
Test is conditionalized on x86_64-apple triple as
I am not sure if the INT_MAX/LONG_MAX values in the test
will pass this test for other hosts.

llvm-svn: 172016
2013-01-09 23:04:56 +00:00
Dmitri Gribenko dd7d8a0f35 ClangTools.rst: spelling and formatting
llvm-svn: 172008
2013-01-09 22:22:51 +00:00
Dmitri Gribenko cb9ede9437 ClangFormat.rst: improve formatting
llvm-svn: 172007
2013-01-09 22:18:55 +00:00
Hal Finkel 6134a6e7b8 Remove the unused Parser::ParseTranslationUnit function
Parser::ParseTranslationUnit is now dead because the loop over
ParseTopLevelDecl is in ParseAST.

llvm-svn: 172005
2013-01-09 21:49:51 +00:00
Daniel Jasper 85a77c1609 Add documentation for clang-format.
This adds documentation for both LibFormat as well as the standalone
tools and integrations built on top of it. It slightly restructures
the ClangTools documentation.

llvm-svn: 172004
2013-01-09 21:49:28 +00:00
Nico Weber d8ffe75ad1 Formatter: Make parseObjCUntilAtEnd() actually work.
llvm-svn: 172003
2013-01-09 21:42:32 +00:00
Nico Weber 8696a8d9e3 Formatting: Add support for @protocol.
Pull pieces of the @interface code into reusable methods.

llvm-svn: 172001
2013-01-09 21:15:03 +00:00
Nico Weber 4d03055e70 Fix test after r171995.
I wasn't aware libFormat is used elsewhere already. Let me know if rebasing
is not the right thing to do here.

llvm-svn: 171996
2013-01-09 20:36:10 +00:00
Nico Weber 7eecf4b6e3 Formatter: Add support for @interface.
Previously:
@interface Foo + (id)init; @end

Now:
@interface Foo
+ (id)init;
@end

Some tweaking remains, but this is a good first step.

llvm-svn: 171995
2013-01-09 20:25:35 +00:00
Benjamin Kramer 696651429d unwind.h: Add include guards and don't mess with visibility if HIDE_EXPORTS is specified.
For GCC compatibility.

llvm-svn: 171991
2013-01-09 19:54:57 +00:00
Ted Kremenek 2f2edd3fb1 Do not model loads from complex types, since we don't accurately model the imaginary and real parts yet.
Fixes false positive reported in <rdar://problem/12964481>.

llvm-svn: 171987
2013-01-09 18:46:17 +00:00
David Blaikie 5a6a020d9b Suppress GCC -Wreturn warning.
Modified from a patch by David Greene.

llvm-svn: 171982
2013-01-09 17:48:41 +00:00
Rafael Espindola 3bd836a58e Handle static functions being redeclared in function scope.
Fixes pr14861.

llvm-svn: 171978
2013-01-09 16:34:58 +00:00
Manuel Klimek 52b1515405 Enables layouting unwrapped lines around preprocessor directives.
Previously, we'd always start at indent level 0 after a preprocessor
directive, now we layout the following snippet (column limit 69) as
follows:

functionCallTo(someOtherFunction(
    withSomeParameters, whichInSequence,
    areLongerThanALine(andAnotherCall,
  B
                       withMoreParamters,
                       whichStronglyInfluenceTheLayout),
    andMoreParameters),
               trailing);

Note that the different jumping indent is a different issue that will be
addressed separately.

This is the first step towards handling #ifdef->#else->#endif chains
correctly.

llvm-svn: 171974
2013-01-09 15:25:02 +00:00
Guy Benyei 6313f780e1 Enable intel_ocl_bicc for x86_64 target. This was missed in r171056.
llvm-svn: 171969
2013-01-09 12:21:44 +00:00
Daniel Jasper bcab430fee Only align after assignments on the top level.
This fixes llvm.org/PR14870 and we no longer mess up:
template <typename T1, typename T2 = char, typename T3 = char,
          typename T4 = char>
void f();

It removes the nice aligment for assignments inside other expressions,
but I am not sure those are actually practically relevant. If so, we can
fix those later.

llvm-svn: 171966
2013-01-09 10:40:23 +00:00
Daniel Jasper 2df93311da Don't simply give up when exceeding 80cols, choose an "ok" option.
This addresses llvm.org/PR14847.

We can now format something like:
int aaaaaaaaaaaaaaaaaaaaaaaaaaa =
    // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;

clang-format unavoidably exceeds the column limit, but does not just
flush everything into a single line. Moreover, it tries to minimize the
number of characters beyond the column limit.

llvm-svn: 171964
2013-01-09 10:16:05 +00:00
Daniel Jasper 890589414b Correctly format wrapped function call parameters in templated functions.
This fixes llvm.org/PR14846.

Before:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
        int aaaaaaaaaaaaaaaaa);

After:
template <typename T>
void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
    int aaaaaaaaaaaaaaaaa);

llvm-svn: 171963
2013-01-09 09:50:48 +00:00
Manuel Klimek cdd5c2397a Fixes dump_ast_matchers to parse all matcher macros and updates the
docs.

llvm-svn: 171962
2013-01-09 09:38:21 +00:00
Daniel Jasper d8bb2db242 Allow comments in the middle of statements to be on their own line.
This fixes llvm.org/PR14860.

Before, we messed up the format of:
if (DeclaratorInfo.isFunctionDeclarator() &&
    //getDeclSpecContextFromDeclaratorContext(Context) == DSC_top_level &&
    Tok.is(tok::semi) && NextToken().is(tok::l_brace)) {
}

llvm-svn: 171961
2013-01-09 09:33:39 +00:00
Daniel Jasper fb3f2482e5 Fix ObjC block declarations.
Before: int ( ^ Block1) (int, int) = ^ (int i, int j)
After:  int (^Block1) (int, int) = ^(int i, int j)
llvm-svn: 171959
2013-01-09 08:36:49 +00:00
Daniel Jasper 399d24bc7d Improve formatting of conditional operators.
This addresses llvm.org/PR14864.

We used to completely mess this up and now format as:
Diag(NewFD->getLocation(),
     getLangOpts().MicrosoftExt ? diag::ext_function_specialization_in_class :
         diag::err_function_specialization_in_class)
    << NewFD->getDeclName();

llvm-svn: 171957
2013-01-09 07:06:56 +00:00
Nico Weber 69dce49c76 Don't mention -fno-diagnostics-print-source-range-info in manual.
Clang doesn't understand it.

If someone wants to teach clang about that flag instead, please also add
support for -fno-diagnostics-parseable-fixits for consistency.

Until then, let the documentation match the current behavior.

llvm-svn: 171952
2013-01-09 05:06:41 +00:00
Will Dietz 450f1a1f45 [ubsan] Make static check data non-const so it can be used for deduplication.
llvm-svn: 171947
2013-01-09 03:39:41 +00:00
Eli Friedman c52435b4a2 Make sure clang puts tokens from different files on separate lines in "-E -P" mode. <rdar://problem/12774044>
llvm-svn: 171944
2013-01-09 03:16:42 +00:00
Eli Friedman ec94b61745 Make __has_include a bit more resilient in the presence of macros. <rdar://problem/12748859>.
llvm-svn: 171939
2013-01-09 02:20:00 +00:00
Douglas Gregor 3552dabfe1 When name lookup for a redeclaration finds declarations that are known
(because they are part of some module) but have not been made visible
(because they are in a submodule that wasn't imported), filter out
those declarations unless both the old declaration and the new
declaration have external linkage. When one or both has internal
linkage, there should be no conflict unless both are imported.

llvm-svn: 171925
2013-01-09 00:47:56 +00:00
Fariborz Jahanian 14da440018 put back diagnostics when flexible members are captured
in lambdas.

llvm-svn: 171921
2013-01-09 00:09:15 +00:00
Michael Gottesman 675444d5de Removed extra "`" from ARC documentation.
llvm-svn: 171920
2013-01-08 23:55:10 +00:00
Chad Rosier d35ae732ac [ms-inline asm] Add a test case for the offset operator where the operand is a
global variable.

llvm-svn: 171919
2013-01-08 23:51:48 +00:00
Fariborz Jahanian 5eae4adf23 Fix typo (again).
llvm-svn: 171917
2013-01-08 23:48:48 +00:00
Fariborz Jahanian 7a83f04094 Remove lambda from my last patch.
llvm-svn: 171915
2013-01-08 23:40:08 +00:00
Fariborz Jahanian b68f7b2a77 Fixes typo in comment.
llvm-svn: 171913
2013-01-08 23:21:22 +00:00
Fariborz Jahanian a716a34527 objectiveC blocks: It is impractical to capture
struct variables with flexiable array members in
blocks (and lambdas). Issue error instead of
crashing in IRGen. // rdar://12655829

llvm-svn: 171912
2013-01-08 23:17:51 +00:00
Richard Smith 5f044ad5f0 PR14855: don't silently swallow a nested-name-specifier after a type name.
llvm-svn: 171908
2013-01-08 22:43:49 +00:00
Rafael Espindola b68dd4717e Clear LV cache when dropping availability attributes.
llvm-svn: 171906
2013-01-08 22:31:36 +00:00
Rafael Espindola a3aea433f8 Tighten types a bit. No functionality change.
llvm-svn: 171902
2013-01-08 22:04:34 +00:00
Rafael Espindola c231fab756 Don't crash when trying to apply the availability attribute to a block.
llvm-svn: 171899
2013-01-08 21:30:32 +00:00
Rafael Espindola c2453dd8f5 Tighten types a bit. No functionality change.
llvm-svn: 171895
2013-01-08 21:00:12 +00:00
Rafael Espindola 0a67e2fc8b Tighten types a bit. No functionality change.
llvm-svn: 171894
2013-01-08 20:44:06 +00:00
David Blaikie 9360953135 Remove on-by-default warning from -Wmost.
-Wint-to-pointer-cast, added to match GCC's warning by the same name, doesn't
need to be in any other groups (as it isn't in any groups in GCC either).

Found in post-commit review by Ted Kremenek.

llvm-svn: 171893
2013-01-08 20:28:13 +00:00
Nico Weber 4cc9874ff9 Formatter: More tests for already-passing ObjC bits.
llvm-svn: 171892
2013-01-08 20:16:23 +00:00
Anna Zaks efe76bc821 [analyzer] Bump down the max size of functions being analyzed.
With the new setting, we are not going to inline any functions that are
more than 50 basic blocks. (The analyzer is 20% faster on several
especially bad benchmarks with the new default.)

llvm-svn: 171891
2013-01-08 20:09:00 +00:00
Daniel Jasper 66dcb1ca86 Don't break after unary operators.
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *
                                                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 171890
2013-01-08 20:03:18 +00:00
Rafael Espindola f26d5391ab Move loop variable update.
Thanks to Dmitri Gribenko for the suggestion.

llvm-svn: 171889
2013-01-08 19:58:34 +00:00
Rafael Espindola 820fa707b1 Mark all subsequent decls used.
In the source

  static void f();
  static void f();
  template<typename T>
  static void g() {
    f();
  }
  static void f() {
  }
  void h() {
    g<int>();
  }

the call to f refers to the second decl, but it is only marked used at the end
of the translation unit during instantiation, after the third f decl has been
linked in.

With this patch we mark all subsequent decls used, so that it is easy to check
if a symbol is used or not.

llvm-svn: 171888
2013-01-08 19:43:34 +00:00
Nico Weber 77aa25090a Formatter: Format @ literals better. Array and dictionary literals need more work.
llvm-svn: 171887
2013-01-08 19:40:21 +00:00
Jordan Rose a2d5f0c742 Various tweaks and updates to the analyzer website.
llvm-svn: 171885
2013-01-08 19:29:37 +00:00
Anna Zaks 454a384e59 [analyzer] Only include uniqueling location as issue_hash when available
This makes us more optimistic when matching reports in a changing code
base. Addresses Jordan's feedback for r171825.

llvm-svn: 171884
2013-01-08 19:19:46 +00:00
Nico Weber d8cdb53e1d Formatter: More ObjC tests.
llvm-svn: 171883
2013-01-08 19:15:23 +00:00
Argyrios Kyrtzidis bf1be59dae [libclang] In clang_equalCursors, clear out the "FirstInDeclGroup" part in a declaration cursor
before doing the comparison.

This is because we can't set "FirstInDeclGroup" consistently; for example, when visiting a DeclStmt we will set
it but we don't set it on the result of clang_getCursorDefinition for a reference of the same declaration.

llvm-svn: 171878
2013-01-08 18:23:28 +00:00
Douglas Gregor c4c1fb39d8 Use Decl::getAvailability() rather than checking for the "unavailable"
attribute when determining whether we need to see an implementation of
a property. Fixes <rdar://problem/12958191>.

llvm-svn: 171877
2013-01-08 18:16:18 +00:00
Nico Weber 7e6a7a19e3 Formatter: Add tests for some ObjC bits that happen to be formatted correctly.
llvm-svn: 171875
2013-01-08 17:56:31 +00:00
Ted Kremenek 0ab78e622f Repost checker-270, which for some reason got deleted.
llvm-svn: 171870
2013-01-08 17:33:58 +00:00
Manuel Klimek 6e67bed48c clang-format can now format #defines.
llvm-svn: 171865
2013-01-08 16:33:20 +00:00
Daniel Jasper 4f397156c4 Don't put spaces around ##.
In Clang/LLVM this seems to be the more common formatting for ##s. There
might still be case that we miss, but we'll fix those as we go along.

Before:

  #define A(X)
    void function ## X();

After:

  #define A(X)
    void function##X();

llvm-svn: 171862
2013-01-08 16:17:54 +00:00
Rafael Espindola c8c61895be Add missing spaces. This doesn't cause problems in practice because we only warn
about _Static_assert with -pedantic.

llvm-svn: 171860
2013-01-08 16:09:04 +00:00
Rafael Espindola ef5ea1df4e Clear the LV cache when setting the instantiated from link.
Fixes pr14835.

llvm-svn: 171857
2013-01-08 14:58:32 +00:00
Daniel Jasper 7c85fde500 Change the data structure used in clang-format.
This is a first step towards supporting more complex structures such
as #ifs inside unwrapped lines. This patch mostly converts the array-based
UnwrappedLine into a linked-list-based UnwrappedLine. Future changes will
allow multiple children for each Token turning the UnwrappedLine into a
tree.

No functional changes intended.

llvm-svn: 171856
2013-01-08 14:56:18 +00:00
Dmitri Gribenko 7daa1a2201 CodeGen/compound-assign-overflow.c: include stdint.h in freestanding mode
This hopefully fixes the ARM buildbot.

llvm-svn: 171853
2013-01-08 14:47:41 +00:00
Sean Silva 3703823b89 docs: "clang tools" are not a different interface.
I spotted someone confused about this, so remove the heading to make it
clear that they really are a part of Tooling.

llvm-svn: 171841
2013-01-08 04:42:09 +00:00
Rafael Espindola 9a5a6dddf9 Clear the LV cache when merging the availability attribute.
The availability implies default visibility, so it can change the computed
visibility.

llvm-svn: 171840
2013-01-08 04:04:30 +00:00
Eric Christopher 9cf4480392 Add a test to make sure that vector output happens for debug info.
llvm-svn: 171834
2013-01-08 01:54:13 +00:00
Ted Kremenek a046169000 Don't warn about undefined varargs argument behavior in unreachable code.
Fixes <rdar://problem/12322000>.

llvm-svn: 171831
2013-01-08 01:50:40 +00:00
David Blaikie f7e654e3a7 Add [artificial] debug info annotation to test matching r171826
llvm-svn: 171830
2013-01-08 01:12:59 +00:00
Argyrios Kyrtzidis 08281fa337 [arcmt] Follow-up for r171484; make sure when adding brackets enclosing case statements,
that the case does not "contain" a declaration that is referenced "outside" of it,
otherwise we will emit un-compilable code.

llvm-svn: 171828
2013-01-08 00:58:25 +00:00
Richard Smith 1ecd564487 Move ref qualifiers from Type bitfields into FunctionProtoType, stealing two
bits from the number of parameters. This brings the bitfields down from 33 bits
to 32 bits, reducing the size of Types by 4 bytes on 32-bit systems.

llvm-svn: 171827
2013-01-08 00:50:27 +00:00
Anna Zaks a043d0cef2 [analyzer] Include the bug uniqueing location in the issue_hash.
The issue here is that if we have 2 leaks reported at the same line for
which we cannot print the corresponding region info, they will get
treated as the same by issue_hash+description. We need to AUGMENT the
issue_hash with the allocation info to differentiate the two issues.

Add the "hash" (offset from the beginning of a function) representing
allocation site to solve the issue.

We might want to generalize solution in the future when we decide to
track more than just the 2 locations from the diagnostics.

llvm-svn: 171825
2013-01-08 00:25:29 +00:00
Anna Zaks 58b961d176 [analyzer] Plist: change the type of issue_hash from int to string.
This gives more flexibility to what could be stored as issue_hash.

llvm-svn: 171824
2013-01-08 00:25:22 +00:00
Anna Zaks af48a938e3 [analyzer] Extend the Representing Values section of the dev manual.
llvm-svn: 171823
2013-01-08 00:25:14 +00:00
NAKAMURA Takumi 160087b1f6 clang/test/CodeGenOpenCL/shifts.cl: Fixup for -Asserts.
llvm-svn: 171820
2013-01-08 00:15:53 +00:00
Richard Smith 27874d603b PR14838: When a member reference is bound to a temporary, don't forget to
perform the semantic checks associated with the destruction of that temporary.
It'll be destroyed at the end of the constructor.

llvm-svn: 171818
2013-01-08 00:08:23 +00:00
Douglas Gregor 21444b96c8 Back out my no-op change from r171783.
llvm-svn: 171817
2013-01-08 00:01:45 +00:00
Dmitri Gribenko b9eb593e50 Correct OpenBSD profiling test
The test should be looking for gcrt0.o not crt0.o.  Clang was already printing
"gcrt0", but the test was looking for "{{.*}}crt0.o", and the .* regexp
consumed "g".

Patch by Brad Smith.

llvm-svn: 171815
2013-01-07 23:55:47 +00:00
David Blaikie 7eb0685969 Extract the instance-method case for debug info out into a separate function.
This is in preparation for using this to construct the function type for
pointers to member functions to include the implicit/artificial 'this'
parameter in that case as well. (feedback from GDB indicates that this might be
all that's necessary to get it to behave well with Clang's pointer-to-member
function debug output)

llvm-svn: 171809
2013-01-07 23:06:35 +00:00
Rafael Espindola fe95841630 add a triple
llvm-svn: 171808
2013-01-07 23:04:04 +00:00
Will Dietz cefb44869a [ubsan] Use correct type for compound assignment ops.
llvm-svn: 171801
2013-01-07 22:25:52 +00:00
David Blaikie 2aaf065103 Simplify computing debug info type for static member functions.
No (intended) functional change.

llvm-svn: 171800
2013-01-07 22:24:59 +00:00
Michael Gottesman 6fd5846b57 Converted Block-ABI-Apple.txt => Block-ABI-Apple.rst.
llvm-svn: 171799
2013-01-07 22:24:45 +00:00
Sean Silva 449e4926a6 docs: Fix inconsistent titles.
Sphinx was whining about this.

llvm-svn: 171796
2013-01-07 21:46:47 +00:00
Sean Silva dc92fc3426 docs: Copy Block-ABI-Apple.txt to output.
This fixes the URL permanence of that URL. This is a bit of a hack. See
the FIXME in the patch for what the "real" solution should be.

llvm-svn: 171795
2013-01-07 21:46:35 +00:00
Fariborz Jahanian 0a17f59db8 Minor refactoring of my last patch
related to // rdar://12958878

llvm-svn: 171792
2013-01-07 21:31:08 +00:00
Daniel Dunbar 5cfa4aeee5 [docs/analyzer] Test commit (for auto-update).
llvm-svn: 171788
2013-01-07 20:44:37 +00:00
Daniel Dunbar 98a93b3845 [docs] Fix an inconsistent title level, and a sphinx warning.
- We don't need any static files currently, so drop that dir.

llvm-svn: 171787
2013-01-07 20:43:06 +00:00
Daniel Dunbar 48f8bc895b [docs/analyzer] Convert existing debug-checks document to Sphinx and link into doctree.
llvm-svn: 171786
2013-01-07 20:38:55 +00:00
Chad Rosier 8f980ef08c Test case for r171784.
llvm-svn: 171785
2013-01-07 20:34:40 +00:00
Douglas Gregor da776f9a8e Use the C++11 POD definition in C++11 mode to determine whether one
can create a VLA of class type. Fixes <rdar://problem/12151822>.

llvm-svn: 171783
2013-01-07 20:03:16 +00:00
Rafael Espindola 0370597620 Use getter. Fixes the build from a bad merge.
llvm-svn: 171782
2013-01-07 20:01:57 +00:00
Rafael Espindola f0dafd3cbb Add support for attribute((mode(unwind_word))).
Patch by Nick Lewycky. Fixes pr8703.

llvm-svn: 171781
2013-01-07 19:58:54 +00:00
Fariborz Jahanian c41cf0598f objective-C: when searching for declarations in protocol
list of classes, etc., make sure to look into protocol
definitions. // rdar://12958878

llvm-svn: 171777
2013-01-07 19:21:03 +00:00
Argyrios Kyrtzidis 68d31ce5ff [libclang] When annotating preprocessor tokens, if we are in a macro definition,
check if the token was ever a macro name and annotate it if that's the case.

llvm-svn: 171776
2013-01-07 19:16:32 +00:00
Argyrios Kyrtzidis 2d77aeb946 [libclang] Simplify annotation of preprocessing tokens and remove the AnnotateTokensData
DenseMap and the lookups associated with it.

Instead of lexing for preprocessor tokens, associating the annotation with the location in a map,
and later lookup in the map in order to adjust the cursor annotation, just annotate the cursor
while lexing for preprocessor tokens.

llvm-svn: 171775
2013-01-07 19:16:30 +00:00
Argyrios Kyrtzidis 98a8874a0d [libclang] Make token annotation of type/storage qualifiers accurate.
Previously type/storage qualifiers would not be annotated as the declaration they belonged to.
Just use the resulting source range of getRawCursorExtent() which is more correct
than what AnnotateTokensWorker::Visit() was adjusting it to.

llvm-svn: 171774
2013-01-07 19:16:27 +00:00
Argyrios Kyrtzidis 579825a50a [libclang] When getting the cursor for an identifier inside a macro definition, check if
this was ever a macro name and return a specific CXCursor_MacroExpansion cursor in such a case,
instead of the generic CXCursor_MacroDefinition.

Checking for macro name makes sure the identifier is not part of the identifier list in a
function macro.
While, in general, resolving identifiers in macro definitions to other macros may not be completely accurate,
it greatly improves functionality such as give-me-the-definition-of-this, which was not working at all
inside macro definitions.

llvm-svn: 171773
2013-01-07 19:16:25 +00:00
Argyrios Kyrtzidis 7572be2e44 [PCH] (De)serialize the end location of MacroInfo.
llvm-svn: 171772
2013-01-07 19:16:23 +00:00
Argyrios Kyrtzidis 86f1a935dc Pull the bulk of Lexer::MeasureTokenLength() out into a new function,
Lexer::getRawToken().

No functionality change.

llvm-svn: 171771
2013-01-07 19:16:18 +00:00
Anna Zaks 030e65d1b2 [analyzer] Fix a false positive in Secure Keychain API checker.
Better handle the blacklisting of known bad deallocators when symbol
escapes through a call to CFStringCreateWithBytesNoCopy.

Addresses radar://12702952.

llvm-svn: 171770
2013-01-07 19:13:00 +00:00