Commit Graph

13847 Commits

Author SHA1 Message Date
Fariborz Jahanian 0389e528ab Audit DeclPrinter with -ast-dump on Cocoa.h and
fix any bad objectiveC syntax coming out of
DeclPrinter. This is on going. Also, introduce a new
PrintPolicy and use it as needed when declaration tag
is to be produced via DeclPrinter.

llvm-svn: 170606
2012-12-19 23:36:00 +00:00
Bill Wendling 7967fc14b9 Rename the 'Attributes' class to 'Attribute'. It's going to represent a single attribute in the future.
llvm-svn: 170500
2012-12-19 07:18:12 +00:00
Richard Smith 4efa77fde4 Attempt to clarify a vexing-parse diagnostic.
llvm-svn: 170492
2012-12-19 03:15:32 +00:00
Richard Smith d59b832320 PR13470: Ensure that copy-list-initialization isntantiates as
copy-list-initialization (and doesn't add an additional copy step):

Fill in the ListInitialization bit when creating a CXXConstructExpr. Use it
when instantiating initializers in order to correctly handle instantiation of
copy-list-initialization. Teach TreeTransform that function arguments are
initializations, and so need this special treatment too. Finally, remove some
hacks which were working around SubstInitializer's shortcomings.

llvm-svn: 170489
2012-12-19 01:39:02 +00:00
Ted Kremenek 3a081a0339 Pass AnalyzerOptions to PathDiagnosticConsumer to make analyzer options accessible there.
This is plumbing needed for later functionality changes.

llvm-svn: 170488
2012-12-19 01:35:35 +00:00
David Blaikie ff7d47a354 Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as per review discussion in r170365
This does limit these typedefs to being sequences, but no current usage
requires them to be contiguous (we could expand this to a more general
iterator pair range concept at some point).

Also, it'd be nice if SmallVector were constructible directly from an ArrayRef
but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the
inverse conversion. (& generalizing over all range-like things, while nice,
would require some nontrivial SFINAE I haven't thought about yet)

llvm-svn: 170482
2012-12-19 00:45:41 +00:00
Meador Inge b97878a235 CodeGen: Expand creal and cimag into complex field loads
PR 14529 was opened because neither Clang or LLVM was expanding
calls to creal* or cimag* into instructions that just load the
respective complex field.  After some discussion, it was not
considered realistic to do this in LLVM because of the platform
specific way complex types are expanded.  Thus a way to solve
this in Clang was pursued.  GCC does a similar expansion.

This patch adds the feature to Clang by making the creal* and
cimag* functions library builtins and modifying the builtin code
generator to look for the new builtin types.

llvm-svn: 170455
2012-12-18 20:58:04 +00:00
Guy Benyei d8a08ea98d Re-commit r170428 changes with Linux style file endings.
Add OpenCL images as clang builtin types.

llvm-svn: 170432
2012-12-18 14:38:23 +00:00
Guy Benyei 11169dded0 Revert changes from r170428, as I accidentally changed the line endings of these files to Windows style.
llvm-svn: 170431
2012-12-18 14:30:41 +00:00
Guy Benyei b13abb952a Add OpenCL images as clang builtin types.
llvm-svn: 170428
2012-12-18 12:30:03 +00:00
Anders Carlsson 2a45e409a8 When warning about a missing prototype because a function declaration is missing 'void', insert a fixit to add the void.
llvm-svn: 170399
2012-12-18 01:29:20 +00:00
Bill Wendling 707021a90f Use the correct return type (size_t) for these builtins.
<rdar://problem/12646344>

llvm-svn: 170393
2012-12-18 00:37:10 +00:00
Bill Wendling 5d4e6a6a10 Add an expected parameter for the size of the destination.
<rdar://problem/12622659>

llvm-svn: 170392
2012-12-18 00:34:49 +00:00
Eric Christopher 45f2e71571 Add support for passing the main file name down to the assembler
for location information.

Part of PR14624

llvm-svn: 170391
2012-12-18 00:31:10 +00:00
Chandler Carruth 4d5e1a9b34 Fix PR14625 by teaching the driver to detect PWD for assembly files.
This also requires adding support to -cc1as for passing the detecting
PWD down through LLVM's debug info (which in turn required the LLVM
change in r170371).

The test case is weak (we only test the driver behavior) because there
is currently to infrastructure for running cc1as in the test suite. So
those four lines are untested (much like all other lines in that file),
but we have a test for the same pattern using llvm-mc in the LLVM
repository.

llvm-svn: 170373
2012-12-17 21:40:04 +00:00
Argyrios Kyrtzidis 40f6c2ac9c Just use begin()/end() instead of "&Vector[0], &Vector[0]+Vector.size()".
No functionality change.

llvm-svn: 170365
2012-12-17 20:10:50 +00:00
Anna Zaks d53182b0df [analyzer] Implement "do not inline large functions many times"
performance heuristic

After inlining a function with more than 13 basic blocks 32 times, we
are not going to inline it anymore. The idea is that inlining large
functions leads to drastic performance implications. Since the function
has already been inlined, we know that we've analyzed it in many
contexts. 

The following metrics are used:
 - Large function is a function with more than 13 basic blocks (we
should switch to another metric, like cyclomatic complexity)
 - We consider that we've inlined a function many times if it's been
inlined 32 times. This number is configurable with -analyzer-config
max-times-inline-large=xx

This heuristic addresses a performance regression introduced with
inlining on one benchmark. The analyzer on this benchmark became 60
times slower with inlining turned on. The heuristic allows us to analyze
it in 24% of the time. The performance improvements on the other
benchmarks I've tested with are much lower - under 10%, which is
expected.

llvm-svn: 170361
2012-12-17 20:08:51 +00:00
David Chisnall 0d75e0600b Reapply r170344, this time without forgetting to commit the header changes.
llvm-svn: 170354
2012-12-17 18:54:24 +00:00
Nico Weber 555d1aa3a4 IdentifierResolver: Remove an unnecessary include and an unused parameter.
llvm-svn: 170297
2012-12-17 03:51:09 +00:00
Edwin Vane 524741fbbd Style and Doc fix for CommonOptionsParser
- Renaming GetCompilations() and GetSourcePathList() to follow LLVM
  style.
- Updating docs to reflect name change.
- Also updating help text to not mention clang-check since this class
  can be used by any tool.

Reviewed By: Alexander Kornienko

llvm-svn: 170229
2012-12-14 18:58:25 +00:00
Nico Weber 7aa4a881e6 Don't require a space between the two ">" in "vector<id<protocol>>" in objc++11.
C++11 allowed writing "vector<vector<int>>" without a space between the two ">".
This change allows this for protocols in template lists too in -std=c++11 mode,
and improves the diagnostic in c++98 mode.

llvm-svn: 170223
2012-12-14 18:22:38 +00:00
Nico Weber b819108af7 fix another spello
llvm-svn: 170177
2012-12-14 02:41:18 +00:00
Argyrios Kyrtzidis 3960540e30 [PCH] Make the new PCH format (control block) backwards compatible and
don't crash when loading a PCH with the older format.

The introduction of the control block broke compatibility with PCHs from
older versions. This patch allows loading (and rejecting) PCHs from an older
version and allows newer PCHs to be rejected from older clang versions as well.

rdar://12821386

llvm-svn: 170150
2012-12-13 21:38:23 +00:00
Roman Divacky d93c8c008e Dont use/link ARCMT, StaticAnalyzer and Rewriter to clang when the user
specifies not to. Dont build ASTMatchers with Rewriter disabled and
StaticAnalyzer when it's disabled.

Without all those three, the clang binary shrinks (x86_64) from ~36MB
to ~32MB (unstripped).

llvm-svn: 170135
2012-12-13 16:09:42 +00:00
Richard Smith 1629da95fe ubsan: Add -fsanitize=bool and -fsanitize=enum, which check for loads of
bit-patterns which are not valid values for enumerated or boolean types.
These checks are the ubsan analogue of !range metadata.

llvm-svn: 170108
2012-12-13 07:11:50 +00:00
Eli Friedman 07bab73c7f Using CanQualType::getAs<ArrayType> is unsafe; fix the code currently using it,
and make sure additional uses don't get introduced.  <rdar://problem/12858424>.

llvm-svn: 170081
2012-12-13 01:43:21 +00:00
Argyrios Kyrtzidis f5b993f7b1 [objc] For the ARC error that is emitted when a synthesized property implementation
has inconsistent ownership with the backing ivar, point the error location to the
ivar.

Pointing to the ivar (instead of the @synthesize) is better since this is where a fix is needed.
Also provide the location of @synthesize via a note.

This also fixes the problem where an auto-synthesized property would emit an error without
any location.

llvm-svn: 170039
2012-12-12 22:48:25 +00:00
Douglas Gregor c50d4924eb Use @import rather than @__experimental_modules_import, since the
latter is rather a mess to type.

llvm-svn: 169919
2012-12-11 22:11:52 +00:00
Hal Finkel 061f1653e6 Add -fslp-vectorize to enable bb-vectorize
Add -fslp-vectorize (with -ftree-slp-vectorize as an alias for gcc compatibility)
to provide a way to enable the basic-block vectorization pass. This uses the same
acronym as gcc, superword-level parallelism (SLP), also common in the literature,
to refer to basic-block vectorization.

Nadav suggested this as a follow-up to the adding of -fvectorize.

llvm-svn: 169909
2012-12-11 19:59:32 +00:00
Chad Rosier 30797b2d7d [driver] Add the -ftree-vectorize flag as a alias of -fvectorize to maintain
compatibility with gcc.
rdar://12839978 

llvm-svn: 169888
2012-12-11 17:46:33 +00:00
Chad Rosier 0d3ed6f1c2 [driver] Add the -fvectorize flag to enable the loop vectorization passes.
rdar://12839978 

llvm-svn: 169885
2012-12-11 17:12:28 +00:00
Argyrios Kyrtzidis 3b7793797f Extend stat query APIs to explicitly specify if the query is for
a file or directory, allowing just a stat call if a file descriptor
is not needed.

Doing just 'stat' is faster than 'open/fstat/close'.
This has the effect of cutting down system time for validating the input files of a PCH.

llvm-svn: 169831
2012-12-11 07:48:23 +00:00
Richard Smith bd3051272c PR14558: Compute triviality of special members (etc) at the end of the class
definition, rather than at the end of the definition of the set of nested
classes. We still defer checking of the user-specified exception specification
to the end of the nesting -- we can't check that until we've parsed the
in-class initializers for non-static data members.

llvm-svn: 169805
2012-12-11 01:14:52 +00:00
Manuel Klimek dd1ff5ece0 Clarifying comments for the MatchFinder and matchesNames matcher.
llvm-svn: 169737
2012-12-10 16:13:06 +00:00
Aaron Ballman 02df2e0872 Virtual method overrides can no longer have mismatched calling conventions. This fixes PR14339.
llvm-svn: 169705
2012-12-09 17:45:41 +00:00
Richard Smith f86b5dc700 PR14550: If a system header contains a bogus constexpr function definition,
don't mark the function as invalid, since we suppress the error.

llvm-svn: 169689
2012-12-09 05:55:43 +00:00
Richard Smith 6b02d46dae Finish implementing 'selected constructor' rules for triviality in C++11. In
the cases where we can't determine whether special members would be trivial
while building the class, we eagerly declare those special members. The impact
of this is bounded, since it does not trigger implicit declarations of special
members in classes which merely *use* those classes.

In order to determine whether we need to apply this rule, we also need to
eagerly declare move operations and destructors in cases where they might be
deleted. If a move operation were supposed to be deleted, it would instead
be suppressed, and we could need overload resolution to determine if we fall
back to a trivial copy operation. If a destructor were implicitly deleted,
it would cause the move constructor of any derived classes to be suppressed.

As discussed on cxx-abi-dev, C++11's selected constructor rules are also
retroactively applied as a defect resolution in C++03 mode, in order to
identify that class B has a non-trivial copy constructor (since it calls
A's constructor template, not A's copy constructor):

struct A { template<typename T> A(T &); };
struct B { mutable A a; };

llvm-svn: 169673
2012-12-08 08:32:28 +00:00
Richard Smith 1a2532b3fe Remove some remnants of the assumption that there is at most one of each
flavour of special member.

llvm-svn: 169670
2012-12-08 04:10:18 +00:00
Richard Smith 92f241f188 Properly compute triviality for explicitly-defaulted or deleted special members.
Remove pre-standard restriction on explicitly-defaulted copy constructors with
'incorrect' parameter types, and instead just make those special members
non-trivial as the standard requires.

This required making CXXRecordDecl correctly handle classes which have both a
trivial and a non-trivial special member of the same kind.

This also fixes PR13217 by reimplementing DiagnoseNontrivial in terms of the
new triviality computation technology.

llvm-svn: 169667
2012-12-08 02:53:02 +00:00
Argyrios Kyrtzidis f77b0f8886 [libclang] Resolve a cursor that points to a macro name inside a #ifdef/#ifndef
directive as a macro expansion.

This is more of a "macro reference" than a macro expansion but it's close enough
for libclang's purposes. If it causes issues we can revisit and introduce a new
kind of cursor.

llvm-svn: 169666
2012-12-08 02:21:17 +00:00
Argyrios Kyrtzidis 222a7bbf0d [Preprocessor] Enhance Ifdef/Ifndef/Defined preprocessor callbacks to also pass
a MacroInfo object if the identifier was a macro name.

llvm-svn: 169665
2012-12-08 02:21:11 +00:00
Richard Smith 593f993a68 Implement C++03 [dcl.init]p5's checking for value-initialization of references
properly, rather than faking it up by pretending that a reference member makes
the default constructor non-trivial. That leads to rejects-valids when putting
such types inside unions.

llvm-svn: 169662
2012-12-08 02:01:17 +00:00
DeLesley Hutchins 8ecd491e75 Fix analysis based warnings so that all warnings are emitted when compiling
with -Werror.  Previously, compiling with -Werror would emit only the first
warning in a compilation unit, because clang assumes that once an error occurs,
further analysis is unlikely to return valid results.  However, warnings that
have been upgraded to errors should not be treated as "errors" in this sense.

llvm-svn: 169649
2012-12-07 22:53:48 +00:00
Anna Zaks 9cadaa7ef8 [analyzer] Rename the option help to reflect better what it does.
llvm-svn: 169640
2012-12-07 21:51:50 +00:00
Anna Zaks 5d484780fb [analyzer] Optimization heuristic: do not reanalyze every ObjC method as
top level.

This heuristic is already turned on for non-ObjC methods
(inlining-mode=noredundancy). If a method has been previously analyzed,
while being inlined inside of another method, do not reanalyze it as top
level.

This commit applies it to ObjCMethods as well. The main caveat here is
that to catch the retain release errors, we are still going to reanalyze
all the ObjC methods but without inlining turned on.

Gives 21% performance increase on one heavy ObjC benchmark, which
suffered large performance regressions due to ObjC inlining.

llvm-svn: 169639
2012-12-07 21:51:47 +00:00
Jordan Rose 9a33913645 [analyzer] Fix r168019 to work with unpruned paths as well.
This is the case where the analyzer tries to print out source locations
for code within a synthesized function body, which of course does not have
a valid source location. The previous fix attempted to do this during
diagnostic path pruning, but some diagnostics have pruning disabled, and
so any diagnostic with a path that goes through a synthesized body will
either hit an assertion or emit invalid output.

<rdar://problem/12657843> (again)

llvm-svn: 169631
2012-12-07 19:56:29 +00:00
Richard Smith c2f865e8e5 Add file missed from r169574!
llvm-svn: 169576
2012-12-07 02:26:01 +00:00
Jordan Rose d40d321bcd [analyzer] Remove possible pessimizations from r169563.
Thanks for reminding me about copy-elision, David. Passing references here
doesn't help when we could get move construction in C++11. If we really
cared, we'd use std::swap to steal the reference from the temporary arg,
but it's probably not /that/ critical outside of Profile anyway.

llvm-svn: 169570
2012-12-07 01:54:38 +00:00
Jordan Rose 6c4e70817c [analyzer] Avoid ProgramStateRef copy constructors.
Suggested by David Blaikie. ExplodedNode, CallEvent, and CheckerContext all
hang onto their ProgramState, so the accessors can return a reference to the
internal state rather than preemptively copying it. This helps avoid
temporary ProgramStateRefs, though local variables will still (correctly)
do an extra retain and release.

llvm-svn: 169563
2012-12-06 23:55:34 +00:00
Benjamin Kramer bb09cb6433 Simplify PDiag's move assignment overload a bit, the self-move check isn't actually necessary.
This just empties out the diag, which is fine.

llvm-svn: 169542
2012-12-06 20:12:03 +00:00