summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExceptionSpec.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [Concepts] Requires ExpressionsSaar Raz2020-01-241-0/+1
| | | | | | | | | | Implement support for C++2a requires-expressions. Re-commit after compilation failure on some platforms due to alignment issues with PointerIntPair. Differential Revision: https://reviews.llvm.org/D50360 (cherry picked from commit a0f50d731639350c7a79f140f026c27a18215531)
* PR44514: Fix recovery from noexcept with non-convertible expressionsErich Keane2020-01-131-2/+10
| | | | | | | | | | | | We currently treat noexcept(not-convertible-to-bool) as 'none', which results in the typeloc info being a different size, and causing an assert later on in the process. In order to make recovery less destructive, replace this with noexcept(false) and a constructed 'false' expression. Bug Report: https://bugs.llvm.org/show_bug.cgi?id=44514 Differential Revision: https://reviews.llvm.org/D72621
* [c++20] Compute exception specifications for defaulted comparisons.Richard Smith2019-12-151-3/+13
| | | | | | | | 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.
* Properly compute whether statement expressions can throw, rather thanRichard Smith2019-12-151-60/+269
| | | | | | | | | conservatively assuming they always can. Also fix cases where we would not consider the computation of a VLA type when determining whether an expression can throw. We don't yet properly determine whether a VLA can throw, but no longer incorrectly claim it can never throw.
* SemaExceptionSpec - silence static analyzer getAs<> null dereference ↵Simon Pilgrim2019-10-211-4/+3
| | | | | | | | warnings. NFCI. The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 375440
* [c++20] Add CXXRewrittenBinaryOperator to represent a comparisonRichard Smith2019-10-191-0/+1
| | | | | | | | operator that is rewritten as a call to multiple other operators. No functionality change yet: nothing creates these expressions. llvm-svn: 375305
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-151-0/+1
| | | | | | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is refe$ D41217 on Phabricator. (recommit after fixing failing Parser test on windows) llvm-svn: 374903
* Revert 374882 "[Concepts] Concept Specialization Expressions"Nico Weber2019-10-151-1/+0
| | | | | | | | | | This reverts commit ec87b003823d63f3342cf648f55a134c1522e612. The test fails on Windows, see e.g. http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/11533/steps/stage%201%20check/logs/stdio Also revert follow-up r374893. llvm-svn: 374899
* [Concepts] Concept Specialization ExpressionsSaar Raz2019-10-151-0/+1
| | | | | | Part of C++20 Concepts implementation effort. Added Concept Specialization Expressions that are created when a concept is referenced with arguments, and tests thereof. llvm-svn: 374882
* Silence static analyzer getAs<RecordType> null dereference warnings. NFCI.Simon Pilgrim2019-10-031-1/+1
| | | | | | 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
* Move EH spec mismatches under -fms-compatibilityReid Kleckner2019-08-271-6/+6
| | | | | | | | | | | | | | | | | | | | | -fms-extensions is intended to enable conforming language extensions and -fms-compatibility is intended to language rule relaxations, so a user could plausibly compile with -fno-ms-compatibility on Windows while still using dllexport, for example. This exception specification validation behavior has been handled as a warning since before -fms-compatibility was added in 2011. I think it's just an oversight that it hasn't been moved yet. This will help users find conformance issues in their code such as those found in _com_ptr_t as described in https://llvm.org/PR42842. Reviewers: hans Subscribers: STL_MSFT, cfe-commits Differential Revision: https://reviews.llvm.org/D66770 llvm-svn: 370087
* [C++2a] Add __builtin_bit_cast, used to implement std::bit_castErik Pilkington2019-07-021-0/+1
| | | | | | | | | | | | | | | | | | This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a bit_cast from a value v to a type T. This expression can be evaluated at compile time under specific circumstances. The compile time evaluation currently doesn't support bit-fields, but I'm planning on fixing this in a follow up (some of the logic for figuring this out is in CodeGen). I'm also planning follow-ups for supporting some more esoteric types that the constexpr evaluator supports, as well as extending __builtin_memcpy constexpr evaluation to use the same infrastructure. rdar://44987528 Differential revision: https://reviews.llvm.org/D62825 llvm-svn: 364954
* Permit Exception Spec mismatch with NoThrow on inherited VirtualErich Keane2019-06-031-3/+15
| | | | | | | | | As reported here: https://bugs.llvm.org/show_bug.cgi?id=42100 This fairly common pattern ends up being an error in MinGW, so relax it in all cases to a warning. llvm-svn: 362434
* Replace 'default' in an enum-over-a-switch with the missing list.Erich Keane2019-05-311-1/+5
| | | | | | | This suppressed the Wswitch warning causing me to miss it and write an assertion failure. llvm-svn: 362245
* Fix for PR42089, regression from r362119Erich Keane2019-05-311-1/+8
| | | | | | | | | The implementation of the NoThrow ExceptionSpecificationType missed a switch statement for forming the diagnostic when an out-of-line member redeclaration misses the exception specification. This patch adds the correct case statement. llvm-svn: 362225
* Implement __builtin_LINE() et. al. to support source location capture.Eric Fiselier2019-05-161-0/+1
| | | | | | | | | | | | | | | | | Summary: This patch implements the source location builtins `__builtin_LINE(), `__builtin_FUNCTION()`, `__builtin_FILE()` and `__builtin_COLUMN()`. These builtins are needed to implement [`std::experimental::source_location`](https://rawgit.com/cplusplus/fundamentals-ts/v2/main.html#reflection.src_loc.creation). With the exception of `__builtin_COLUMN`, GCC also implements these builtins, and Clangs behavior is intended to match as closely as possible. Reviewers: rsmith, joerg, aaron.ballman, bogner, majnemer, shafik, martong Reviewed By: rsmith Subscribers: rnkovacs, loskutov, riccibruno, mgorny, kunitoki, alexr, majnemer, hfinkel, cfe-commits Differential Revision: https://reviews.llvm.org/D37035 llvm-svn: 360937
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Create ConstantExpr classBill Wendling2018-10-311-0/+3
| | | | | | | | | | | | | | | | A ConstantExpr class represents a full expression that's in a context where a constant expression is required. This class reflects the path the evaluator took to reach the expression rather than the syntactic context in which the expression occurs. In the future, the class will be expanded to cache the result of the evaluated expression so that it's not needlessly re-evaluated Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D53475 llvm-svn: 345692
* Remove unnecessary semicolon to silence -Wpedantic warning. NFCI.Simon Pilgrim2018-09-061-1/+1
| | | | llvm-svn: 341556
* PR38627: Fix handling of exception specification adjustment forRichard Smith2018-09-051-17/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | destructors. We previously tried to patch up the exception specification after completing the class, which went wrong when the exception specification was needed within the class body (in particular, by a friend redeclaration of the destructor in a nested class). We now mark the destructor as having a not-yet-computed exception specification immediately after creating it. This requires delaying various checks against the exception specification (where we'd previously have just got the wrong exception specification, and now find we have an exception specification that we can't compute yet) when those checks fire while the class is being defined. This also exposed an issue that we were missing a CodeSynthesisContext for computation of exception specifications (otherwise we'd fail to make the module containing the definition of the class visible when computing its members' exception specs). Adding that incidentally also gives us a diagnostic quality improvement. This has also exposed an pre-existing problem: making the exception specification evaluation context a non-SFINAE context (as it should be) results in a bootstrap failure; PR38850 filed for this. llvm-svn: 341499
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-2/+2
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* PR38141: check whether noexcept-specifications are equivalent in redeclarationsRichard Smith2018-07-121-4/+10
| | | | llvm-svn: 336946
* [Fixed Point Arithmetic] Fixed Point Precision Bits and Fixed Point LiteralsLeonard Chan2018-06-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This diff includes the logic for setting the precision bits for each primary fixed point type in the target info and logic for initializing a fixed point literal. Fixed point literals are declared using the suffixes ``` hr: short _Fract uhr: unsigned short _Fract r: _Fract ur: unsigned _Fract lr: long _Fract ulr: unsigned long _Fract hk: short _Accum uhk: unsigned short _Accum k: _Accum uk: unsigned _Accum ``` Errors are also thrown for illegal literal values ``` unsigned short _Accum u_short_accum = 256.0uhk; // expected-error{{the integral part of this literal is too large for this unsigned _Accum type}} ``` Differential Revision: https://reviews.llvm.org/D46915 llvm-svn: 335148
* Track the result of evaluating a computed noexcept specification on theRichard Smith2018-05-031-142/+106
| | | | | | | | | | | | | | FunctionProtoType. We previously re-evaluated the expression each time we wanted to know whether the type is noexcept or not. We now evaluate the expression exactly once. This is not quite "no functional change": it fixes a crasher bug during AST deserialization where we would try to evaluate the noexcept specification in a situation where we have not deserialized sufficient portions of the AST to permit such evaluation. llvm-svn: 331428
* Remove redundant casts. NFCGeorge Burgess IV2018-03-011-2/+2
| | | | | | | | | | | | | | | | | | | So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and `dyn_cast`s for fun. This is a portion of what it found for clang; I plan to do similar cleanups in LLVM and other subprojects when I find time. Because of the volume of changes, I explicitly avoided making any change that wasn't highly local and obviously correct to me (e.g. we still have a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading is a thing and the cast<Bar> did actually change the type -- just up the class hierarchy). I also tried to leave the types we were cast<>ing to somewhere nearby, in cases where it wasn't locally obvious what we were dealing with before. llvm-svn: 326416
* DR126: partially implement the const-correct rules for exception handler ↵Richard Smith2018-01-131-64/+96
| | | | | | | | | matching. While here, fix up the myriad other ways in which Sema's two "can this handler catch that exception?" implementations get things wrong and unify them. llvm-svn: 322431
* Now that C++17 is official (https://www.iso.org/standard/68564.html), start ↵Aaron Ballman2017-12-041-7/+7
| | | | | | changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. llvm-svn: 319688
* [coroutines] Add DependentCoawaitExpr and fix re-building CoroutineBodyStmt.Eric Fiselier2017-03-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The changes contained in this patch are: 1. Defines a new AST node `CoawaitDependentExpr` for representing co_await expressions while the promise type is still dependent. 2. Correctly detect and transform the 'co_await' operand to `p.await_transform(<expr>)` when possible. 3. Change the initial/final suspend points to build during the initial parse, so they have the correct operator co_await lookup results. 4. Fix transformation of the CoroutineBodyStmt so that it doesn't re-build the final/initial suspends. @rsmith: This change is a little big, but it's not trivial for me to split it up. Please let me know if you would prefer this submitted as multiple patches. Reviewers: rsmith, GorNishanov Reviewed By: rsmith Subscribers: ABataev, rsmith, mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D26057 llvm-svn: 297093
* Fix completely bogus types for some builtins:Richard Smith2016-12-191-6/+7
| | | | | | | | | | | | | | | | | | | | | * In C++, never create a FunctionNoProtoType for a builtin (fixes C++1z crasher from r289754). * Fix type of __sync_synchronize to be a no-parameter function rather than a varargs function. This matches GCC. * Fix type of vfprintf to match its actual type. We gave it a wrong type due to PR4290 (apparently autoconf generates invalid code and expects compilers to choke it down or it miscompiles the program; the relevant error in clang was downgraded to a warning in r122744 to fix other occurrences of this autoconf brokenness, so we don't need this workaround any more). * Turn off vararg argument checking for __noop, since it's not *really* a varargs function. Alternatively we could add custom type checking for it and synthesize parameter types matching the actual arguments in each call, but that seemed like overkill. llvm-svn: 290146
* Add two new AST nodes to represent initialization of an array in terms ofRichard Smith2016-12-121-0/+2
| | | | | | | | | | | | | | | | | | | | initialization of each array element: * ArrayInitLoopExpr is a prvalue of array type with two subexpressions: a common expression (an OpaqueValueExpr) that represents the up-front computation of the source of the initialization, and a subexpression representing a per-element initializer * ArrayInitIndexExpr is a prvalue of type size_t representing the current position in the loop This will be used to replace the creation of explicit index variables in lambda capture of arrays and copy/move construction of classes with array elements, and also C++17 structured bindings of arrays by value (which inexplicably allow copying an array by value, unlike all of C++'s other array declarations). No uses of these nodes are introduced by this change, however. llvm-svn: 289413
* PR31244: Use the exception specification from the callee's type directly toRichard Smith2016-12-031-17/+28
| | | | | | | compute whether a call is noexcept, even if we can't map the callee expression to a called declaration. llvm-svn: 288558
* [c++1z] Improve support for -fno-exceptions: we can't just ignore exceptionRichard Smith2016-11-301-32/+55
| | | | | | | | | specifications in this mode in C++17, since they're part of the function type, so check and diagnose them like we would if exceptions were enabled. Better ideas welcome. llvm-svn: 288220
* [c++1z] P0012R1: Implement a few remaining pieces: downgrade diagnostic forRichard Smith2016-10-221-22/+50
| | | | | | | | | | | | | | mismatched dynamic exception specifications in expressions from an error to a warning, since this is no longer ill-formed in C++1z. Allow reference binding of a reference-to-non-noexcept function to a noexcept function lvalue. As defect resolutions, also allow a conditional between noexcept and non-noexcept function lvalues to produce a non-noexcept function lvalue (rather than decaying to a function pointer), and allow function template argument deduction to deduce a reference to non-noexcept function when binding to a noexcept function type. llvm-svn: 284905
* Extend hack to work around bad exception specifications for 'swap' members toRichard Smith2016-10-191-8/+21
| | | | | | also cover libstdc++'s std::__debug::array and std::__profile::array. llvm-svn: 284669
* P0012R1: Make exception specifications be part of the type system. ThisRichard Smith2016-10-161-0/+5
| | | | | | | implements the bulk of the change (modifying the type system to include exception specifications), but not all the details just yet. llvm-svn: 284337
* Don't diagnoes a mismatch between implicit and explicit exceptionRichard Smith2016-08-311-1/+1
| | | | | | | specifications under -fno-exceptions, just as we don't diagnose other exception specification mismatch errors. llvm-svn: 280289
* PR28423: Compare primary declaration contexts.Vassil Vassilev2016-08-201-1/+2
| | | | | | | | | | | In certain cases (mostly coming from modules), Sema's idea of the StdNamespace does not point to the first declaration of namespace std. Patch by Cristina Cristescu! Reviewed by Richard Smith. llvm-svn: 279371
* [ObjC] Implement @available in the Parser and ASTErik Pilkington2016-07-161-0/+1
| | | | | | | | | | | | | | | | This patch adds a new AST node: ObjCAvailabilityCheckExpr, and teaches the Parser and Sema to generate it. This node represents an availability check of the form: @available(macos 10.10, *); Which will eventually compile to a runtime check of the host's OS version. This is the first patch of the feature I proposed here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/049851.html Differential Revision: https://reviews.llvm.org/D22171 llvm-svn: 275654
* P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991:Richard Smith2016-06-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace inheriting constructors implementation with new approach, voted into C++ last year as a DR against C++11. Instead of synthesizing a set of derived class constructors for each inherited base class constructor, we make the constructors of the base class visible to constructor lookup in the derived class, using the normal rules for using-declarations. For constructors, UsingShadowDecl now has a ConstructorUsingShadowDecl derived class that tracks the requisite additional information. We create shadow constructors (not found by name lookup) in the derived class to model the actual initialization, and have a new expression node, CXXInheritedCtorInitExpr, to model the initialization of a base class from such a constructor. (This initialization is special because it performs real perfect forwarding of arguments.) In cases where argument forwarding is not possible (for inalloca calls, variadic calls, and calls with callee parameter cleanup), the shadow inheriting constructor is not emitted and instead we directly emit the initialization code into the caller of the inherited constructor. Note that this new model is not perfectly compatible with the old model in some corner cases. In particular: * if B inherits a private constructor from A, and C uses that constructor to construct a B, then we previously required that A befriends B and B befriends C, but the new rules require A to befriend C directly, and * if a derived class has its own constructors (and so its implicit default constructor is suppressed), it may still inherit a default constructor from a base class llvm-svn: 274049
* [Sema] Return an appropriate result from CheckSpecifiedExceptionTypeDavid Majnemer2016-06-111-2/+5
| | | | | | | | We shouldn't return true from CheckSpecifiedExceptionType if the record type is incomplete and -fms-extensions is engaged. Otherwise we will have an incomplete AST. llvm-svn: 272447
* [-fms-extensions] Permit incomplete types in dynamic exception specificationsDavid Majnemer2016-06-101-2/+5
| | | | | | | | | | Microsoft headers, comdef.h and comutil.h, assume that this is an OK thing to do. Downgrade the hard error to a warning if we are in -fms-extensions mode. This fixes PR28080. llvm-svn: 272412
* Wire a SourceLocation into IsDerivedFrom and move the RequireCompleteType callRichard Smith2015-12-181-1/+1
| | | | | | | | for the derived class into it. This is mostly just a cleanup, but could in principle be a bugfix if there is some codepath that reaches here and didn't previously require a complete type (I couldn't find any such codepath, though). llvm-svn: 256037
* [MSVC] 'property' with an empty array in array subscript expression.Alexey Bataev2015-11-251-0/+1
| | | | | | | | | | | | MSVC supports 'property' attribute and allows to apply it to the declaration of an empty array in a class or structure definition. For example: ``` __declspec(property(get=GetX, put=PutX)) int x[]; ``` The above statement indicates that x[] can be used with one or more array indices. In this case, i=p->x[a][b] will be turned into i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i); Differential Revision: http://reviews.llvm.org/D13336 llvm-svn: 254067
* [coroutines] Creation of promise object, lookup of operator co_await, buildingRichard Smith2015-10-271-0/+2
| | | | | | of await_* calls, and AST representation for same. llvm-svn: 251387
* [-fms-extensions] Allow missing exception specifications in redeclarations ↵David Majnemer2015-10-201-4/+8
| | | | | | | | | | | as an extension Microsoft's ATL headers make use of this MSVC extension, add support for it and issue a diagnostic under -Wmicrosoft-exception-spec. This fixes PR25265. llvm-svn: 250854
* SourceRanges are small and trivially copyable, don't them by reference.Craig Topper2015-10-041-1/+1
| | | | llvm-svn: 249259
* Replace double negation of !FileID.isInvalid() with FileID.isValid().Yaron Keren2015-10-031-2/+2
| | | | | | +couple more of double-negated !SourceLocation.isInvalid() unfixed in r249228. llvm-svn: 249235
* Promote a warning on ill-formed code (redeclaration missing an exceptionRichard Smith2015-09-301-15/+31
| | | | | | | | | | | | | | | | | specification) to an error. No compiler other than Clang seems to allow this, and it doesn't seem like a useful thing to accept as an extension in general. The current behavior was added for PR5957, where the problem was specifically related to mismatches of the exception specification on the implicitly-declared global operator new and delete. To retain that workaround, we downgrade the error to an ExtWarn when the declaration is of a replaceable global allocation function. Now that this is an error, stop trying (and failing) to recover from a missing computed noexcept specification. That recovery didn't work, and led to crashes in code like the added testcase. llvm-svn: 248867
* [OPENMP 4.0] Initial support for array sections.Alexey Bataev2015-08-251-0/+1
| | | | | | | | Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0). Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions. Differential Revision: http://reviews.llvm.org/D10732 llvm-svn: 245937
OpenPOWER on IntegriCloud