summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
Commit message (Collapse)AuthorAgeFilesLines
...
* [c++20] Implement P1009R2: allow omitting the array bound in an arrayRichard Smith2019-05-061-2/+22
| | | | | | | | | | new expression. This was voted into C++20 as a defect report resolution, so we retroactively apply it to all prior language modes (though it can never actually be used before C++11 mode). llvm-svn: 360006
* Revert rL359962 : Use DiagRuntimeBehavior for -Wunsequenced to weed out ↵Simon Pilgrim2019-05-051-2/+2
| | | | | | | | | | false positives where either the modification or the other access is unreachable. ........ Try to fix buildbots llvm-svn: 359984
* [C++] Interpret unknown identifier in parameter clause as unknown typeNicolas Lesser2019-05-051-3/+1
| | | | | | instead of as parameter name without a type. llvm-svn: 359979
* [c++20] Implement P0428R2 - Familiar template syntax for generic lambdasHamza Sood2019-05-041-0/+45
| | | | | | Differential Revision: https://reviews.llvm.org/D36527 llvm-svn: 359967
* Use DiagRuntimeBehavior for -Wunsequenced to weed out false positivesRichard Smith2019-05-041-2/+2
| | | | | | where either the modification or the other access is unreachable. llvm-svn: 359962
* Disallow the operand of __builtin_constant_p from modifying enclosingRichard Smith2019-05-041-0/+71
| | | | | | | | | | | | | | state when it's encountered while evaluating a constexpr function. We attempt to follow GCC trunk's behavior here, but it is somewhat inscrutible, so our behavior is only approximately the same for now. Specifically, we only permit modification of objects whose lifetime began within the operand of the __builtin_constant_p. GCC appears to have effectively the same restriction, but also some unknown restriction based on where and how the local state of the constexpr function is mentioned within the operand (see added testcases). llvm-svn: 359958
* [clang] adding explicit(bool) from c++2aNicolas Lesser2019-05-044-3/+746
| | | | | | | | | | | | | | | | | | | | | this patch adds support for the explicit bool specifier. Changes: - The parsing for the explicit(bool) specifier was added in ParseDecl.cpp. - The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class. - Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted. - Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration. - The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected. - Test for Semantic and Serialization were added. This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback. Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky. Patch by Tyker Differential Revision: https://reviews.llvm.org/D60934 llvm-svn: 359949
* Revert r359814 "[Sema] Emit warning for visibility attribute on ↵Nico Weber2019-05-032-6/+2
| | | | | | | | internal-linkage declaration" See cfe-commits thread for r359814. llvm-svn: 359858
* SemaOverload: Complete candidates before emitting the error, to ensure ↵David Blaikie2019-05-031-0/+35
| | | | | | | | | | | | | | | | | diagnostics emitted (or suppressed) during completion don't interfere with the overload notes Because diagnostics and their notes are not connected at the API level, if the error message for an overload is emitted, then the overload candidates are completed - if a diagnostic is emitted during that work, the notes related to overload candidates would be attached to the latter diagnostic, not the original error. Sort of worse, if the latter diagnostic was disabled, the notes are disabled. Reviewers: rsmith Differential Revision: https://reviews.llvm.org/D61357 llvm-svn: 359854
* [Sema] Emit warning for visibility attribute on internal-linkage declarationScott Linder2019-05-022-2/+6
| | | | | | | | GCC warns on these cases, but we currently just silently ignore the attribute. Differential Revision: https://reviews.llvm.org/D61097 llvm-svn: 359814
* Diagnose non-dependent qualified friend function template declarationsRichard Smith2019-05-022-10/+21
| | | | | | | that don't match any existing declaration. Don't get confused and treat such declarations as template *specializations*. llvm-svn: 359746
* [Parser] Avoid correcting delayed typos in array subscript multiple times.Volodymyr Sapsai2019-05-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | We correct some typos in `ActOnArraySubscriptExpr` and `ActOnOMPArraySectionExpr`, so when their result is `ExprError`, we can end up correcting delayed typos in the same expressions again. In general it is OK but when `NumTypos` is incorrect, we can hit the assertion > Assertion failed: (Entry != DelayedTypos.end() && "Failed to get the state for a TypoExpr!"), function getTypoExprState, file clang/lib/Sema/SemaLookup.cpp, line 5219. Fix by replacing some subscript `ExprResult` with typo-corrected expressions instead of keeping the original expressions. Thus if original expressions contained `TypoExpr`, we'll use corrected expressions instead of trying to correct them again. rdar://problem/47403222 Reviewers: rsmith, erik.pilkington, majnemer Reviewed By: erik.pilkington Subscribers: jkorous, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D60848 llvm-svn: 359713
* [Diagnostics] Support -Wtype-limits for GCC compatibilityDavid Bolvansky2019-04-291-0/+1
| | | | | | | | | | | | | | | | | | Summary: GCC's -Wtype-limits (part of -Wextra): Warn if a comparison is always true or always false due to the limited range of the data type Reviewers: rsmith, aaron.ballman, lebedev.ri, thakis Reviewed By: rsmith Subscribers: lebedev.ri, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58841 llvm-svn: 359516
* Reinstate r359059, reverted in r359361, with a fix to properly preventRichard Smith2019-04-272-0/+72
| | | | | | | | | | | | | | | | | | | | | | | us emitting the operand of __builtin_constant_p if it has side-effects. Original commit message: Fix interactions between __builtin_constant_p and constexpr to match current trunk GCC. GCC permits information from outside the operand of __builtin_constant_p (but in the same constant evaluation context) to be used within that operand; clang now does so too. A few other minor deviations from GCC's behavior showed up in my testing and are also fixed (matching GCC): * Clang now supports nullptr_t as the argument type for __builtin_constant_p * Clang now returns true from __builtin_constant_p if called with a null pointer * Clang now returns true from __builtin_constant_p if called with an integer cast to pointer type llvm-svn: 359367
* Revert Fix interactions between __builtin_constant_p and constexpr to match ↵Jorge Gorbe Moya2019-04-272-72/+0
| | | | | | | | current trunk GCC. This reverts r359059 (git commit 0b098754b73f3b96d00ecb1c7605760b11c90298) llvm-svn: 359361
* [MinGW] Fix dllexport of explicit template instantiationMartin Storsjo2019-04-261-5/+24
| | | | | | | | | | | | | | | | | Contrary to MSVC, GCC/MinGW needs to have the dllexport attribute on the template instantiation declaration, not on the definition. Previously clang never marked explicit template instantiations as dllexport in MinGW mode, if the instantiation had a previous declaration, regardless of where the attribute was placed. This makes Clang behave like GCC in this regard, and allows using the same attribute form for both MinGW compilers. This fixes PR40256. Differential Revision: https://reviews.llvm.org/D61118 llvm-svn: 359285
* C++ DR2387: a variable template declared wtih (or instantiated with) aRichard Smith2019-04-262-2/+5
| | | | | | | | | const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. This reinstates part of r359048, reverted in r359076. llvm-svn: 359260
* Add missing diagnostic for explicit instantiation declarations namingRichard Smith2019-04-262-2/+33
| | | | | | | | | | | | | | | | | internal linkage entities. Such constructs are ill-formed by [temp.explicit]p13. We make a special exception to permit an invalid construct used by libc++ in some build modes: its <valarray> header declares some functions with the internal_linkage attribute and then (meaninglessly) provides explicit instantiation declarations for them. Luckily, Clang happens to effectively ignore the explicit instantiation declaration when generating code in this case, and this change codifies that behavior. This reinstates part of r359048, reverted in r359076. (The libc++ issue triggering the rollback has been addressed.) llvm-svn: 359259
* Revert r359048: C++ DR2387: a variable template declared wthiIlya Biryukov2019-04-243-6/+4
| | | | | | | | | | | | | The change breaks libc++ with the follwing error: In file included from valarray:4: .../include/c++/v1/valarray:1062:60: error: explicit instantiation declaration of 'valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t)) ^ .../include/c++/v1/valarray:1063:60: error: explicit instantiation declaration of '~valarray<_Tp>' with internal linkage _LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray()) llvm-svn: 359076
* [Builtins] Implement __builtin_is_constant_evaluated for use in C++2aEric Fiselier2019-04-241-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements `__builtin_is_constant_evaluated` as specifier by [P0595R2](https://wg21.link/p0595r2). It is built on the back of Bill Wendling's work for `__builtin_constant_p()`. More tests to come, but early feedback is appreciated. I plan to implement warnings for common mis-usages like those belowe in a following patch: ``` void foo(int x) { if constexpr (std::is_constant_evaluated())) { // condition is always `true`. Should use plain `if` instead. foo_constexpr(x); } else { foo_runtime(x); } } ``` Reviewers: rsmith, MaskRay, bruno, void Reviewed By: rsmith Subscribers: dexonsmith, zoecarver, fdeazeve, kristina, cfe-commits Differential Revision: https://reviews.llvm.org/D55500 llvm-svn: 359067
* Revert r350917 "[Sema] If CheckPlaceholderExpr rewrites the initializerRichard Smith2019-04-241-0/+15
| | | | | | | | | | | | | | of an auto" This commit changed the initializer expression passed into initialization (stripping off an enclosing pair of parentheses or braces) and subtly changing the meaning of programs, typically by inserting bogus calls to copy constructors. See the added testcase in test/SemaCXX/cxx1y-init-captures.cpp for an example of the breakage. llvm-svn: 359066
* Fix interactions between __builtin_constant_p and constexpr to matchRichard Smith2019-04-242-0/+72
| | | | | | | | | | | | | | | | | | current trunk GCC. GCC permits information from outside the operand of __builtin_constant_p (but in the same constant evaluation context) to be used within that operand; clang now does so too. A few other minor deviations from GCC's behavior showed up in my testing and are also fixed (matching GCC): * Clang now supports nullptr_t as the argument type for __builtin_constant_p * Clang now returns true from __builtin_constant_p if called with a null pointer * Clang now returns true from __builtin_constant_p if called with an integer cast to pointer type llvm-svn: 359059
* Add missing diagnostic for anonymous struct/union definitions that don'tRichard Smith2019-04-244-11/+11
| | | | | | introduce any names. llvm-svn: 359051
* C++ DR2387: a variable template declared wtih (or instantiated with) aRichard Smith2019-04-233-4/+6
| | | | | | | const-qualified type is not implicitly given internal linkage. But a variable template declared 'static' is. llvm-svn: 359048
* [APSInt][OpenMP] Fix isNegative, etc. for unsigned typesJoel E. Denny2019-04-231-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this patch, APSInt inherits APInt::isNegative, which merely checks the sign bit without regard to whether the type is actually signed. isNonNegative and isStrictlyPositive call isNegative and so are also affected. This patch adjusts APSInt to override isNegative, isNonNegative, and isStrictlyPositive with implementations that consider whether the type is signed. A large set of Clang OpenMP tests are affected. Without this patch, these tests assume that `true` is not a valid argument for clauses like `collapse`. Indeed, `true` fails APInt::isStrictlyPositive but not APSInt::isStrictlyPositive. This patch adjusts those tests to assume `true` should be accepted. This patch also adds tests revealing various other similar fixes due to APSInt::isNegative calls in Clang's ExprConstant.cpp and SemaExpr.cpp: `++` and `--` overflow in `constexpr`, evaluated object size based on `alloc_size`, `<<` and `>>` shift count validation, and OpenMP array section validation. Reviewed By: lebedev.ri, ABataev, hfinkel Differential Revision: https://reviews.llvm.org/D59712 llvm-svn: 359012
* [c++2a] Implement semantic restrictions for 'export' declarations.Richard Smith2019-04-222-5/+10
| | | | llvm-svn: 358932
* Revert "[clang] Aligned allocation is actually supported in macosx 10.13"Louis Dionne2019-04-151-6/+6
| | | | | | | | This reverts r358409, which I think broke the bots in compiler-rt. Since I'm having trouble reproducing the failure, I'm reverting this until I can investigate locally. llvm-svn: 358437
* [clang] Aligned allocation is actually supported in macosx 10.13Louis Dionne2019-04-151-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | Summary: In r350649, I changed aligned allocation from being available starting in macosx10.13 to macosx10.14. However, aligned allocation is indeed available starting with macosx10.13, my investigation had been based on the wrong libc++abi dylib. This means that Clang before the fix will be more stringent when it comes to aligned allocation -- it will not allow it when back-deploying to macosx 10.13, when it would actually be safe to do so. Note that a companion change will be coming to fix the libc++ tests. Reviewers: ahatanak Subscribers: jkorous, dexonsmith, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60626 llvm-svn: 358409
* Check i < FD->getNumParams() before queryingDmitri Gribenko2019-04-102-0/+24
| | | | | | | | | | | | | | | | | | | | | | Summary: As was already stated in a previous comment, the parameter isn't necessarily referring to one of the DeclContext's parameter. We should check the index is within the range to avoid out-of-boundary access. Reviewers: gribozavr, rsmith, lebedev.ri Reviewed By: gribozavr, rsmith Subscribers: lebedev.ri, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60055 Patch by Violet. llvm-svn: 358134
* [Sema] Fix assertion when `auto` parameter in lambda has an attribute.Volodymyr Sapsai2019-03-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes the assertion > no Attr* for AttributedType* > UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298! In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes` types with `auto` but later in `TypeProcessingState::takeAttrForAttributedType` we use transformed types and that's why cannot find `Attr` corresponding to `AttributedType`. Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`. rdar://problem/47689465 Reviewers: rsmith, arphaman, aaron.ballman Reviewed By: aaron.ballman Subscribers: jkorous, dexonsmith, jdoerfert, cfe-commits Differential Revision: https://reviews.llvm.org/D58659 llvm-svn: 357298
* [Sema] Fix a crash when nonnull checkingMichael Liao2019-03-291-0/+23
| | | | | | | | | | | | | | | | | | | | Summary: - If a parameter is used, nonnull checking needs function prototype to retrieve the corresponding parameter's attributes. However, at the prototype substitution phase when a template is being instantiated, expression may be created and checked without a fully specialized prototype. Under such a scenario, skip nonnull checking on that argument. Reviewers: rjmccall, tra, yaxunl Subscribers: javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59900 llvm-svn: 357236
* [Sema] Fix an assert when a block captures a constexpr localErik Pilkington2019-03-261-0/+8
| | | | | | | | | | | | | | MarkVarDeclODRUsed indirectly calls captureInBlock, which creates a copy expression. The copy expression is insulated in it's own ExpressionEvaluationContext, so it saves, mutates, and restores MaybeODRUseExprs as CleanupVarDeclMarking is iterating through it, leading to a crash. Fix this by iterating through a local copy of MaybeODRUseExprs. rdar://47493525 https://reviews.llvm.org/D59670 llvm-svn: 357040
* [MS] Add frontend support for __declspec(allocator)Reid Kleckner2019-03-251-0/+13
| | | | | | | | | | The intention is to add metadata to direct call sites of functions marked with __declspec(allocator), which will ultimately result in some S_HEAPALLOCSITE debug info records when emitting codeview. This is a piece of PR38491 llvm-svn: 356964
* [Sema] Don't check for array bounds when the types in the base expression ↵Bruno Ricci2019-03-251-0/+13
| | | | | | | | | | | | | | are dependent Bail-out of CheckArrayAccess when the types of the base expression before and after eventual casts are dependent. We will get another chance to check for array bounds during instantiation. Fixes PR41087. Differential Revision: https://reviews.llvm.org/D59776 Reviewed By: efriedma llvm-svn: 356957
* Un-revert "[coroutines][PR40978] Emit error for co_yield within catch block"Brian Gesiak2019-03-252-6/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: https://reviews.llvm.org/D59076 added a new coroutine error that prevented users from using 'co_await' or 'co_yield' within a exception handler. However, it was reverted in https://reviews.llvm.org/rC356774 because it caused a regression in nested scopes in C++ catch statements, as documented by https://bugs.llvm.org/show_bug.cgi?id=41171. The issue was due to an incorrect use of a `clang::ParseScope`. To fix: 1. Add a regression test for catch statement parsing that mimics the bug report from https://bugs.llvm.org/show_bug.cgi?id=41171. 2. Re-apply the coroutines error patch from https://reviews.llvm.org/D59076, but this time with the correct ParseScope behavior. Reviewers: GorNishanov, tks2103, rsmith, riccibruno, jbulow Reviewed By: riccibruno Subscribers: EricWF, jdoerfert, lewissbaker, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59752 llvm-svn: 356865
* Revert "[coroutines][PR40978] Emit error for co_yield within catch block"Brian Gesiak2019-03-221-57/+6
| | | | | | | | The commit https://reviews.llvm.org/rC356296 is causing a regression in nested catch scopes, https://bugs.llvm.org/show_bug.cgi?id=41171. Revert this change for now in order to un-break that problem report. llvm-svn: 356774
* Permit redeclarations of a builtin to specify calling convention.Erich Keane2019-03-213-19/+19
| | | | | | | | | | | | | | | | | | | | After https://reviews.llvm.org/rL355317 we noticed that quite a decent amount of code redeclares builtins (memcpy in particular, I believe reduced from an MSVC header) with a calling convention specified. This gets particularly troublesome when the user specifies a new 'default' calling convention on the command line. When looking to add a diagnostic for this case, it was noticed that we had 3 other diagnostics that differed only slightly. This patch ALSO unifies those under a 'select'. Unfortunately, the order of words in ONE of these diagnostics was reversed ("'thiscall' calling convention" vs "calling convention 'thiscall'"), so this patch also standardizes on the former. Differential Revision: https://reviews.llvm.org/D59560 Change-Id: I79f99fe7c2301640755ffdd774b46eb44526bb22 llvm-svn: 356663
* [Sema] Deduplicate some availability checking logicErik Pilkington2019-03-202-38/+70
| | | | | | | | | | | | | | | Before this commit, we emit unavailable errors for calls to functions during overload resolution, and for references to all other declarations in DiagnoseUseOfDecl. The early checks during overload resolution aren't as good as the DiagnoseAvailabilityOfDecl based checks, as they error on the code from PR40991. This commit fixes this by removing the early checking. llvm.org/PR40991 rdar://48564179 Differential revision: https://reviews.llvm.org/D59394 llvm-svn: 356599
* Ensure that const variables declared at namespace scope correctly have ↵Aaron Ballman2019-03-192-0/+8
| | | | | | | | external linkage when marked as dllexport and targeting the MSVC ABI. Patch thanks to Zahira Ammarguellat. llvm-svn: 356458
* Thread safety analysis: Add note for unlock kind mismatchAaron Puchert2019-03-181-4/+4
| | | | | | | | | | | | | | | | | | Summary: Similar to D56967, we add the existing diag::note_locked_here to tell the user where we saw the locking that isn't matched correctly. Reviewers: aaron.ballman, delesley Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59455 llvm-svn: 356427
* [coroutines][PR40978] Emit error for co_yield within catch blockBrian Gesiak2019-03-151-6/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: As reported in https://bugs.llvm.org/show_bug.cgi?id=40978, it's an error to use the `co_yield` or `co_await` keywords outside of a valid "suspension context" as defined by [expr.await]p2 of http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/n4775.pdf. Whether or not the current scope was in a function-try-block's (https://en.cppreference.com/w/cpp/language/function-try-block) handler could be determined using scope flag `Scope::FnTryCatchScope`. No such flag existed for a simple C++ catch statement, so this commit adds one. Reviewers: GorNishanov, tks2103, rsmith Reviewed By: GorNishanov Subscribers: EricWF, jdoerfert, cfe-commits, lewissbaker Tags: #clang Differential Revision: https://reviews.llvm.org/D59076 llvm-svn: 356296
* [8.0 Regression] Fix handling of `__builtin_constant_p` inside template ↵Eric Fiselier2019-03-082-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | arguments, enumerators, case statements, and the enable_if attribute. Summary: The following code is accepted by Clang 7 and prior but rejected by the upcoming 8 release and in trunk [1] ``` // error {{never produces a constant expression}} void foo(const char* s) __attribute__((enable_if(__builtin_constant_p(*s) == false, "trap"))) {} void test() { foo("abc"); } ``` Prior to Clang 8, the call to `__builtin_constant_p` was a constant expression returning false. Currently, it's not a valid constant expression. The bug is caused because we failed to set `InConstantContext` when attempting to evaluate unevaluated constant expressions. [1] https://godbolt.org/z/ksAjmq Reviewers: rsmith, hans, sbenza Reviewed By: rsmith Subscribers: kristina, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59038 llvm-svn: 355743
* [Sema] Change addr space diagnostics in casts to follow C++ style.Anastasia Stulova2019-03-071-14/+14
| | | | | | | | | | | | | | | | | | | | This change adds a new diagnostic for mismatching address spaces to be used for C++ casts (only enabled in C style cast for now, the rest will follow!). The change extends C-style cast rules to account for address spaces. It also adds a separate function for address space cast checking that can be used to map from a separate address space cast operator addrspace_cast (to be added as a follow up patch). Note, that after this change clang will no longer allows arbitrary address space conversions in reinterpret_casts because they can lead to accidental errors. The implicit safe conversions would still be allowed. Differential Revision: https://reviews.llvm.org/D58346 llvm-svn: 355609
* [Sema][NFC] SequenceChecker: More tests in preparation for D57660Bruno Ricci2019-02-231-5/+148
| | | | llvm-svn: 354727
* [Sema][NFC] SequenceChecker: Add tests for references/members, and prepare ↵Bruno Ricci2019-02-152-45/+246
| | | | | | | | | | | | | for the C++17 tests Add some tests for unsequenced operations with members and references. For now most of it is unhandled but it shows what work needs to be done. Also merge the tests for the C++17 sequencing rules in warn-unsequenced.cpp since we want to make sure that the appropriate warnings are still present in C++17 without duplicating the whole content of warn-unsequenced.cpp. llvm-svn: 354151
* Revert "[Analysis] -Wunreachable-code shouldn't fire on the increment of a ↵Sam McCall2019-02-151-5/+0
| | | | | | | | foreach loop" This reverts commit r354102. llvm-svn: 354109
* [Analysis] -Wunreachable-code shouldn't fire on the increment of a foreach loopSam McCall2019-02-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The idea is that the code here isn't written, so doesn't indicate a bug. Similar to code expanded from macros. This means the warning no longer fires on this code: for (auto C : collection) { process(C); return; } handleEmptyCollection(); Unclear whether this is more often a bug or not in practice, I think it's a reasonable idiom in some cases. Either way, if we want to warn on "loop that doesn't loop", I think it should be a separate warning, and catch `while(1) break;` Reviewers: ilya-biryukov, ioeric Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58134 llvm-svn: 354102
* [Sema] Fix-up a -Wfloat-conversion diagnosticErik Pilkington2019-02-141-6/+6
| | | | | | | | | | | | We were warning on valid ObjC property reference exprs, and passing in the wrong arguments to DiagnoseFloatingImpCast (leading to a badly worded diagnostic). rdar://47644670 Differential revision: https://reviews.llvm.org/D58145 llvm-svn: 354074
* [Builtins] Treat `bcmp` as a builtin.Clement Courbet2019-02-142-1/+57
| | | | | | | | | | | | | | | | | Summary: This makes it consistent with `memcmp` and `__builtin_bcmp`. Also see the discussion in https://reviews.llvm.org/D56593. Reviewers: jyknight Subscribers: kristina, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58120 llvm-svn: 354023
* Restore Check for Unreachable Exit Block in -Winfinite-recursionRobert Widmann2019-02-131-2/+11
| | | | | | | | | | | | | | | | | | | Summary: When this was rewritten in D43737, the logic changed to better explore infinite loops. The check for a reachable exit block was deleted which accidentally introduced false positives in case the exit node was unreachable. We were testing for cases like this, but @steven_wu provided an additional test case that I've included in the regression tests for this patch. Reviewers: steven_wu, rtrieu Reviewed By: steven_wu, rtrieu Subscribers: cfe-commits, steven_wu Tags: #clang Differential Revision: https://reviews.llvm.org/D58122 llvm-svn: 353984
OpenPOWER on IntegriCloud