Commit Graph

2907 Commits

Author SHA1 Message Date
David Majnemer c729b0b506 [-cxx-abi microsoft] Correctly identify Win32 entry points
Summary:
This fixes several issues with the original implementation:
- Win32 entry points cannot be in namespaces
- A Win32 entry point cannot be a function template, diagnose if we it.
- Win32 entry points cannot be overloaded.
- Win32 entry points implicitly return, similar to main.

Reviewers: rnk, rsmith, whunt, timurrrr

Reviewed By: rnk

CC: cfe-commits, nrieck

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

llvm-svn: 190818
2013-09-16 22:44:20 +00:00
Richard Smith 12a41bd3e0 Add some missing ProhibitAttributes calls to some declaration-like #pragmas.
llvm-svn: 190806
2013-09-16 21:17:44 +00:00
Amara Emerson 8c3de546d6 Add error checking to reject neon_vector_type attribute on targets without NEON.
Patch by Artyom Skrobov.

llvm-svn: 190801
2013-09-16 18:07:35 +00:00
Wei Pan c354d2177a Handle PredefinedExpr with templates and lambdas
Summary:

- lambdas, blocks or captured statements in templates were not
  handled which causes codegen crashes.

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

llvm-svn: 190784
2013-09-16 13:57:27 +00:00
Serge Pavlov d5489074e6 Avoid getting an argument of allocation function if it does not exist.
This is a fix to PR12778: in erroneous code an allocation function
can be declared with no arguments, quering the first argument in this case
causes assertion violation.

llvm-svn: 190751
2013-09-14 12:00:01 +00:00
Richard Smith 17e32460ed Part three of PR15721: if we have an invalid CXXDefaultInitExpr, don't crash if
we try to constant-evaluate it. Patch by Karthik Bhat, test by me.

llvm-svn: 190722
2013-09-13 20:51:45 +00:00
Aaron Ballman 8c9795d9fa vector_size cannot be applied to Booleans. Updated the semantic checking logic, as well as the comment and added a test case. Fixes PR12649
llvm-svn: 190721
2013-09-13 20:43:08 +00:00
Aaron Ballman 3b1dde63a2 Switching the WeakRef attribute to using the new checkStringLiteralArgument helper function.
llvm-svn: 190719
2013-09-13 19:35:18 +00:00
Benjamin Kramer ca9fe1453f Guard availability and thread safety attributes against wide strings.
Found by inspection.

llvm-svn: 190701
2013-09-13 16:30:12 +00:00
Richard Trieu 1bc22c12cb Refactor the uninitialized field visitor. Also moved the calls to the visitor
later in the code so that the expressions will have addition processing first.
This catches a few additional cases of uninitialized uses of class fields.

llvm-svn: 190657
2013-09-13 03:20:53 +00:00
Aaron Ballman 682ee42550 Tablegen now generates a StringSwitch for attributes containing enumeration arguments to map strings to the proper enumeration value. This makes error checking more consistent and reduces the amount of hand-written code required.
llvm-svn: 190545
2013-09-11 19:47:58 +00:00
Aaron Ballman e4ba0bdf11 Adding some additional test cases for the cleanup attribute.
llvm-svn: 190525
2013-09-11 13:43:47 +00:00
Daniel Jasper c531daefd9 Split -Wunused-variable warning.
With r190382, -Wunused-variable warns about unused const variables when
appropriate. For codebases that use -Werror, this poses a problem as
existing unused const variables need to be cleaned up first. To make the
transistion easier, this patch splits -Wunused-variable by pulling out
an additional -Wunused-const-variable (by default activated along with
-Wunused-variable).

llvm-svn: 190508
2013-09-11 10:37:35 +00:00
Eli Friedman aa76981400 volatile types are not trivially copyable.
PR17123.

llvm-svn: 190484
2013-09-11 03:49:34 +00:00
Eli Friedman 9ea1e16747 Fix is_trivially_constructible preconditions.
Fixes a crash in cases where the first argument was an incomplete type
or an uninstantiated template type.

<rdar://problem/14938471>

llvm-svn: 190482
2013-09-11 02:53:02 +00:00
Aaron Ballman c12aaff2cb The cleanup attribute no longer uses an unresolved, simple identifier as its argument. Instead, it takes an expression that is fully resolved.
llvm-svn: 190476
2013-09-11 01:37:41 +00:00
Richard Smith 84c6b3d293 PR5683: Issue a warning when subtracting pointers to types of zero size, and
treat such subtractions as being non-constant. Patch by Serge Pavlov! With a
few tweaks by me.

llvm-svn: 190439
2013-09-10 21:34:14 +00:00
Eli Friedman a5dfebdcfd Fix regression from r190382.
Make sure we perform the correct "referenced-but-not-used" check for
static member constants.

Fixes bug reported on cfe-commits by Alexey Samsonov.

llvm-svn: 190437
2013-09-10 21:10:25 +00:00
Eli Friedman 5ef2175866 Make -Wunused warning rules more consistent.
This patch does a few different things.

This patch improves unused var diags for const vars: we no longer
unconditionally suppress diagnostics for const vars, instead only suppressing
the diagnostic when the declaration appears to be useful.

This patch also makes us more consistently use whether a variable/function
is declared in the main file to suppress diagnostics where appropriate.

Fixes <rdar://problem/14907887>.

llvm-svn: 190382
2013-09-10 03:05:56 +00:00
Reid Kleckner 76808056f9 Ignore calling conventions when checking function template specializations
Summary:
Calling conventions are inherited during decl merging.  Before this
change, deduction would fail due to a type mismatch between the template
and the specialization.  This change adjusts the CCs to match before
deduction, and lets the decl merging logic diagnose mismatch or inherit
the CC from the template.

This allows specializations of static member function templates in the
Microsoft C++ ABI.

Reviewers: rsmith

CC: cfe-commits

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

llvm-svn: 190377
2013-09-10 01:04:45 +00:00
Eli Friedman 5a722e92af Add self-comparison warnings for fields.
This expands very slightly what -Wtautological-compare considers to be
tautological to include implicit accesses to C++ fields and ObjC ivars.
I don't want to turn this into a full expression-identity check, but
these additions seem pretty well-contained, and maintain the theme
of checking for "x == x".

<rdar://problem/14431127>

llvm-svn: 190118
2013-09-06 03:13:09 +00:00
David Blaikie 16f76d27ae Consumed Analysis: The 'consumable' attribute now takes a identifier specifying the default assumed state for objects of this class
This information is used for return states and pass-by-value parameter
states.

Patch by Chris Wailes.

Review by DeLesley Hutchins and Aaron Ballman.

llvm-svn: 190116
2013-09-06 01:28:43 +00:00
Richard Smith 4d2bbd78ff When creating an implicit conversion sequence for a reference of type T from an
initializer list containing a single element of type T, be sure to mark the
sequence as a list conversion sequence so that it is known to be worse than an
implicit conversion sequence that initializes a std::initializer_list object.

llvm-svn: 190115
2013-09-06 01:22:42 +00:00
Serge Pavlov 8260530cb2 Clear LookupResult object if invalid candidate is found.
If source code is invalid, error recovery can lead to name lookup in a set containing invalid declaration. The lookup is stopped once found such declaration, but LookupResult object could remain in inconsistent state. Its destructor triggered a check, which caused assert violation.
This patch fixes PR16964 and PR12791.

llvm-svn: 189916
2013-09-04 04:50:29 +00:00
DeLesley Hutchins e13ce180f2 Consumed analysis: update to comments in test cases.
Patch by chris.wailes@gmail.com.

llvm-svn: 189866
2013-09-03 22:35:53 +00:00
Aaron Ballman f58070baed Switched FormatAttr to using an IdentifierArgument instead of a StringArgument since that is a more accurate modeling.
llvm-svn: 189851
2013-09-03 21:02:22 +00:00
DeLesley Hutchins fc368259af Consumed analysis: add return_typestate attribute.
Patch by chris.wailes@gmail.com

Functions can now declare what state the consumable type the are returning will
be in. This is then used on the caller side and checked on the callee side.
Constructors now use this attribute instead of the 'consumes' attribute.

llvm-svn: 189843
2013-09-03 20:11:38 +00:00
Richard Trieu ad00e83ae4 The diagnostic err_init_conversion_failed uses the enum
InitializedEntity::EntityKind as an index for one of its %select.  Over time,
EntityKind has been expanded, but the diagnostic text has not been updated.
This adds additional text to the %select to cover the new enum values.  A
comment has been added to the end of the enum regarding this situation.  This
fixes the crasher in PR17043.

llvm-svn: 189716
2013-08-31 03:50:47 +00:00
DeLesley Hutchins 5a715c4f00 Consumed analysis: add 'consumable' class attribute.
Patch by chris.wailes@gmail.com

Adds the 'consumable' attribute that can be attached to classes.  This replaces
the previous method of scanning a class's methods to see if any of them have
consumed analysis attributes attached to them.  If consumed analysis attributes
are attached to methods of a class that isn't marked 'consumable' a warning
is generated.

llvm-svn: 189702
2013-08-30 22:56:34 +00:00
DeLesley Hutchins b570c13574 Consumed analysis: track function parameters.
Patch by chris.wailes@gmail.com.

llvm-svn: 189616
2013-08-29 22:36:05 +00:00
DeLesley Hutchins 7fa60edb47 Consumed analysis: non-const methods no longer transfer an object into an
unknown state.  Patch by chris.wailes@gmail.com.

llvm-svn: 189612
2013-08-29 21:17:25 +00:00
DeLesley Hutchins 5533ec5c55 Consumed analysis: improve handling of conditionals.
Patch by chris.wailes@gmail.com.

* The TestedVarsVisitor was folded into the ConsumedStmtVisitor.
* The VarTestResult class was updated to allow these changes.
* The PropagationInfo class was updated for the same reasons.
* Correctly handle short-circuiting of Boolean operations.
* Blocks are now marked as unreachable when we can statically prove we will
  never branch to them.
* Unreachable blocks are skipped by the analysis.

llvm-svn: 189594
2013-08-29 17:26:57 +00:00
David Majnemer 8918920a32 Sema: Subst type default template args earlier
Summary:
We would not perform substitution at an appropriate point, allowing strange
results to appear. We would accepts things that we shouldn't or mangle things incorrectly.  Note that this hasn't fixed the other cases like
template-template parameters or non-type template parameters.

Reviewers: doug.gregor, rjmccall, rsmith

Reviewed By: rsmith

CC: cfe-commits

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

llvm-svn: 189540
2013-08-28 23:48:32 +00:00
Eli Friedman a31efa07ff Improve error for assignment to incomplete class.
PR7681.

llvm-svn: 189510
2013-08-28 20:35:35 +00:00
Reid Kleckner 78af0708b7 Delete CC_Default and use the target default CC everywhere
Summary:
Makes functions with implicit calling convention compatible with
function types with a matching explicit calling convention.  This fixes
things like calls to qsort(), which has an explicit __cdecl attribute on
the comparator in Windows headers.

Clang will now infer the calling convention from the declarator.  There
are two cases when the CC must be adjusted during redeclaration:
1. When defining a non-inline static method.
2. When redeclaring a function with an implicit or mismatched
convention.

Fixes PR13457, and allows clang to compile CommandLine.cpp for the
Microsoft C++ ABI.

Excellent test cases provided by Alexander Zinenko!

Reviewers: rsmith

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

llvm-svn: 189412
2013-08-27 23:08:25 +00:00
Wei Pan 8d6b19a518 Handle predefined expression for a captured statement
- __func__ or __FUNCTION__ returns captured statement's parent
  function name, not the one compiler generated.

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

Reviewed by bkramer

llvm-svn: 189219
2013-08-26 14:27:34 +00:00
DeLesley Hutchins 73ec2ae91e Consumed analysis: change class name in test cases.
The name of a class used in the testing files was updated to actually
be descriptive.  Patch by chris.wailes@gmail.com.

llvm-svn: 189132
2013-08-23 18:40:39 +00:00
Richard Smith d136f60b07 Reword a diagnostic to avoid a confusing implication that it might be talking
about a declaration within a return type.

llvm-svn: 189083
2013-08-23 02:16:48 +00:00
DeLesley Hutchins c2ecf0d815 Update to consumed analysis.
Patch by chris.wailes@gmail.com.  The following functionality was added:

* The same functionality is now supported for both CXXOperatorCallExprs and CXXMemberCallExprs.
* Factored out some code in StmtVisitor.
* Removed variables from the state map when their destructors are encountered.
* Started adding documentation for the consumed analysis attributes.

llvm-svn: 189059
2013-08-22 20:44:47 +00:00
Larisse Voufo 8122b22adc Add a constexpr functionality test for static data member templates.
llvm-svn: 188975
2013-08-22 01:05:27 +00:00
Larisse Voufo 72caf2bb6b Refactor for clarity and simplicity.
llvm-svn: 188974
2013-08-22 00:59:14 +00:00
Larisse Voufo 4cda461ec4 Improve support for static data member templates. This revision still has at least one bug, as it does not respect the variable template specialization hierarchy well.
llvm-svn: 188969
2013-08-22 00:28:27 +00:00
Eli Friedman 5ba37d5282 Split isFromMainFile into two functions.
Basically, isInMainFile considers line markers, and isWrittenInMainFile
doesn't.  Distinguishing between the two is useful when dealing with
files which are preprocessed files or rewritten with -frewrite-includes
(so we don't, for example, print useless warnings).

llvm-svn: 188968
2013-08-22 00:27:10 +00:00
Nick Lewycky 1e43d9521f Fix the end sourcelocation of the call expression in a member access when
recovering by adding empty parenthesis. Fixes PR16676!

llvm-svn: 188920
2013-08-21 19:09:44 +00:00
Benjamin Kramer 90f5422954 Sema: Use the right type for PredefinedExpr when it's in a lambda.
1. We now print the return type of lambdas and return type deduced functions
as "auto". Trailing return types with decltype print the underlying type.
2. Use the lambda or block scope for the PredefinedExpr type instead of the
parent function. This fixes PR16946, a strange mismatch between type of the
expression and the actual result.
3. Verify the type in CodeGen.
4. The type for blocks is still wrong. They are numbered and the name is not
known until CodeGen.

llvm-svn: 188900
2013-08-21 11:45:27 +00:00
Richard Smith 3249fed9b2 If we find an error in the range expression in a range-based for loop, and the
loop variable has a type containing 'auto', set the declaration to be invalid
(because we couldn't deduce its type) to prevent follow-on errors.

llvm-svn: 188853
2013-08-21 01:40:36 +00:00
Richard Smith a6c8703e5b PR16727: don't try to evaluate a potentially value-dependent expression when
checking for missing parens in &&/|| expressions.

llvm-svn: 188716
2013-08-19 22:06:05 +00:00
Richard Smith f9b1510576 Refactor all diagnosing of TypoCorrections through a common function, in
preparation for teaching this function how to diagnose a correction that
includes importing a module.

llvm-svn: 188602
2013-08-17 00:46:16 +00:00
Rafael Espindola 87198cd35c Don't reject attribute used in an "extern const" variable definition.
Before this patch we would warn and drop the attribute in
extern const char test3[] __attribute__((used)) = "";

llvm-svn: 188588
2013-08-16 23:18:50 +00:00
DeLesley Hutchins d40542213c Thread safety analysis: new test case
llvm-svn: 188571
2013-08-16 18:28:00 +00:00