summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix "pointer is null" static analyzer warnings. NFCI.Simon Pilgrim2020-01-141-20/+17
| | | | Use castAs<> instead of getAs<> since the pointer is dereferenced immediately in all cases and castAs will perform the null assertion for us.
* [Concepts] Function trailing requires clausesSaar Raz2020-01-091-1/+27
| | | | | | Function trailing requires clauses now parsed, supported in overload resolution and when calling, referencing and taking the address of functions or function templates. Differential Revision: https://reviews.llvm.org/D43357
* [c++20] Compute exception specifications for defaulted comparisons.Richard Smith2019-12-151-53/+106
| | | | | | | | This requires us to essentially fully form the body of the defaulted comparison, but from an unevaluated context. Naively this would require generating the function definition twice; instead, we ensure that the function body is implicitly defined before performing the check, and walk the actual body where possible.
* [c++20] Improve phrasing of diagnostic for missing #include <compare>.Richard Smith2019-12-131-4/+7
|
* Suppress false-positive -Wuninitialized warnings in the constructor of aRichard Smith2019-12-111-1/+1
| | | | templated but non-template class.
* [c++20] Implement P1946R0: allow defaulted comparisons to take theirRichard Smith2019-12-101-6/+25
| | | | arguments by value.
* [c++20] Delete defaulted comparison functions if they would invoke anRichard Smith2019-12-101-2/+26
| | | | inaccessible comparison function.
* [c++20] Implement P1185R2 (as modified by P2002R0).Richard Smith2019-12-101-33/+107
| | | | | | For each defaulted operator<=> in a class that doesn't explicitly declare any operator==, also inject a matching implicit defaulted operator==.
* [c++20] Return type deduction for defaulted three-way comparisons.Richard Smith2019-12-101-7/+64
|
* [c++20] Fix handling of unqualified lookups from a defaulted comparisonRichard Smith2019-12-091-33/+97
| | | | | | | | | | function. We need to perform unqualified lookups from the context of a defaulted comparison, but not until we implicitly define the function, at which point we can't do those lookups any more. So perform the lookup from the end of the class containing the =default declaration and store the lookup results on the defaulted function until we synthesize the body.
* [c++20] Defaulted comparison support for array members.Richard Smith2019-12-091-10/+131
|
* [c++20] Fix incorrect assumptions in checks for comparison category types.Richard Smith2019-12-091-19/+26
| | | | | | In the presence of modules, we can have multiple lookup results for the same entity, and we need to re-check for completeness each time we consider a type.
* Fix clang -Wcovered-switch-default after llvmorg-10-init-11484-g6626e5a06a9Fangrui Song2019-12-091-2/+2
| | | | | We need to place llvm_unreachable after switch to work around the GCC warning.
* Fix compilation warning from GCC7. NFC.Michael Liao2019-12-091-0/+2
|
* [c++20] Synthesis of defaulted comparison functions.Richard Smith2019-12-081-19/+322
| | | | | | Array members are not yet handled. In addition, defaulted comparisons can't yet find comparison operators by unqualified lookup (only by member lookup and ADL). These issues will be fixed in follow-on changes.
* [c++20] Determine whether a defaulted comparison should be deleted orRichard Smith2019-12-061-77/+473
| | | | constexpr.
* [Concepts] Constraint Enforcement & DiagnosticsSaar Raz2019-12-061-2/+10
| | | | | | | | | Part of the C++20 concepts implementation effort. - Associated constraints (requires clauses, currently) are now enforced when instantiating/specializing templates and when considering partial specializations and function overloads. - Elaborated diagnostics give helpful insight as to why the constraints were not satisfied. Phabricator: D41569 Re-commit, after fixing some memory bugs.
* Actually delay processing DelayedDllExportClasses until the outermost class ↵Hans Wennborg2019-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | is finished (PR40006) This was already the intention of DelayedDllExportClasses, but code such as this would break it: template<typename> struct Tmpl {}; struct Outer { struct Inner { __declspec(dllexport) Inner() = default; unsigned int x = 0; }; Tmpl<Inner> y; }; ActOnFinishCXXNonNestedClass() would get called when the instantiation of Templ<Inner> is finished, even though the compiler is still not finished with Outer, causing the compile fail. This hooks into Sema::{Push,Pop}ParsingClass() to avoid calling ActOnFinishCXXNonNestedClass() for template instantiations while a class is being parsed. Differential revision: https://reviews.llvm.org/D70905
* [OpenCL] Use generic addr space for lambda call operatorAnastasia Stulova2019-12-031-12/+15
| | | | | | | | | | | | | | | Since lambdas are represented by callable objects, we add generic addr space for implicit object parameter in call operator. Any lambda variable declared in __constant addr space (which is not convertible to generic) fails to compile with a diagnostic. To support constant addr space we need to add a way to qualify the lambda call operators. Tags: #clang Differential Revision: https://reviews.llvm.org/D69938
* Partially reland "[Diagnostics] Put "deprecated copy" warnings into ↵Dávid Bolvanský2019-11-261-5/+5
| | | | | | -Wdeprecated-copy"" But do not enable it under -Wextra until libcxx issue is solved.
* Revert "[Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy"Tom Stellard2019-11-251-4/+3
| | | | | | This reverts commit 9353c5dd0664ea444236e527bf93566e11dc34df. This commit introduced bot falures for multi-stage bots with -Werror.
* [Diagnostics] Make behaviour of Clang's -Wdeprecated-copy same as in GCCDávid Bolvanský2019-11-231-2/+3
| | | | Do not warn for functions that are explicitly marked delete or default, which follows the behavior of the GCC warning.
* [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copyDávid Bolvanský2019-11-221-3/+4
| | | | | | | | | | | | | | | | | Summary: GCC 9 added -Wdeprecated-copy (as part of -Wextra). This diagnostic is already implemented in Clang too, just hidden under -Wdeprecated (not on by default). This patch adds -Wdeprecated-copy and makes it compatible with GCC 9+. This diagnostic is heavily tested in deprecated.cpp, so I added simple tests just to check we warn when new flag/-Wextra is enabled. Reviewers: rsmith, dblaikie Reviewed By: dblaikie Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70342
* [DeclCXX] Remove unknown external linkage specificationsEhud Katz2019-11-211-4/+0
| | | | | | | | | | | | | | | | Partial revert of r372681 "Support for DWARF-5 C++ language tags". The change introduced new external linkage languages ("C++11" and "C++14") which not supported in C++. It also changed the definition of the existing enum to use the DWARF constants. The problem is that "LinkageSpecDeclBits.Language" (the field that reserves this enum) is actually defined as 3 bits length (bitfield), which cannot contain the new DWARF constants. Defining the enum as integer literals is more appropriate for maintaining valid values. Differential Revision: https://reviews.llvm.org/D69935
* Revert "[Concepts] Constraint Enforcement & Diagnostics"Vlad Tsyrklevich2019-10-281-10/+2
| | | | | This reverts commit ffa214ef22892d75340dc6720271863901dc2c90, it was causing ASAN test failures on sanitizer-x86_64-linux-bootstrap.
* [c++20] Enforce rule that a union-like class or class with referenceRichard Smith2019-10-271-3/+36
| | | | members cannot have defaulted comparisons.
* [Concepts] Constraint Enforcement & DiagnosticsSaar Raz2019-10-251-2/+10
| | | | | | Part of the C++20 concepts implementation effort. - Associated constraints (requires clauses, currently) are now enforced when instantiating/specializing templates and when considering partial specializations and function overloads. - Elaborated diagnostics give helpful insight as to why the constraints were not satisfied. Phabricator: D41569
* [c++2a] Allow comparison functions to be explicitly defaulted.Richard Smith2019-10-221-43/+242
| | | | | | This adds some initial syntactic checking that only the appropriate function signatures can be defaulted. No implicit definitions are generated yet.
* [c++20] Implement most of P1152R4.Richard Smith2019-10-091-0/+7
| | | | | | | | | | | | | | Diagnose some now-deprecated uses of volatile types: * as function parameter types and return types * as the type of a structured binding declaration * as the type of the lvalue operand of an increment / decrement / compound assignment operator This does not implement a check for the deprecation of simple assignments whose results are used; that check requires somewhat more complexity and will be addressed separately. llvm-svn: 374133
* Silence static analyzer getAs<RecordType> null dereference warnings. NFCI.Simon Pilgrim2019-10-031-5/+6
| | | | | | The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<RecordType> directly and if not assert will fire for us. llvm-svn: 373584
* Don't crash if a variable with a constexpr destructor has aRichard Smith2019-09-291-1/+2
| | | | | | value-dependent initializer. llvm-svn: 373173
* For P0784R7: compute whether a variable has constant destruction if itRichard Smith2019-09-291-0/+13
| | | | | | | | | | has a constexpr destructor. For constexpr variables, reject if the variable does not have constant destruction. In all cases, do not emit runtime calls to the destructor for variables with constant destruction. llvm-svn: 373159
* For P0784R7: Add support for dynamic allocation with new / delete duringRichard Smith2019-09-271-0/+6
| | | | | | constant evaluation. llvm-svn: 373036
* Support for DWARF-5 C++ language tags.Adrian Prantl2019-09-241-0/+4
| | | | | | | | | | | | This patch provides support for DW_LANG_C_plus_plus_11, DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend. Patch by Sourabh Singh Tomar! Differential Revision: https://reviews.llvm.org/D67613 Reapplies r372663 after adapting a failing test in the LLDB testsuite. llvm-svn: 372681
* Revert "Support for DWARF-5 C++ language tags."Jonas Devlieghere2019-09-231-4/+0
| | | | | | This reverts commit bf9c8ffb54943c6d77398adbedddf05ef9724007. llvm-svn: 372672
* Support for DWARF-5 C++ language tags.Adrian Prantl2019-09-231-0/+4
| | | | | | | | | | This patch provides support for DW_LANG_C_plus_plus_11, DW_LANG_C_plus_plus_14 tags in the Clang C++ frontend. Patch by Sourabh Singh Tomar! Differential Revision: https://reviews.llvm.org/D67613 llvm-svn: 372663
* For P0784R7: add support for constexpr destructors, and call them asRichard Smith2019-09-231-9/+61
| | | | | | | | | | | appropriate during constant evaluation. Note that the evaluator is sometimes invoked on incomplete expressions. In such cases, if an object is constructed but we never reach the point where it would be destroyed (and it has non-trivial destruction), we treat the expression as having an unmodeled side-effect. llvm-svn: 372538
* Finish building the full-expression for a static_assert expressionRichard Smith2019-09-201-9/+18
| | | | | | | | | | | | | | before evaluating it rather than afterwards. This is groundwork for C++20's P0784R7, where non-trivial destructors can be constexpr, so we need ExprWithCleanups markers in constant expressions. No significant functionality change intended (though this fixes a bug only visible through libclang / -ast-dump / tooling: we now store the converted condition on the StaticAssertDecl rather than the original). llvm-svn: 372368
* [c++20] P1331R2: Allow transient use of uninitialized objects inRichard Smith2019-09-181-11/+30
| | | | | | constant evaluation. llvm-svn: 372237
* [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.Erich Keane2019-09-131-12/+10
| | | | | | | | | | | | In order to enable future improvements to our attribute diagnostics, this moves info from ParsedAttr into CommonAttributeInfo, then makes this type the base of the *Attr and ParsedAttr types. Quite a bit of refactoring took place, including removing a bunch of redundant Spelling Index propogation. Differential Revision: https://reviews.llvm.org/D67368 llvm-svn: 371875
* Fixit for -Wfinal-dtor-non-final-classDavid Bolvansky2019-09-031-1/+0
| | | | llvm-svn: 370740
* Added fixit notes for -Wfinal-dtor-non-final-classDavid Bolvansky2019-09-031-4/+8
| | | | llvm-svn: 370737
* [clang] Warning for non-final classes with final destructorsDavid Bolvansky2019-08-311-0/+13
| | | | | | | | | | | | Marking a class' destructor final prevents the class from being inherited from. However, it is a subtle and awkward way to express that at best, and unintended at worst. It may also generate worse code (in other compilers) than marking the class itself final. For these reasons, this revision adds a warning for nonfinal classes with final destructors, with a note to suggest marking the class final to silence the warning. See https://reviews.llvm.org/D66621 for more background. Patch by logan-5 (Logan Smith) Differential Revision: https://reviews.llvm.org/D66711 llvm-svn: 370594
* PR40674: fix assertion failure if a structured binding declaration has aRichard Smith2019-08-241-1/+2
| | | | | | | tuple-like decomposition that produces value-dependent reference bindings. llvm-svn: 369829
* Implement P1668R1Erich Keane2019-08-191-0/+3
| | | | | | | Allow inline assembly statements in unexecuted branches of constexpr functions. llvm-svn: 369281
* [SemaDeclCXX] Allow inheriting constructor declaration to specify a ↵Tan S. B.2019-08-171-1/+2
| | | | | | | | cv-qualified type Differential Revision: https://reviews.llvm.org/D47419 llvm-svn: 369196
* [Sema] Implement DR2386 for C++17 structured bindingReid Kleckner2019-08-151-7/+4
| | | | | | | | | | | | | | | | | | Allow implementations to provide complete definitions of std::tuple_size<T>, but to omit the 'value' member to signal that T is not tuple-like. The Microsoft standard library implements std::tuple_size<const T> this way. If the value member exists, clang still validates that it is an ICE, but if it does not, then the type is considered to not be tuple-like. Fixes PR33236 Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D66040 llvm-svn: 369043
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-3/+3
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368942
* Don't try emitting dllexported explicitly defaulted non-trivial ctors twice ↵Hans Wennborg2019-08-021-1/+7
| | | | | | | | | | during explicit template instantiation definition (PR42857) Trying to emit the definition twice triggers an assert. Differential revision: https://reviews.llvm.org/D65579 llvm-svn: 367661
* Delay emitting dllexport explicitly defaulted members until the class is ↵Hans Wennborg2019-08-011-2/+11
| | | | | | | | | | | | | | | | | | | | fully parsed (PR40006) This is similar to r245139, but that only addressed dllexported classes. It was still possible to run into the same problem with dllexported members in an otherwise normal class (see bug). This uses the same strategy to fix: delay defining the method until the whole class has been parsed. (The easiest way to see the ordering problem is in Parser::ParseCXXMemberSpecification(): it calls ParseLexedMemberInitializers() *after* ActOnFinishCXXMemberDecls(), which was trying to define the dllexport method. Now we delay it to ActOnFinishCXXNonNestedClass() which is called after both of those.) Differential revision: https://reviews.llvm.org/D65511 llvm-svn: 367520
OpenPOWER on IntegriCloud