Commit Graph

42833 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 8bee90d5f3 [PCH/Modules] Re-apply r172620 and r172629, now with 100% less infinite loops!
Makes sure that a deserialized macro is only added to the preprocessor macro definitions only once.
Unfortunately I couldn't get a reduced test case.

rdar://13016031

llvm-svn: 172843
2013-01-18 20:59:01 +00:00
Nico Weber 0bba2d11d0 Fix parsing of class specifiers before '\n' 'operator'.
r159549 / r159164 regressed clang to reject

  struct s {};
  struct s
  operator++(struct s a)
  { return a; }

This fixes the regression. Richard, pleas check if this looks right.

llvm-svn: 172834
2013-01-18 18:41:42 +00:00
Jordan Rose 1dc3940383 [analyzer] Special path notes for C++ special member functions.
Examples:
  Calling implicit default constructor for Foo
  Calling defaulted move constructor for Foo
  Calling copy constructor for Foo
  Calling implicit destructor for Foo
  Calling defaulted move assignment operator for Foo
  Calling copy assignment operator for Foo

llvm-svn: 172833
2013-01-18 18:27:21 +00:00
Jordan Rose fe856d58a3 [analyzer] Do a better job describing C++ member functions in the call stack.
Examples:
  Calling constructor for 'Foo'
  Entered call from 'Foo::create'

llvm-svn: 172832
2013-01-18 18:27:14 +00:00
Manuel Klimek 05d82b72f1 Fix comment.
llvm-svn: 172831
2013-01-18 18:24:28 +00:00
Manuel Klimek da08761bb2 Fixes issues around pulling in the next line in simple if statements.
llvm-svn: 172822
2013-01-18 14:46:43 +00:00
NAKAMURA Takumi d6a707f20e clang/test/CodeGen: Suppress a couple of tests on win32. It seems -fsanitize-blacklist doesn't accept DOSish pathnames.
llvm-svn: 172820
2013-01-18 14:11:04 +00:00
Manuel Klimek d3b92fa61e Fixes problems with line merging in the face of preprocessor directives.
This patch prepares being able to test for and fix more problems (see
FIXME in the test for example).

Previously we would output unwrapped lines for preprocessor directives
at the point where we also parsed the hash token. Since often
projections only terminate (and thus output their own unwrapped line)
after peeking at the next token, this would lead to the formatter seeing
the preprocessor directives out-of-order (slightly earlier). To be able
to correctly identify lines to merge, the formatter needs a well-defined
order of unwrapped lines, which this patch introduces.

llvm-svn: 172819
2013-01-18 14:04:34 +00:00
NAKAMURA Takumi 8b517f1076 clang-check: Introduce llvm::sys::PrintStackTraceOnErrorSignal()
llvm-svn: 172818
2013-01-18 13:46:48 +00:00
Will Dietz f54319c891 [ubsan] Add support for -fsanitize-blacklist
llvm-svn: 172808
2013-01-18 11:30:38 +00:00
Daniel Jasper 04468962ab Reduce penalty for splitting between ")" and ".".
').' is likely part of a builder pattern statement.
This is based upon a patch developed by Nico Weber. Thank you!

Before:
int foo() {
  return llvm::StringSwitch<Reference::Kind>(name).StartsWith(
      ".eh_frame_hdr", ORDER_EH_FRAMEHDR).StartsWith(
      ".eh_frame", ORDER_EH_FRAME).StartsWith(".init", ORDER_INIT).StartsWith(
      ".fini", ORDER_FINI).StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

After:
int foo() {
  return llvm::StringSwitch<Reference::Kind>(name)
         .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
         .StartsWith(".eh_frame", ORDER_EH_FRAME)
         .StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
         .StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
}

Probably not ideal, but makes many cases much more readable.

The changes to overriding-ftemplate-comments.cpp don't seem better or
worse. We should address those soon.

llvm-svn: 172804
2013-01-18 10:56:38 +00:00
Daniel Jasper 997b08ce3c Also align trailing line comments in include directives.
Before:
  #include <a> // for x
  #include <a/b/c> // for yz
After:
  #include <a>     // for x
  #include <a/b/c> // for yz

llvm-svn: 172799
2013-01-18 09:19:33 +00:00
Daniel Jasper aa701fa3ad Let the formatter align trailing line comments where possible.
Before:
int a; // comment
int bbbbb; // comment

After:
int a;     // comment
int bbbbb; // comment

llvm-svn: 172798
2013-01-18 08:44:07 +00:00
Nico Weber a5510af53e Formatter: After case blocks, "break" goes on the same line as the "}", PR14907.
Before:
switch (foo) {
case a: {
  int a = g();
  h(a);
}
  break;
}

Now:
switch (foo) {
case a: {
  int a = g();
  h(a);
} break;
}

llvm-svn: 172789
2013-01-18 05:50:57 +00:00
Nico Weber e3025672e9 Formatter: Enable @encode test.
This doesn't work right with pointers to pointers, but that's likely just a
dupe of PR14884.

llvm-svn: 172785
2013-01-18 05:11:47 +00:00
Douglas Gregor 6a7cb9f8bc Revert Clang r172620 and r172629, which caused a hang when building
complicated modules (<rdar://problem/13038265>). Unfortunately, this
un-fixes <rdar://problem/13016031>.

llvm-svn: 172783
2013-01-18 04:34:14 +00:00
Nico Weber 250fe71366 Formatter: The contents of @selector() should be formatted as a selector.
Before: @selector(foo: )
Now: @selector(foo:)
llvm-svn: 172781
2013-01-18 02:43:57 +00:00
Douglas Gregor 62ffead1ad When checking the parameter types of an Objective-C method, don't
decay the parameter type immediately; let CheckParameter() do its
job. Fixes <rdar://problem/12071218>.

llvm-svn: 172780
2013-01-18 01:41:40 +00:00
Chad Rosier 92c487d13c [ms-inline asm] Test case for r172773.
llvm-svn: 172774
2013-01-18 00:51:29 +00:00
Douglas Gregor f4e43315a9 One can override an Objective-C ARC ownership qualifier that came from
a template parameter; make that also include one that came from
'auto'. Fixes <rdar://problem/12078752>.

llvm-svn: 172770
2013-01-17 23:59:28 +00:00
Richard Smith 5011a0022a Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor not
to visit them.

llvm-svn: 172769
2013-01-17 23:46:04 +00:00
Douglas Gregor cd78037ad1 In Objective-C ARC, completely ignore ownership qualifiers on the
return type of a function by canonicalizing them away. They are
useless anyway, and conflict with our rules for template argument
deduction and __strong. Fixes <rdar://problem/12367446>.

llvm-svn: 172768
2013-01-17 23:36:45 +00:00
Anna Zaks 0e9c94199c [analyzer] DirectIvarAssignment: allow suppression annotation on Ivars.
llvm-svn: 172766
2013-01-17 23:24:58 +00:00
Richard Smith d33f5201b5 Defer checking for unsequenced operations on the RHS of && and || in order to
reduce stack usage and hopefully bring back the linux x86_64 buildbot.

llvm-svn: 172765
2013-01-17 23:18:09 +00:00
Jordan Rose 1eb342920b Format strings: don't ever convert %+d to %lu.
Presumably, if the printf format has the sign explicitly requested, the user
wants to treat the data as signed.

This is a fix-up for r172739, and also includes several test changes that
didn't make it into that commit.

llvm-svn: 172762
2013-01-17 22:34:10 +00:00
Richard Smith 0015f09877 Parsing support for C11's _Noreturn keyword. No semantics yet.
llvm-svn: 172761
2013-01-17 22:16:11 +00:00
Richard Smith 01a7fba820 -Wunsequenced: if the LHS of an &&, || or ?: is not constant, check for
unsequenced operations in the RHS. We don't compare the RHS with the rest of
the expression yet; such checks will need care to avoid diagnosing unsequenced
operations which are both in conditionally-evaluated subexpressions which
actually can't occur together, such as in '(b && ++x) + (!b && ++x)'.

llvm-svn: 172760
2013-01-17 22:06:26 +00:00
Kevin Enderby ae2ec4745f We want the dwarf AT_producer for assembly source files to match clang's
AT_producer.  Which includes clang's version information so we can tell
which version of the compiler was used.

This is second of the two steps to allow us to do this.  The first was a
change to llvm-mc with revision 172630 to provide a method to set the
AT_producer string.  This second step has the clang driver passing the value
of getClangFullVersion() via the new flag -dwarf-debug-producer when invoking
the integrated assembler on assembly source files.  Then using the new
setDwarfDebugProducer() method to set the AT_producer string.

rdar://12888242

llvm-svn: 172758
2013-01-17 21:38:06 +00:00
Peter Collingbourne 24c67c6a63 Do not pass -pie flag to linker if -shared specified. This matches
the gcc driver and makes it possible to add -pie to $CC or similar and
have it apply in the right places.

llvm-svn: 172753
2013-01-17 20:17:16 +00:00
Chad Rosier e343bc83f0 [ms-inline asm] Updates and test case for r172743.
Part of rdar://12576868

llvm-svn: 172744
2013-01-17 19:22:48 +00:00
Chad Rosier 4edf11fcf0 [ms-inline asm] Extend the Sema interface to get the size and length of a
VarDecl.
Part of rdar://12576868

llvm-svn: 172742
2013-01-17 19:21:24 +00:00
Jordan Rose aa7a3b3e75 Format strings: correct signedness if already correcting width (%d,%u).
It is valid to do this:
  printf("%u", (int)x);

But if we see this:
  printf("%lu", (int)x);

...our fixit should suggest %d, not %u.

llvm-svn: 172739
2013-01-17 18:47:16 +00:00
Jordan Rose b169ccc118 Convert test/FixIt/format-darwin.m to use relative line numbers.
llvm-svn: 172738
2013-01-17 18:47:12 +00:00
Joey Gouly 1d58cdbf4e Add some semantic checks for OpenCL. Variadic macros, VLAs and bitfields are not supported.
llvm-svn: 172732
2013-01-17 17:35:00 +00:00
Nico Weber 80a82761bd Formatter: Get bit tests in ifs right.
It's generally not possible to know if 'a' '*' 'b' is a multiplication
expression or a variable declaration with a purely lexer-based approach. The
formatter currently uses a heuristic that classifies this token sequence as a
multiplication in rhs contexts (after '=' or 'return') and as a declaration
else.

Because of this, it gets bit tests in ifs, such as "if (a & b)" wrong. However,
declarations in ifs always have to be followed by '=', so this patch changes
the formatter to classify '&' as an operator if it's at the start of an if
statement.

Before:
  if (a& b)
  if (int* b = f())

Now:
  if (a & b)
  if (int* b = f())

llvm-svn: 172731
2013-01-17 17:17:19 +00:00
Dmitri Gribenko 764ea24cfd Documentation: formatting
llvm-svn: 172729
2013-01-17 17:04:54 +00:00
Daniel Jasper fefb1e6257 Allow breaking after the trailing const after a function declaration.
Before:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const GUARDED_BY(
    aaaaaaaaaaaaa);

After:
void aaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) const
    GUARDED_BY(aaaaaaaaaaaaa);

llvm-svn: 172718
2013-01-17 13:31:52 +00:00
Chandler Carruth 0153800601 Add initial rough support for synthesizing linker options when passed
-fopenmp in the link step on Linux. There is probably more tweaking that
will need to take place to get good support for linking the relevant
libraries on all Linux distributions and/or on other platforms, but this
get's the ball moving and allows Clang to build programs which contain
OpenMP pragmas that can be safely ignored by a compiler that doesn't
implement them, and yet makes direct calls into the OpenMP runtime.

llvm-svn: 172715
2013-01-17 13:19:29 +00:00
Daniel Jasper 11cb81cd6f Improve handling of comments in static initializers.
Also adding more tests.

We can now keep the formatting of something like:

static SomeType type = { aaaaaaaaaaaaaaaaaaaa, /* comment */
                         aaaaaaaaaaaaaaaaaaaa /* comment */,
                         /* comment */ aaaaaaaaaaaaaaaaaaaa,
                         aaaaaaaaaaaaaaaaaaaa, // comment
                         aaaaaaaaaaaaaaaaaaaa };

Note that the comment in the first line is handled like a trailing line comment
as that is likely what the user intended.

llvm-svn: 172711
2013-01-17 12:53:34 +00:00
David Blaikie b61b815fc8 Improve -Wreorder to handle cases of anonymous class member ordering
llvm-svn: 172707
2013-01-17 08:49:22 +00:00
NAKAMURA Takumi 98154a917f clang/test/Index/code-completion-skip-bodies.cpp: Check stdout and stderr individually, rather than mixed output of stdout and stderr with 2>&1.
XFAIL(s) are removed.

llvm-svn: 172705
2013-01-17 07:27:55 +00:00
Nico Weber 772fbfda45 Revert most of r172140.
r172140 changed the formatter to produce "-(id) foo" instead of "- (id)foo"
in google style, with a link to
http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml#Method_Declarations_and_Definitions
as reference.  But now that I look at that link again, it seems I didn't
read it very carefully the first time round.

llvm-svn: 172703
2013-01-17 06:14:50 +00:00
David Blaikie 3fc2f9114a ArrayRef-ize some ctor initializer related APIs
llvm-svn: 172701
2013-01-17 05:26:25 +00:00
David Blaikie 3ae79d9b8b Remove some unnecessary casts
llvm-svn: 172700
2013-01-17 05:26:21 +00:00
David Blaikie af64e141d3 Add test for PR12938, fixed by Richard Smith in r172691
llvm-svn: 172697
2013-01-17 02:43:00 +00:00
Matt Beaumont-Gay 978cca9f49 Suppress all -Wunused-value warnings from macro body expansions.
This is inspired by a number of false positives in real code, including
PR14968. I've added test cases reduced from these false positives to
test/Sema/unused-expr.c, as well as corresponding test cases that pass the
offending expressions as arguments to a no-op macro to ensure that we do warn
there.

This also removes my previous tweak from r166522/r166534, so that we warn on
unused cast expressions in macro arguments.

There were several test cases that were using -Wunused-value to test general
diagnostic emission features; I changed those to use other warnings or warn on
a macro argument expression. I stared at the test case for PR14399 for a while
with Richard Smith and we believe the new test case exercises the same
codepaths as before.

llvm-svn: 172696
2013-01-17 02:06:08 +00:00
Douglas Gregor eaa75a69ad Add a comment for Daniel
llvm-svn: 172695
2013-01-17 01:58:31 +00:00
Richard Smith 7fc772c0bd Test that we correctly handle reversion of line splicing etc in raw string
literals. As suggested by Sean Silva.

llvm-svn: 172694
2013-01-17 01:46:13 +00:00
Richard Smith 2ae0164fba Attempt to work around bug in older GCCs to fix buildbot.
llvm-svn: 172693
2013-01-17 01:40:50 +00:00
Daniel Dunbar 69e4746439 [IRgen] Update modules autolink metadata to use module flags (as now specified
in the LangRef).

llvm-svn: 172692
2013-01-17 01:35:06 +00:00