Commit Graph

933 Commits

Author SHA1 Message Date
Craig Topper e3d2ecbe86 Import MutableArrayRef into clang namespace.
llvm-svn: 211988
2014-06-28 23:22:33 +00:00
Craig Topper 00bbdcf9b3 Remove llvm:: from uses of ArrayRef.
llvm-svn: 211987
2014-06-28 23:22:23 +00:00
Nikola Smiljanic 03ff2596cb Refactoring. Remove Owned method from Sema.
llvm-svn: 209812
2014-05-29 14:05:12 +00:00
Nikola Smiljanic 01a7598561 Refactoring. Remove release and take methods from ActionResult. Rename takeAs to getAs.
llvm-svn: 209800
2014-05-29 10:55:11 +00:00
Craig Topper c3ec149bb2 [C++11] Use 'nullptr'. Sema edition.
llvm-svn: 209613
2014-05-26 06:22:03 +00:00
Richard Trieu 9098c9f1a8 Add hasSameType overload to ASTContext for Type pointers. Switch a type
comparison check to use this instead of calling Type::getCanonicalTypeInternal

llvm-svn: 209378
2014-05-22 01:39:16 +00:00
Richard Trieu 5fe0a42ae9 Fix diagnostic message for member function pointer mismatches where one of the
classes is a template argument.

llvm-svn: 209190
2014-05-20 04:10:24 +00:00
Richard Smith ec2748a8ad More fixes for isBetterOverloadCandidate not being a strict weak ordering. The
bug was obvious from inspection, figuring out a way to test it was... less so.

llvm-svn: 209060
2014-05-17 04:36:39 +00:00
Richard Smith 9516eee2f2 Switch to a more efficient expression of this check.
llvm-svn: 209055
2014-05-17 02:21:47 +00:00
Richard Smith 6fdeaabda9 Correct incoherent function versus function template partial ordering for conversion operators (the comparison could claim that two conversion operators are both better than each other). Actually implement DR495, rather than passing its test by chance because the declarations happened to be in the "lucky" order.
llvm-svn: 209054
2014-05-17 01:58:45 +00:00
Benjamin Kramer f3ca269839 Decouple ExprCXX.h and DeclCXX.h and clean up includes a bit.
Required pulling LambdaExpr::Capture into its own header.
No functionality change.

llvm-svn: 208470
2014-05-10 16:31:55 +00:00
Kaelyn Takata 50c4ffcca7 Try harder to ensure a strict weak ordering of overload candidates that
have arity mismatches.

llvm-svn: 208146
2014-05-07 00:43:38 +00:00
Nick Lewycky aa7168a215 Fix crash when one overload candidate is a template instead of a function. Patch by Kaelyn Takata.
Testcase coming out of creduce will land in a separate commit shortly.

Also, it appears that this callback is used even in a SFINAE context where the results are never displayed.

llvm-svn: 208062
2014-05-06 06:35:27 +00:00
Alp Toker b6cc592ea3 Fix a bunch of mislayered clang/Lex includes from Sema
llvm-svn: 207896
2014-05-03 03:45:55 +00:00
David Blaikie 8ad22e6a5c Use std::abs(int) portably.
Code review feedback from Reid Kleckner on r207806.

llvm-svn: 207811
2014-05-01 23:01:41 +00:00
David Blaikie 09acbf35e2 Fix some -Wabsolute-value warnings introduced in r207796.
llvm-svn: 207806
2014-05-01 22:23:56 +00:00
Kaelyn Takata b96b3be899 When sorting overload candidates, sort arity mismatches in ascending
order by the number of missing or extra parameters. This is useful if
there are more than a few overload candidates with arity mismatches,
particularly in the presence of -fshow-overloads=best.

llvm-svn: 207796
2014-05-01 21:15:24 +00:00
Richard Smith 100b24abc5 Implement [over.match.oper]p3 properly, by filtering the non-candidates out
when building the candidate set, rather than trying to contort name lookup into
handling this.

llvm-svn: 206436
2014-04-17 01:52:14 +00:00
Kaelyn Takata fb271f0cab Try harder about not suggesting methods as corrections when they
obviously won't work. Specifically, don't suggest methods (static or
not) from unrelated classes when the expression is a method call
through a specific object.

llvm-svn: 205653
2014-04-04 22:16:30 +00:00
Ted Kremenek 8d265c2633 Add defensive check that argument may be null in call to compareConversionFunctions() on incorrect code.
I'm looking into getting a reduced test case, but it's not
immediately available.

Fixes <rdar://problem/16344806>

llvm-svn: 205285
2014-04-01 07:23:18 +00:00
Craig Topper e14c0f8e73 [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203640
2014-03-12 04:55:44 +00:00
Ahmed Charles af94d56b56 [C++11] Remove the remaining uses of OwningPtr.
Replace OwningArrayPtr with std::unique_ptr<T[]>.

llvm-svn: 203388
2014-03-09 11:34:25 +00:00
Aaron Ballman e8a8baef44 [C++11] Replacing RecordDecl iterators field_begin() and field_end() with iterator_range fields(). Updating all of the usages of the iterators with range-based for loops.
llvm-svn: 203355
2014-03-08 20:12:42 +00:00
Kaelyn Uhrain b4b1475322 Don't suggest non-static methods as corrections when they obviously
won't work (i.e. when not doing a member lookup and not in a method from
the same class or a descendant class).

llvm-svn: 202520
2014-02-28 18:12:42 +00:00
Nick Lewycky b8336b7d13 Fix crash with enable_if on constructors.
llvm-svn: 202467
2014-02-28 05:26:13 +00:00
John McCall 9b595db16d Tighten lax vector-conversion rules and enforce them consistently.
When a lax conversion featured a vector and a non-vector, we were
only requiring the non-vector to be a scalar type, but really it
needs to be a real type (i.e. integral or real floating); it is
not reasonable to allow a pointer, member pointer, or complex
type here.

r198474 required lax conversions to match in "data size", i.e.
element size * element count, forbidding matches that happen
only because a vector is rounded up to the nearest power of two
in size.  Unfortunately, the erroneous logic was repeated in
several different places; unify them to use the new condition,
so that it triggers for arbitrary conversions and not just
those performed as part of binary operator checking.

rdar://15931426

llvm-svn: 200810
2014-02-04 23:58:19 +00:00
Argyrios Kyrtzidis 3e3305daba [Sema] Follow-up on r200521 for the -Wnon-literal-null-conversion warning and revert its behavior for C++.
llvm-svn: 200622
2014-02-02 05:26:43 +00:00
Argyrios Kyrtzidis 278c8d33e2 [Sema] For -Wnon-literal-null-conversion warning, look through integer casts, which are used
by some projects in their null macro.

rdar://15925483

llvm-svn: 200521
2014-01-31 07:51:32 +00:00
Alp Toker 314cc81b8c Rename getResultType() on function and method declarations to getReturnType()
A return type is the declared or deduced part of the function type specified in
the declaration.

A result type is the (potentially adjusted) type of the value of an expression
that calls the function.

Rule of thumb:

  * Declarations have return types and parameters.
  * Expressions have result types and arguments.

llvm-svn: 200082
2014-01-25 16:55:45 +00:00
Ismail Pazarbasi df1a280526 Added missing StandardConversionSequence initialization
This is the second msan failure where UserDefinedConversion does not initialize
its `Before` member as identity conversion.

llvm-svn: 199997
2014-01-24 13:16:17 +00:00
Ismail Pazarbasi 99afd96703 Initialize StandardConversionSequence correctly
MSAN detected a path that leaves DeprecatedStringLiteralToCharPtr uninitialized.
UserDefinedConversionSequence::First is a StandardConversionSequence that must
be initialized with setAsIdentityConversion.

llvm-svn: 199988
2014-01-24 10:54:12 +00:00
Alp Toker a2794f9f36 Introduce and use Decl::getAsFunction() to simplify templated function checks
Lift the getFunctionDecl() utility out of the parser into a general
Decl::getAsFunction() and use it to simplify other parts of the implementation.

Reduce isFunctionOrFunctionTemplate() to a simple type check that works the
same was as the other is* functions and move unwrapping of shadowed decls to
callers so it doesn't get run twice.

Shuffle around canSkipFunctionBody() to reduce virtual dispatch on ASTConsumer.
There's no need to query when we already know the body can't be skipped.

llvm-svn: 199794
2014-01-22 07:29:52 +00:00
Nick Lewycky d950ae74a3 Simplify expression, made possible by r199702.
llvm-svn: 199703
2014-01-21 01:30:30 +00:00
Alp Toker b3fd5cfa81 Update FunctionTypeLoc and related names to match r199686
llvm-svn: 199699
2014-01-21 00:32:38 +00:00
Alp Toker 9cacbabd33 Rename FunctionProtoType accessors from 'arguments' to 'parameters'
Fix a perennial source of confusion in the clang type system: Declarations and
function prototypes have parameters to which arguments are supplied, so calling
these 'arguments' was a stretch even in C mode, let alone C++ where default
arguments, templates and overloading make the distinction important to get
right.

Readability win across the board, especially in the casting, ADL and
overloading implementations which make a lot more sense at a glance now.

Will keep an eye on the builders and update dependent projects shortly.

No functional change.

llvm-svn: 199686
2014-01-20 20:26:09 +00:00
Ismail Pazarbasi 1121de36c2 Fix string-literal to char* conversion in overload resolution for C++11
String literal to char* conversion is deprecated in C++03, and is removed in
C++11. We still accept this conversion in C++11 mode as an extension, if we find
it in the best viable function.

llvm-svn: 199513
2014-01-17 21:08:52 +00:00
Alp Toker bfa3934f27 Rename language option MicrosoftMode to MSVCCompat
There's been long-standing confusion over the role of these two options. This
commit makes the necessary changes to differentiate them clearly, following up
from r198936.

MicrosoftExt (aka. fms-extensions):
 Enable largely unobjectionable Microsoft language extensions to ease
 portability. This mode, also supported by gcc, is used for building software
 like FreeBSD and Linux kernel extensions that share code with Windows drivers.

MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode):
 Turn on a special mode supporting 'heinous' extensions for drop-in
 compatibility with the Microsoft Visual C++ product. Standards-compilant C and
 C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt.

Note that full -fms-compatibility mode is currently enabled by default on the
Windows target, which may need tuning to serve as a reasonable default.

See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined
type_info out of InitializePredefinedMacros'

No change in behaviour.

llvm-svn: 199209
2014-01-14 12:51:41 +00:00
Nick Lewycky 35a6ef4c35 Add a new attribute 'enable_if' which can be used to control overload resolution based on the values of the function arguments at the call site.
llvm-svn: 198996
2014-01-11 02:50:57 +00:00
Fariborz Jahanian 381edf5759 ObjectiveC. Further improvements of use
of objc_bridge_related attribute; eliminate
unnecessary diagnostics which is issued elsewhere,
fixit now produces a valid AST tree per convention.
This results in some simplification in handling of
this attribute as well. // rdar://15499111

llvm-svn: 197436
2013-12-16 22:54:37 +00:00
Alp Toker 028ed91127 Fix code typos spotted while working on type traits
llvm-svn: 196587
2013-12-06 17:56:43 +00:00
Alp Toker d473363876 Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

llvm-svn: 196466
2013-12-05 04:47:09 +00:00
Richard Smith c156470be5 PR17533 and duplicates: don't compute the return type of an overloaded operator
until after we've referenced the operator; otherwise, we might pick up a
not-yet-deduced type.

llvm-svn: 194775
2013-11-15 02:58:23 +00:00
Richard Smith 16e1b07597 Rather than duplicating extension diagnostics to allow them to cause a
substitution failure, allow a flag to be set on the Diagnostic object,
to mark it as 'causes substitution failure'.

Refactor Diagnostic.td and the tablegen to use an enum for SFINAE behavior
rather than a bunch of flags.

llvm-svn: 194444
2013-11-12 02:41:45 +00:00
Douglas Gregor 9f2ed47133 s/DebugPrint/dump/g
llvm-svn: 194242
2013-11-08 02:16:10 +00:00
Douglas Gregor c9f019ab0f Objective-C++ ARC: Improve the conversion to a const __unsafe_unretained reference.
Under ARC++, a reference to a const Objective-C pointer is implicitly
treated as __unsafe_unretained, and can be initialized with (e.g.) a
__strong lvalue. Make sure this behavior does not break template
argument deduction and (related) that partial ordering still prefers a
'T* const&' template over a 'T const&' template when this case kicks
in. Fixes <rdar://problem/14467941>.

llvm-svn: 194239
2013-11-08 02:04:24 +00:00
Douglas Gregor 2ee1d99d00 Fix a bogus assert I introduced in r194224
llvm-svn: 194237
2013-11-08 01:20:25 +00:00
Douglas Gregor 4b60a1594d Re-instate contextual conversion to Objective-C pointers in message sends.
When performing an Objective-C message send to a value of class type,
perform a contextual conversion to an Objective-C pointer type. We've
had this for a long time, but it recently regressed. Fixes
<rdar://problem/15234703>.

llvm-svn: 194224
2013-11-07 22:34:54 +00:00
Richard Smith 8b86f2d401 Implement final resolution of DR1402: implicitly-declared move operators that
would be deleted are still declared, but are ignored by overload resolution.

Also, don't delete such members if a subobject has no corresponding move
operation and a non-trivial copy. This causes us to implicitly declare move
operations in more cases, but risks move-assigning virtual bases multiple
times in some circumstances (a warning for that is to follow).

llvm-svn: 193969
2013-11-04 01:48:18 +00:00
David Majnemer 42350dfcc8 Sema: Do not allow overloading between methods based on restrict
If the sole distinction between two declarations is that one has a
__restrict qualifier then we should not consider it to be an overload.

Instead, we will consider it as an incompatible redeclaration which is
similar to how MSVC, ICC and GCC would handle it.

This fixes PR17786.

N.B. We must not mangle in __restrict into method qualifiers becase we
don't allow overloading between such declarations anymore.  To do
otherwise would be a violation of the Itanium ABI.

llvm-svn: 193964
2013-11-03 23:51:28 +00:00
Alp Toker 67b47ac0a7 Fix crash in cleanup attr handling
ResolveSingleFunctionTemplateSpecialization() returns 0 and doesn't emit diags
unless the expression has template-ids, so we must null check the result.

Also add a better diag noting which overloads are causing the problem.

Reviewed by Aaron Ballman.

llvm-svn: 193055
2013-10-20 18:48:56 +00:00