Commit Graph

35912 Commits

Author SHA1 Message Date
Hans Wennborg d99d688358 Make -Wformat fix-its preserve original conversion specifiers.
This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType()
only fix a conversion specification enough that Clang wouldn't warn about it,
as opposed to always changing it to use the "canonical" conversion specifier.
(PR11975)

This preserves the user's choice of conversion specifier in cases like:

printf("%a", (long double)1);
where we previously suggested "%Lf", we now suggest "%La"

printf("%x", (long)1);
where we previously suggested "%ld", we now suggest "%lx".

llvm-svn: 150578
2012-02-15 09:59:46 +00:00
Richard Smith d3cf238e26 If a static data member of a class template which could be used in a constant
expression is referenced, defined, then referenced again, make sure we
instantiate it the second time it's referenced. This is the static data member
analogue of r150518.

llvm-svn: 150560
2012-02-15 02:42:50 +00:00
Richard Smith b228a86fcf Implement DR1454. This allows all intermediate results in constant expressions
to be core constant expressions (including pointers and references to
temporaries), and makes constexpr calculations Turing-complete. A Turing machine
simulator is included as a testcase.

This opens up the possibilty of removing CCValue entirely, and removing some
copies from the constant evaluator in the process, but that cleanup is not part
of this change.

llvm-svn: 150557
2012-02-15 02:18:13 +00:00
Anna Zaks d1ff1cbe23 [analyzer] Malloc checker: make a bit safer.
llvm-svn: 150556
2012-02-15 02:12:00 +00:00
Richard Smith 19582e85bd Fix typo in r150549.
llvm-svn: 150555
2012-02-15 02:07:05 +00:00
John McCall c62bb39142 Split reinterpret_casts of member pointers out from CK_BitCast; this
is general goodness because representations of member pointers are
not always equivalent across member pointer types on all ABIs
(even though this isn't really standard-endorsed).

Take advantage of the new information to teach IR-generation how
to do these reinterprets in constant initializers.  Make sure this
works when intermingled with hierarchy conversions (although
this is not part of our motivating use case).  Doing this in the
constant-evaluator would probably have been better, but that would
require a *lot* of extra structure in the representation of
constant member pointers:  you'd really have to track an arbitrary
chain of hierarchy conversions and reinterpretations in order to
get this right.  Ultimately, this seems less complex.  I also
wasn't quite sure how to extend the constant evaluator to handle
foldings that we don't actually want to treat as extended
constant expressions.

llvm-svn: 150551
2012-02-15 01:22:51 +00:00
Douglas Gregor 3009383b9f Implement indexing support for lambdas in libclang (both kinds), as
well as improving the RecursiveASTVisitor's walk of lambda
expressions.

llvm-svn: 150549
2012-02-15 00:54:55 +00:00
Fariborz Jahanian fdc06e32cf modern objective-c translator: start writing the main class
meta-data.

llvm-svn: 150548
2012-02-15 00:50:11 +00:00
Anna Zaks a432feaf26 [analyzer] Add the Malloc checker to the list of tested checkers.
llvm-svn: 150535
2012-02-15 00:19:07 +00:00
Anna Zaks 5a6213d22b [analyzer] Malloc Checker: Add another false positive as a todo test.
llvm-svn: 150534
2012-02-15 00:11:28 +00:00
Anna Zaks ac06814d2f [analyzer] Malloc Checker: add support for reallocf, which always frees
the passed in pointer on failure.

llvm-svn: 150533
2012-02-15 00:11:25 +00:00
Anna Zaks d51574850e [analyzer] Malloc Checker: add support for valloc + minor code
hardening.

llvm-svn: 150532
2012-02-15 00:11:22 +00:00
Richard Smith 9bd64f90e2 Extend all-std-headers.cpp to include C++11 headers when building in C++11 mode.
Conditionally include headers which older STL implementations don't provide.

llvm-svn: 150526
2012-02-14 23:06:14 +00:00
Richard Smith 1cb2af0b3a Advertize support for constexpr.
llvm-svn: 150524
2012-02-14 22:56:17 +00:00
Richard Smith b9a7efd791 I hereby declare that all remaining constexpr issues are bugs, not unimplemented
features. :)

llvm-svn: 150522
2012-02-14 22:39:23 +00:00
Richard Smith ab44d9b321 constexpr: evaluation support for nullptr comparisons.
llvm-svn: 150521
2012-02-14 22:35:28 +00:00
Douglas Gregor adb376ec33 Implement C++ core issue 974, which permits default arguments for
lambda expressions. Because these issue was pulled back from Ready
status at the Kona meeting, we still emit an ExtWarn when using
default arguments for lambda expressions.

llvm-svn: 150519
2012-02-14 22:28:59 +00:00
Richard Smith 4a941e25f2 If a constexpr function template specialization is referenced, and then the
template is defined, and then the specialization is referenced again, don't
forget to instantiate the template on the second reference. Use the source
location of the first reference as the point of instantiation, though.

llvm-svn: 150518
2012-02-14 22:25:15 +00:00
Argyrios Kyrtzidis 7e747957cd [libclang] Indexing: only index implicit template instantiations via an opt-in indexing option.
llvm-svn: 150517
2012-02-14 22:23:11 +00:00
Dmitri Gribenko 800ddf3dda Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)
* if, switch, range-based for: warn if semicolon is on the same line.
* for, while: warn if semicolon is on the same line and either next
statement is compound statement or next statement has more
indentation.

Replacing the semicolon with {} or moving the semicolon to the next
line will always silence the warning.

Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp.

llvm-svn: 150515
2012-02-14 22:14:32 +00:00
Anna Zaks 3d34834bb0 [analyzer] Make Malloc Checker optimistic in presence of inlining.
(In response of Ted's review of r150112.)

This moves the logic which checked if a symbol escapes through a
parameter to invalidateRegionCallback (instead of post CallExpr visit.)

To accommodate the change, added a CallOrObjCMessage parameter to
checkRegionChanges callback.

llvm-svn: 150513
2012-02-14 21:55:24 +00:00
Ted Kremenek 76978f9d6c Remove recusive expression visitation in ExprEngine::VisitIncrementDecrementOperator().
llvm-svn: 150511
2012-02-14 21:38:30 +00:00
Richard Smith 98a0a49fbf Pending clear answer from WG21 on whether core issue 903 is intended to apply to
C++11 or just C++17, restrict the set of null pointer constants in C++11 mode
back to those which were considered null in C++98.

llvm-svn: 150510
2012-02-14 21:38:30 +00:00
Ted Kremenek 89dbd3ba40 Remove recursive visitation in ExprEngine for UO_Not, UO_Minus, UO_LNot.
llvm-svn: 150509
2012-02-14 21:31:00 +00:00
Ted Kremenek 8c8578c0b8 Remove recursive visitation in ExprEngine for UO_Deref, UO_AddrOf, and UO_Extension.
llvm-svn: 150506
2012-02-14 21:27:05 +00:00
Ted Kremenek c14557fb6a Remove ExprEngine recursive visitation of unary UO_Imag operation.
llvm-svn: 150505
2012-02-14 21:27:02 +00:00
Ted Kremenek b5d87d8843 Further remove some recursive visitiation in ExprEngine that is no longer needed because the CFG is fully linearized.
llvm-svn: 150504
2012-02-14 21:26:59 +00:00
Douglas Gregor 621003e7b9 Check the return type of lambda expressions.
llvm-svn: 150503
2012-02-14 21:20:44 +00:00
Richard Smith 1bfe068e71 PR11650: Implement resolution of core issue 1301. Value initialization can't be
used to construct an object of union type with a deleted default constructor
(plus fixes for some related value-initialization corner cases).

llvm-svn: 150502
2012-02-14 21:14:13 +00:00
John McCall 5ed3caf2e3 Warn about non-int main() results in GNU C mode instead of erroring.
Based on a patch by Vasiliy Korchagin!

llvm-svn: 150500
2012-02-14 19:50:52 +00:00
Fariborz Jahanian bce36774f0 more objective-c translator for modern abi.
metadata for protocol definitions used on
class qualifiers.

llvm-svn: 150498
2012-02-14 19:31:35 +00:00
Douglas Gregor 3e308b1fba Implement support for lambda capture pack expansions, e.g.,
[&values...] { print(values...); }

llvm-svn: 150497
2012-02-14 19:27:52 +00:00
Kaelyn Uhrain 0a16a8e531 Use several weighted factors to determine typo candidate viablity.
Replace the simple Levenshtein edit distance for typo correction
candidates--and the hacky way adding namespace qualifiers would affect
the edit distance--with a synthetic "edit distance" comprised of several
factors and their relative weights. This also allows the typo correction
callback object to convey more information about the viability of a
correction candidate than simply viable or not viable.

llvm-svn: 150495
2012-02-14 18:56:48 +00:00
Douglas Gregor ae64101e49 Simplify and robustify lambda PCH test
llvm-svn: 150493
2012-02-14 18:47:12 +00:00
Douglas Gregor 99ae806aff Implement AST (de-)serialization for lambda expressions.
llvm-svn: 150491
2012-02-14 17:54:36 +00:00
Fariborz Jahanian b1ba885b49 more modern objc translator. Focusing on metadata for methods.
llvm-svn: 150490
2012-02-14 17:19:02 +00:00
Dylan Noblesmith 4d9cbffbe2 include clang's config.h unconditionally (v2)
And remove HAVE_CLANG_CONFIG_H, now that the header is generated
in the autoconf build, too.

Reverts r149571/restores r149504, now that config.h is generated
correctly by LLVM's configure in all build configurations.

llvm-svn: 150487
2012-02-14 15:54:49 +00:00
Benjamin Kramer 8001f7467a Use a simpler (and more efficient) pattern to pad vectors.
llvm-svn: 150475
2012-02-14 12:06:21 +00:00
David Blaikie cdd91dbe9f Fix crash-on-invalid for 'operator int[]()' in C++11.
Signed off by Richard Smith.

llvm-svn: 150464
2012-02-14 09:00:46 +00:00
Ted Kremenek b05119cb00 Fix use-after-free introduced by me being an idiot.
llvm-svn: 150461
2012-02-14 06:54:46 +00:00
Eli Friedman 248f898c5b Remove useless if statement.
llvm-svn: 150459
2012-02-14 03:54:45 +00:00
Eli Friedman 4412b23e7e Add a coverage test for lambda expression IRGen.
llvm-svn: 150458
2012-02-14 03:07:59 +00:00
Ted Kremenek 914c7e62e8 Implement new DiagnosticsRenderer that packages notes retrieved by clang_getDiagnosticSetFromTU() as
child diagnostics of primary diagnostics.  By using the DiagnosticRenderer, these Diagnostics now
match with those generated for serialized diagnostics.

llvm-svn: 150456
2012-02-14 02:46:03 +00:00
Ted Kremenek 0964cca5d5 Refactor DiagnosticRenderer and SDiagsRenderer to have some functionality
pulled into DiagnosticNoteRenderer, and common DiagnosticRenderer that
assumes that all custom diagnostic messages are notes.  Also extend
DiagnosticRenderer to work with StoredDiagnostics in preparation for
subsequent changes.

llvm-svn: 150455
2012-02-14 02:46:00 +00:00
Ted Kremenek 3efa357fee Add helper methods to StoredDiagnostic.
llvm-svn: 150454
2012-02-14 02:43:12 +00:00
Richard Smith e7f5de485e Fix another issue introduced by the proposed wording for core issue 1358: since
the instantiation of a constexpr function temploid is now always constexpr, a
defaulted constexpr function temploid is often ill-formed by the rule in
[dcl.fct.def.default]p2 that an explicitly-defaulted constexpr function must
have a constexpr implicit definition. To avoid making loads of completely
reasonable code ill-formed, do not apply that rule to templates.

llvm-svn: 150453
2012-02-14 02:33:50 +00:00
Eli Friedman 5f1a04ffd1 Implement IRGen of lambda expressions which capture arrays.
llvm-svn: 150452
2012-02-14 02:31:03 +00:00
Eli Friedman 6ae6302ddf Refactor out new function EmitInitializerForField from EmitMemberInitializer. The new function will be used to initialize the fields of lambda expressions.
llvm-svn: 150451
2012-02-14 02:15:49 +00:00
Anna Zaks ad01ef5fb9 [analyzer] Malloc Checker: realloc: add dependency between the symbols
in realloc map. 

If there is no dependency, the reallocated ptr will get garbage
collected before we know that realloc failed, which would lead us to
missing a memory leak warning.

Also added new test cases, which we can handle now.
Plus minor cleanups.

llvm-svn: 150446
2012-02-14 00:26:13 +00:00
Douglas Gregor 1b66d8c287 Simple test ensuring that we perform direct initialization when copy-capturing in lambdas
llvm-svn: 150442
2012-02-14 00:03:38 +00:00