[llvm-branch-commits] [llvm] 9a0900d - [NFC][AIX][XCOFF] Fix compile warning on strncpy
Author: Yang Fan Date: 2021-01-19T14:07:11+08:00 New Revision: 9a0900dc4c6b3390fc886b7b556196da82ba1204 URL: https://github.com/llvm/llvm-project/commit/9a0900dc4c6b3390fc886b7b556196da82ba1204 DIFF: https://github.com/llvm/llvm-project/commit/9a0900dc4c6b3390fc886b7b556196da82ba1204.diff LOG: [NFC][AIX][XCOFF] Fix compile warning on strncpy GCC warning: ``` In file included from /usr/include/string.h:495, from /usr/include/c++/9/cstring:42, from /llvm-project/llvm/include/llvm/ADT/Hashing.h:53, from /llvm-project/llvm/include/llvm/ADT/ArrayRef.h:12, from /llvm-project/llvm/include/llvm/MC/MCAsmBackend.h:12, from /llvm-project/llvm/lib/MC/XCOFFObjectWriter.cpp:14: In function ‘char* strncpy(char*, const char*, size_t)’, inlined from ‘{anonymous}::Section::Section(const char*, llvm::XCOFF::SectionTypeFlags, bool, {anonymous}::CsectGroups)’ at /llvm-project/llvm/lib/MC/XCOFFObjectWriter.cpp:146:12: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:106:34: warning: ‘char* __builtin_strncpy(char*, const char*, long unsigned int)’ specified bound 8 equals destination size [-Wstringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~ ^ ``` Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D94872 Added: Modified: llvm/lib/MC/XCOFFObjectWriter.cpp Removed: diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp index d6cee3bb59bb..031eceaadf06 100644 --- a/llvm/lib/MC/XCOFFObjectWriter.cpp +++ b/llvm/lib/MC/XCOFFObjectWriter.cpp @@ -138,12 +138,13 @@ struct Section { Group->clear(); } - Section(const char *N, XCOFF::SectionTypeFlags Flags, bool IsVirtual, + Section(StringRef N, XCOFF::SectionTypeFlags Flags, bool IsVirtual, CsectGroups Groups) - : Address(0), Size(0), FileOffsetToData(0), FileOffsetToRelocations(0), -RelocationCount(0), Flags(Flags), Index(UninitializedIndex), -IsVirtual(IsVirtual), Groups(Groups) { -strncpy(Name, N, XCOFF::NameSize); + : Name(), Address(0), Size(0), FileOffsetToData(0), +FileOffsetToRelocations(0), RelocationCount(0), Flags(Flags), +Index(UninitializedIndex), IsVirtual(IsVirtual), Groups(Groups) { +assert(N.size() <= XCOFF::NameSize && "section name too long"); +memcpy(Name, N.data(), N.size()); } }; ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] 89b0972 - [Sema] Fix deleted function problem in implicitly movable test
Author: Yang Fan Date: 2021-01-01T15:47:49+08:00 New Revision: 89b0972aa2f58f927633c63570b36550a17f4e63 URL: https://github.com/llvm/llvm-project/commit/89b0972aa2f58f927633c63570b36550a17f4e63 DIFF: https://github.com/llvm/llvm-project/commit/89b0972aa2f58f927633c63570b36550a17f4e63.diff LOG: [Sema] Fix deleted function problem in implicitly movable test In implicitly movable test, a two-stage overload resolution is performed. If the first overload resolution selects a deleted function, Clang directly performs the second overload resolution, without checking whether the deleted function matches the additional criteria. This patch fixes the above problem. Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D92936 Added: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp Modified: clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaStmt.cpp Removed: diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 6d2e6094e79c..4a965c60c74e 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4119,7 +4119,9 @@ static void TryConstructorInitialization(Sema &S, InitializationSequence::FK_ListConstructorOverloadFailed : InitializationSequence::FK_ConstructorOverloadFailed, Result); -return; + +if (Result != OR_Deleted) + return; } bool HadMultipleCandidates = (CandidateSet.size() > 1); @@ -4140,31 +4142,45 @@ static void TryConstructorInitialization(Sema &S, return; } - // C++11 [dcl.init]p6: - // If a program calls for the default initialization of an object - // of a const-qualified type T, T shall be a class type with a - // user-provided default constructor. - // C++ core issue 253 proposal: - // If the implicit default constructor initializes all subobjects, no - // initializer should be required. - // The 253 proposal is for example needed to process libstdc++ headers in 5.x. CXXConstructorDecl *CtorDecl = cast(Best->Function); - if (Kind.getKind() == InitializationKind::IK_Default && - Entity.getType().isConstQualified()) { -if (!CtorDecl->getParent()->allowConstDefaultInit()) { - if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) -Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); + if (Result != OR_Deleted) { // TODO: Support for more than one failure. +// C++11 [dcl.init]p6: +// If a program calls for the default initialization of an object +// of a const-qualified type T, T shall be a class type with a +// user-provided default constructor. +// C++ core issue 253 proposal: +// If the implicit default constructor initializes all subobjects, no +// initializer should be required. +// The 253 proposal is for example needed to process libstdc++ headers +// in 5.x. +if (Kind.getKind() == InitializationKind::IK_Default && +Entity.getType().isConstQualified()) { + if (!CtorDecl->getParent()->allowConstDefaultInit()) { +if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) + Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); +return; + } +} + +// C++11 [over.match.list]p1: +// In copy-list-initialization, if an explicit constructor is chosen, the +// initializer is ill-formed. +if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { + Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); return; } } - // C++11 [over.match.list]p1: - // In copy-list-initialization, if an explicit constructor is chosen, the - // initializer is ill-formed. - if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { -Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); + // [class.copy.elision]p3: + // In some copy-initialization contexts, a two-stage overload resolution + // is performed. + // If the first overload resolution selects a deleted function, we also + // need the initialization sequence to decide whether to perform the second + // overload resolution. + // For deleted functions in other contexts, there is no need to get the + // initialization sequence. + if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy) return; - } // Add the constructor initialization step. Any cv-qualification conversion is // subsumed by the initialization. @@ -5260,7 +5276,16 @@ static void TryUserDefinedConversion(Sema &S, Sequence.SetOverloadFailure( InitializationSequence::FK_UserConversionOverloadFailed, Result); -return; + +// [class.copy.elision]p3: +// In some copy-initialization contexts, a two-stage overload resolution +// is perfo
[llvm-branch-commits] [clang-tools-extra] d5324c0 - [clang-tidy][NFC] Fix a build warning due to an extra semicolon
Author: Yang Fan Date: 2021-01-01T16:00:20+08:00 New Revision: d5324c052b21741d8d9f980d796604589b85c97a URL: https://github.com/llvm/llvm-project/commit/d5324c052b21741d8d9f980d796604589b85c97a DIFF: https://github.com/llvm/llvm-project/commit/d5324c052b21741d8d9f980d796604589b85c97a.diff LOG: [clang-tidy][NFC] Fix a build warning due to an extra semicolon Differential Revision: https://reviews.llvm.org/D93961 Added: Modified: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp index 472123f8b306..be068aa8da4a 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp @@ -392,7 +392,7 @@ parseConfiguration(llvm::MemoryBufferRef Config) { static void diagHandlerImpl(const llvm::SMDiagnostic &Diag, void *Ctx) { (*reinterpret_cast(Ctx))(Diag); -}; +} llvm::ErrorOr parseConfigurationWithDiags(llvm::MemoryBufferRef Config, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] 471dec3 - [CodeGen][NFC] Fix a build warning due to an extra semicolon
Author: Yang Fan Date: 2021-01-02T10:42:58+08:00 New Revision: 471dec3801b32d8b9428f6341accb649ef6cda56 URL: https://github.com/llvm/llvm-project/commit/471dec3801b32d8b9428f6341accb649ef6cda56 DIFF: https://github.com/llvm/llvm-project/commit/471dec3801b32d8b9428f6341accb649ef6cda56.diff LOG: [CodeGen][NFC] Fix a build warning due to an extra semicolon Added: Modified: llvm/lib/CodeGen/DwarfEHPrepare.cpp Removed: diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp index a4824ef21640..34a04feec040 100644 --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -273,7 +273,7 @@ static bool prepareDwarfEH(CodeGenOpt::Level OptLevel, return DwarfEHPrepare(OptLevel, RewindFunction, F, TLI, DT ? &DTU : nullptr, TTI) .run(); -}; +} namespace { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] e43b3d1 - Revert "[Sema] Fix deleted function problem in implicitly movable test"
Author: Yang Fan Date: 2021-01-04T17:21:19+08:00 New Revision: e43b3d1f5e05c6e5e07cff054df193cf0d0c6583 URL: https://github.com/llvm/llvm-project/commit/e43b3d1f5e05c6e5e07cff054df193cf0d0c6583 DIFF: https://github.com/llvm/llvm-project/commit/e43b3d1f5e05c6e5e07cff054df193cf0d0c6583.diff LOG: Revert "[Sema] Fix deleted function problem in implicitly movable test" This reverts commit 89b0972a Added: Modified: clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaStmt.cpp Removed: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 4a965c60c74e..6d2e6094e79c 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4119,9 +4119,7 @@ static void TryConstructorInitialization(Sema &S, InitializationSequence::FK_ListConstructorOverloadFailed : InitializationSequence::FK_ConstructorOverloadFailed, Result); - -if (Result != OR_Deleted) - return; +return; } bool HadMultipleCandidates = (CandidateSet.size() > 1); @@ -4142,45 +4140,31 @@ static void TryConstructorInitialization(Sema &S, return; } + // C++11 [dcl.init]p6: + // If a program calls for the default initialization of an object + // of a const-qualified type T, T shall be a class type with a + // user-provided default constructor. + // C++ core issue 253 proposal: + // If the implicit default constructor initializes all subobjects, no + // initializer should be required. + // The 253 proposal is for example needed to process libstdc++ headers in 5.x. CXXConstructorDecl *CtorDecl = cast(Best->Function); - if (Result != OR_Deleted) { // TODO: Support for more than one failure. -// C++11 [dcl.init]p6: -// If a program calls for the default initialization of an object -// of a const-qualified type T, T shall be a class type with a -// user-provided default constructor. -// C++ core issue 253 proposal: -// If the implicit default constructor initializes all subobjects, no -// initializer should be required. -// The 253 proposal is for example needed to process libstdc++ headers -// in 5.x. -if (Kind.getKind() == InitializationKind::IK_Default && -Entity.getType().isConstQualified()) { - if (!CtorDecl->getParent()->allowConstDefaultInit()) { -if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) - Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); -return; - } -} - -// C++11 [over.match.list]p1: -// In copy-list-initialization, if an explicit constructor is chosen, the -// initializer is ill-formed. -if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { - Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); + if (Kind.getKind() == InitializationKind::IK_Default && + Entity.getType().isConstQualified()) { +if (!CtorDecl->getParent()->allowConstDefaultInit()) { + if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) +Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); return; } } - // [class.copy.elision]p3: - // In some copy-initialization contexts, a two-stage overload resolution - // is performed. - // If the first overload resolution selects a deleted function, we also - // need the initialization sequence to decide whether to perform the second - // overload resolution. - // For deleted functions in other contexts, there is no need to get the - // initialization sequence. - if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy) + // C++11 [over.match.list]p1: + // In copy-list-initialization, if an explicit constructor is chosen, the + // initializer is ill-formed. + if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { +Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); return; + } // Add the constructor initialization step. Any cv-qualification conversion is // subsumed by the initialization. @@ -5276,16 +5260,7 @@ static void TryUserDefinedConversion(Sema &S, Sequence.SetOverloadFailure( InitializationSequence::FK_UserConversionOverloadFailed, Result); - -// [class.copy.elision]p3: -// In some copy-initialization contexts, a two-stage overload resolution -// is performed. -// If the first overload resolution selects a deleted function, we also -// need the initialization sequence to decide whether to perform the second -// overload resolution. -if (!(Result == OR_Deleted && - Kind.getKind() == InitializationKind::IK_Copy)) - return; +return; } FunctionDecl *Function = Best->Function
[llvm-branch-commits] [clang] 74f93bc - [Sema] Fix deleted function problem in implicitly movable test
Author: Yang Fan Date: 2021-01-06T10:05:40+08:00 New Revision: 74f93bc373d089e757bb65cf8b30b63a4eae8b69 URL: https://github.com/llvm/llvm-project/commit/74f93bc373d089e757bb65cf8b30b63a4eae8b69 DIFF: https://github.com/llvm/llvm-project/commit/74f93bc373d089e757bb65cf8b30b63a4eae8b69.diff LOG: [Sema] Fix deleted function problem in implicitly movable test In implicitly movable test, a two-stage overload resolution is performed. If the first overload resolution selects a deleted function, Clang directly performs the second overload resolution, without checking whether the deleted function matches the additional criteria. This patch fixes the above problem. Reviewed By: Quuxplusone Differential Revision: https://reviews.llvm.org/D92936 Added: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp Modified: clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaStmt.cpp clang/test/SemaCXX/warn-return-std-move.cpp Removed: diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 6d2e6094e79c..b5f31bf403d4 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -4115,11 +4115,13 @@ static void TryConstructorInitialization(Sema &S, IsListInit); } if (Result) { -Sequence.SetOverloadFailure(IsListInit ? - InitializationSequence::FK_ListConstructorOverloadFailed : - InitializationSequence::FK_ConstructorOverloadFailed, -Result); -return; +Sequence.SetOverloadFailure( +IsListInit ? InitializationSequence::FK_ListConstructorOverloadFailed + : InitializationSequence::FK_ConstructorOverloadFailed, +Result); + +if (Result != OR_Deleted) + return; } bool HadMultipleCandidates = (CandidateSet.size() > 1); @@ -4140,31 +4142,45 @@ static void TryConstructorInitialization(Sema &S, return; } - // C++11 [dcl.init]p6: - // If a program calls for the default initialization of an object - // of a const-qualified type T, T shall be a class type with a - // user-provided default constructor. - // C++ core issue 253 proposal: - // If the implicit default constructor initializes all subobjects, no - // initializer should be required. - // The 253 proposal is for example needed to process libstdc++ headers in 5.x. CXXConstructorDecl *CtorDecl = cast(Best->Function); - if (Kind.getKind() == InitializationKind::IK_Default && - Entity.getType().isConstQualified()) { -if (!CtorDecl->getParent()->allowConstDefaultInit()) { - if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) -Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); + if (Result != OR_Deleted) { +// C++11 [dcl.init]p6: +// If a program calls for the default initialization of an object +// of a const-qualified type T, T shall be a class type with a +// user-provided default constructor. +// C++ core issue 253 proposal: +// If the implicit default constructor initializes all subobjects, no +// initializer should be required. +// The 253 proposal is for example needed to process libstdc++ headers +// in 5.x. +if (Kind.getKind() == InitializationKind::IK_Default && +Entity.getType().isConstQualified()) { + if (!CtorDecl->getParent()->allowConstDefaultInit()) { +if (!maybeRecoverWithZeroInitialization(S, Sequence, Entity)) + Sequence.SetFailed(InitializationSequence::FK_DefaultInitOfConst); +return; + } +} + +// C++11 [over.match.list]p1: +// In copy-list-initialization, if an explicit constructor is chosen, the +// initializer is ill-formed. +if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { + Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); return; } } - // C++11 [over.match.list]p1: - // In copy-list-initialization, if an explicit constructor is chosen, the - // initializer is ill-formed. - if (IsListInit && !Kind.AllowExplicit() && CtorDecl->isExplicit()) { -Sequence.SetFailed(InitializationSequence::FK_ExplicitConstructor); + // [class.copy.elision]p3: + // In some copy-initialization contexts, a two-stage overload resolution + // is performed. + // If the first overload resolution selects a deleted function, we also + // need the initialization sequence to decide whether to perform the second + // overload resolution. + // For deleted functions in other contexts, there is no need to get the + // initialization sequence. + if (Result == OR_Deleted && Kind.getKind() != InitializationKind::IK_Copy) return; - } // Add the constructor initialization step. Any cv-qualification conversion is // subsumed by the initialization. @@ -5258,9 +5274,17 @@ static void
[llvm-branch-commits] [clang] a032a4e - [-Wcalled-once-parameter][NFC] Fix operator precedence warning
Author: Yang Fan Date: 2021-01-06T12:16:30+08:00 New Revision: a032a4e7998c9adc7faea9e7b8e36a9552d3503b URL: https://github.com/llvm/llvm-project/commit/a032a4e7998c9adc7faea9e7b8e36a9552d3503b DIFF: https://github.com/llvm/llvm-project/commit/a032a4e7998c9adc7faea9e7b8e36a9552d3503b.diff LOG: [-Wcalled-once-parameter][NFC] Fix operator precedence warning Added: Modified: clang/lib/Analysis/CalledOnceCheck.cpp Removed: diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp index 2eff97640dfa..6b7d3790e3e5 100644 --- a/clang/lib/Analysis/CalledOnceCheck.cpp +++ b/clang/lib/Analysis/CalledOnceCheck.cpp @@ -573,8 +573,8 @@ class CalledOnceChecker : public ConstStmtVisitor { CheckConventionalParameters(CheckConventionalParameters), CurrentState(0) { initDataStructures(); -assert(size() == 0 || - !States.empty() && "Data structures are inconsistent"); +assert((size() == 0 || !States.empty()) && + "Data structures are inconsistent"); } //===--===// ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits