[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()
nemanjai added a comment. I assume this also fixes https://bugs.llvm.org/show_bug.cgi?id=31161? https://reviews.llvm.org/D38656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38678: [Sema] Warn about unused variables if we can constant evaluate the initializer.
bkramer created this revision. If the variable construction can be constant evaluated it doesn't have side effects, so removing it is always safe. We only try to evaluate variables that are unused, there should be no impact on compile time. https://reviews.llvm.org/D38678 Files: lib/Sema/SemaDecl.cpp test/SemaCXX/warn-unused-variables.cpp Index: test/SemaCXX/warn-unused-variables.cpp === --- test/SemaCXX/warn-unused-variables.cpp +++ test/SemaCXX/warn-unused-variables.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s template void f() { T t; t = 17; @@ -194,3 +195,35 @@ } } + +#if __cplusplus >= 201103L +namespace with_constexpr { +template +struct Literal { + T i; + Literal() = default; + constexpr Literal(T i) : i(i) {} +}; + +struct NoLiteral { + int i; + NoLiteral() = default; + constexpr NoLiteral(int i) : i(i) {} + ~NoLiteral() {} +}; + +static Literal gl1; // expected-warning {{unused variable 'gl1'}} +static Literal gl2(1); // expected-warning {{unused variable 'gl2'}} +static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}} + +template +void test(int i) { + Literal l1; // expected-warning {{unused variable 'l1'}} + Literal l2(42); // expected-warning {{unused variable 'l2'}} + Literal l3(i); // no-warning + Literal l4(0);// no-warning + NoLiteral nl1; // no-warning + NoLiteral nl2(42); // no-warning +} +} +#endif Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1683,7 +1683,8 @@ dyn_cast(Init); if (Construct && !Construct->isElidable()) { CXXConstructorDecl *CD = Construct->getConstructor(); -if (!CD->isTrivial() && !RD->hasAttr()) +if (!CD->isTrivial() && !RD->hasAttr() && +!VD->evaluateValue()) return false; } } Index: test/SemaCXX/warn-unused-variables.cpp === --- test/SemaCXX/warn-unused-variables.cpp +++ test/SemaCXX/warn-unused-variables.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -Wunused-label -Wno-c++1y-extensions -verify -std=c++11 %s template void f() { T t; t = 17; @@ -194,3 +195,35 @@ } } + +#if __cplusplus >= 201103L +namespace with_constexpr { +template +struct Literal { + T i; + Literal() = default; + constexpr Literal(T i) : i(i) {} +}; + +struct NoLiteral { + int i; + NoLiteral() = default; + constexpr NoLiteral(int i) : i(i) {} + ~NoLiteral() {} +}; + +static Literal gl1; // expected-warning {{unused variable 'gl1'}} +static Literal gl2(1); // expected-warning {{unused variable 'gl2'}} +static const Literal gl3(0); // expected-warning {{unused variable 'gl3'}} + +template +void test(int i) { + Literal l1; // expected-warning {{unused variable 'l1'}} + Literal l2(42); // expected-warning {{unused variable 'l2'}} + Literal l3(i); // no-warning + Literal l4(0);// no-warning + NoLiteral nl1; // no-warning + NoLiteral nl2(42); // no-warning +} +} +#endif Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -1683,7 +1683,8 @@ dyn_cast(Init); if (Construct && !Construct->isElidable()) { CXXConstructorDecl *CD = Construct->getConstructor(); -if (!CD->isTrivial() && !RD->hasAttr()) +if (!CD->isTrivial() && !RD->hasAttr() && +!VD->evaluateValue()) return false; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315197 - Certain versions of clang require an explicit initialization for literal const members.
Author: d0k Date: Sun Oct 8 14:28:47 2017 New Revision: 315197 URL: http://llvm.org/viewvc/llvm-project?rev=315197=rev Log: Certain versions of clang require an explicit initialization for literal const members. include/clang/Lex/PreprocessorLexer.h:79:3: error: constructor for 'clang::PreprocessorLexer' must explicitly initialize the const member 'FID' Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h Modified: cfe/trunk/include/clang/Lex/PreprocessorLexer.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorLexer.h?rev=315197=315196=315197=diff == --- cfe/trunk/include/clang/Lex/PreprocessorLexer.h (original) +++ cfe/trunk/include/clang/Lex/PreprocessorLexer.h Sun Oct 8 14:28:47 2017 @@ -77,7 +77,7 @@ protected: PreprocessorLexer(Preprocessor *pp, FileID fid); PreprocessorLexer() -: PP(nullptr), InitialNumSLocEntries(0), +: PP(nullptr), FID(), InitialNumSLocEntries(0), ParsingPreprocessorDirective(false), ParsingFilename(false), LexingRawMode(false) {} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315193 - travis: Make sure we report failure even if only earlier checked files fail
Author: jvesely Date: Sun Oct 8 13:07:58 2017 New Revision: 315193 URL: http://llvm.org/viewvc/llvm-project?rev=315193=rev Log: travis: Make sure we report failure even if only earlier checked files fail for loop would only report status of the last command v2: return '1' call test instead of '[' Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyModified: libclc/trunk/.travis.yml Modified: libclc/trunk/.travis.yml URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=315193=315192=315193=diff == --- libclc/trunk/.travis.yml (original) +++ libclc/trunk/.travis.yml Sun Oct 8 13:07:58 2017 @@ -55,6 +55,8 @@ matrix: script: - $PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG --with-cxx-compiler=$CXX && make -j4 - - for f in $CHECK_FILES; do -./check_external_calls.sh built_libs/$f; -done + - ret=0; +for f in $CHECK_FILES; do +./check_external_calls.sh built_libs/$f || ret=1; +done; +test $ret -eq 0 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315192 - check_external_calls.sh: Print number of calls in tested file.
Author: jvesely Date: Sun Oct 8 13:07:56 2017 New Revision: 315192 URL: http://llvm.org/viewvc/llvm-project?rev=315192=rev Log: check_external_calls.sh: Print number of calls in tested file. Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyModified: libclc/trunk/check_external_calls.sh Modified: libclc/trunk/check_external_calls.sh URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/check_external_calls.sh?rev=315192=315191=315192=diff == --- libclc/trunk/check_external_calls.sh (original) +++ libclc/trunk/check_external_calls.sh Sun Oct 8 13:07:56 2017 @@ -24,9 +24,10 @@ TMP_FILE=$(mktemp) # Check for calls. Calls to llvm intrinsics are OK $DIS < $FILE | grep ' call ' | grep -v '@llvm' > "$TMP_FILE" +COUNT=$(wc -l < "$TMP_FILE") -if [ $(wc -l < "$TMP_FILE") -ne "0" ]; then - echo "ERROR: unresolved calls detected" +if [ "$COUNT" -ne "0" ]; then + echo "ERROR: $COUNT unresolved calls detected in $FILE" cat $TMP_FILE ret=1 else ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315188 - math/binary_decl.inc: Do not declare mixed float/double functions
Author: jvesely Date: Sun Oct 8 12:33:53 2017 New Revision: 315188 URL: http://llvm.org/viewvc/llvm-project?rev=315188=rev Log: math/binary_decl.inc: Do not declare mixed float/double functions fmin/fmax only need vector/scalar mix Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyModified: libclc/trunk/generic/include/clc/math/binary_decl.inc Modified: libclc/trunk/generic/include/clc/math/binary_decl.inc URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/binary_decl.inc?rev=315188=315187=315188=diff == --- libclc/trunk/generic/include/clc/math/binary_decl.inc (original) +++ libclc/trunk/generic/include/clc/math/binary_decl.inc Sun Oct 8 12:33:53 2017 @@ -1,6 +1,2 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE a, __CLC_GENTYPE b); -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE a, float b); - -#ifdef cl_khr_fp64 -_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE a, double b); -#endif +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE a, __CLC_SCALAR_GENTYPE b); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315191 - ptx: Use __clc_nextafter to implement nextafter
Author: jvesely Date: Sun Oct 8 12:34:00 2017 New Revision: 315191 URL: http://llvm.org/viewvc/llvm-project?rev=315191=rev Log: ptx: Use __clc_nextafter to implement nextafter using clang builtin results in external library call Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyAdded: libclc/trunk/ptx/lib/SOURCES libclc/trunk/ptx/lib/math/ libclc/trunk/ptx/lib/math/nextafter.cl Added: libclc/trunk/ptx/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx/lib/SOURCES?rev=315191=auto == --- libclc/trunk/ptx/lib/SOURCES (added) +++ libclc/trunk/ptx/lib/SOURCES Sun Oct 8 12:34:00 2017 @@ -0,0 +1 @@ +math/nextafter.cl Added: libclc/trunk/ptx/lib/math/nextafter.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx/lib/math/nextafter.cl?rev=315191=auto == --- libclc/trunk/ptx/lib/math/nextafter.cl (added) +++ libclc/trunk/ptx/lib/math/nextafter.cl Sun Oct 8 12:34:00 2017 @@ -0,0 +1,10 @@ +#include +#include "../lib/clcmacro.h" +#include + +_CLC_DEFINE_BINARY_BUILTIN(float, nextafter, __clc_nextafter, float, float) + +#ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable +_CLC_DEFINE_BINARY_BUILTIN(double, nextafter, __clc_nextafter, double, double) +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315190 - Do not include clc_nextafter header globally
Author: jvesely Date: Sun Oct 8 12:33:58 2017 New Revision: 315190 URL: http://llvm.org/viewvc/llvm-project?rev=315190=rev Log: Do not include clc_nextafter header globally Drop unused clc/math/clc_nextafter.h header Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyRemoved: libclc/trunk/generic/include/clc/math/clc_nextafter.h Modified: libclc/trunk/amdgpu/lib/math/nextafter.cl libclc/trunk/generic/include/clc/clc.h libclc/trunk/generic/include/clc/math/gentype.inc Modified: libclc/trunk/amdgpu/lib/math/nextafter.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgpu/lib/math/nextafter.cl?rev=315190=315189=315190=diff == --- libclc/trunk/amdgpu/lib/math/nextafter.cl (original) +++ libclc/trunk/amdgpu/lib/math/nextafter.cl Sun Oct 8 12:33:58 2017 @@ -1,5 +1,6 @@ #include #include "../lib/clcmacro.h" +#include _CLC_DEFINE_BINARY_BUILTIN(float, nextafter, __clc_nextafter, float, float) Modified: libclc/trunk/generic/include/clc/clc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=315190=315189=315190=diff == --- libclc/trunk/generic/include/clc/clc.h (original) +++ libclc/trunk/generic/include/clc/clc.h Sun Oct 8 12:33:58 2017 @@ -264,9 +264,4 @@ #include #include -/* libclc internal defintions */ -#ifdef __CLC_INTERNAL -#include -#endif - #pragma OPENCL EXTENSION all : disable Removed: libclc/trunk/generic/include/clc/math/clc_nextafter.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/clc_nextafter.h?rev=315189=auto == --- libclc/trunk/generic/include/clc/math/clc_nextafter.h (original) +++ libclc/trunk/generic/include/clc/math/clc_nextafter.h (removed) @@ -1,11 +0,0 @@ -#define __CLC_BODY - -#define __CLC_FUNCTION nextafter -#include -#undef __CLC_FUNCTION - -#define __CLC_FUNCTION __clc_nextafter -#include -#undef __CLC_FUNCTION - -#undef __CLC_BODY Modified: libclc/trunk/generic/include/clc/math/gentype.inc URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/gentype.inc?rev=315190=315189=315190=diff == --- libclc/trunk/generic/include/clc/math/gentype.inc (original) +++ libclc/trunk/generic/include/clc/math/gentype.inc Sun Oct 8 12:33:58 2017 @@ -54,6 +54,8 @@ #ifndef __FLOAT_ONLY #ifdef cl_khr_fp64 +#pragma OPENCL EXTENSION cl_khr_fp64 : enable + #define __CLC_SCALAR_GENTYPE double #define __CLC_FPSIZE 64 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libclc] r315189 - math/nextafter: Use custom declaration inc file
Author: jvesely Date: Sun Oct 8 12:33:55 2017 New Revision: 315189 URL: http://llvm.org/viewvc/llvm-project?rev=315189=rev Log: math/nextafter: Use custom declaration inc file Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyAdded: libclc/trunk/generic/include/clc/math/nextafter.inc Modified: libclc/trunk/generic/include/clc/math/nextafter.h Modified: libclc/trunk/generic/include/clc/math/nextafter.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/nextafter.h?rev=315189=315188=315189=diff == --- libclc/trunk/generic/include/clc/math/nextafter.h (original) +++ libclc/trunk/generic/include/clc/math/nextafter.h Sun Oct 8 12:33:55 2017 @@ -1,5 +1,2 @@ -#define __CLC_BODY -#define __CLC_FUNCTION nextafter +#define __CLC_BODY #include -#undef __CLC_FUNCTION -#undef __CLC_BODY Added: libclc/trunk/generic/include/clc/math/nextafter.inc URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/nextafter.inc?rev=315189=auto == --- libclc/trunk/generic/include/clc/math/nextafter.inc (added) +++ libclc/trunk/generic/include/clc/math/nextafter.inc Sun Oct 8 12:33:55 2017 @@ -0,0 +1 @@ +_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE nextafter(__CLC_GENTYPE a, __CLC_GENTYPE b); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r315185 - Remove unused variables. No functionality change.
Author: d0k Date: Sun Oct 8 12:11:02 2017 New Revision: 315185 URL: http://llvm.org/viewvc/llvm-project?rev=315185=rev Log: Remove unused variables. No functionality change. Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp cfe/trunk/lib/CodeGen/CGExprComplex.cpp cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=315185=315184=315185=diff == --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original) +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Sun Oct 8 12:11:02 2017 @@ -1169,7 +1169,6 @@ ItaniumRecordLayoutBuilder::LayoutBase(c // Query the external layout to see if it provides an offset. bool HasExternalLayout = false; if (UseExternalLayout) { -llvm::DenseMap::iterator Known; if (Base->IsVirtual) HasExternalLayout = External.getExternalNVBaseOffset(Base->Class, Offset); else Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=315185=315184=315185=diff == --- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sun Oct 8 12:11:02 2017 @@ -775,7 +775,6 @@ ComplexPairTy ComplexExprEmitter::EmitBi if (!LHSi) LibCallOp.LHS.second = llvm::Constant::getNullValue(LHSr->getType()); - StringRef LibCallName; switch (LHSr->getType()->getTypeID()) { default: llvm_unreachable("Unsupported floating point type!"); Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=315185=315184=315185=diff == --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original) +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun Oct 8 12:11:02 2017 @@ -6886,7 +6886,6 @@ void CGOpenMPRuntime::emitTargetCall(Cod for (CapturedStmt::const_capture_iterator CI = CS.capture_begin(), CE = CS.capture_end(); CI != CE; ++CI, ++RI, ++CV) { -StringRef Name; QualType Ty; CurBasePointers.clear(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state
szepet created this revision. Herald added subscribers: baloghadamsoftware, whisperity. First, I am not exactly sure what are the requirements for moving a checker out of alpha. However, the checker seems to work with a low false positive rate. (<15 on the LLVM, 6 effectively different) Also found a true positive (well, it was only example code but still!) which fixes was sent and accepted in patch https://reviews.llvm.org/D32939 . Is it enough or should I check it on other open source projects? If so, what results are acceptable? ( @NoQ probably has already used it as well, maybe can have some more comments on the results.) https://reviews.llvm.org/D38675 Files: include/clang/StaticAnalyzer/Checkers/Checkers.td Index: include/clang/StaticAnalyzer/Checkers/Checkers.td === --- include/clang/StaticAnalyzer/Checkers/Checkers.td +++ include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -272,6 +272,11 @@ HelpText<"Checks C++ copy and move assignment operators for self assignment">, DescFile<"CXXSelfAssignmentChecker.cpp">; +def MisusedMovedObjectChecker : Checker<"MisusedMovedObject">, + HelpText<"Method calls on a moved-from object and copying a moved-from " + "object will be reported">, + DescFile<"MisusedMovedObjectChecker.cpp">; + } // end: "cplusplus" let ParentPackage = CplusplusOptIn in { @@ -293,11 +298,6 @@ HelpText<"Check for iterators used outside their valid ranges">, DescFile<"IteratorChecker.cpp">; -def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">, - HelpText<"Method calls on a moved-from object and copying a moved-from " - "object will be reported">, - DescFile<"MisusedMovedObjectChecker.cpp">; - } // end: "alpha.cplusplus" Index: include/clang/StaticAnalyzer/Checkers/Checkers.td === --- include/clang/StaticAnalyzer/Checkers/Checkers.td +++ include/clang/StaticAnalyzer/Checkers/Checkers.td @@ -272,6 +272,11 @@ HelpText<"Checks C++ copy and move assignment operators for self assignment">, DescFile<"CXXSelfAssignmentChecker.cpp">; +def MisusedMovedObjectChecker : Checker<"MisusedMovedObject">, + HelpText<"Method calls on a moved-from object and copying a moved-from " + "object will be reported">, + DescFile<"MisusedMovedObjectChecker.cpp">; + } // end: "cplusplus" let ParentPackage = CplusplusOptIn in { @@ -293,11 +298,6 @@ HelpText<"Check for iterators used outside their valid ranges">, DescFile<"IteratorChecker.cpp">; -def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">, - HelpText<"Method calls on a moved-from object and copying a moved-from " - "object will be reported">, - DescFile<"MisusedMovedObjectChecker.cpp">; - } // end: "alpha.cplusplus" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38674: [analyzer] MisusedMovedObjectChecker: More precise warning message
szepet created this revision. Herald added subscribers: baloghadamsoftware, whisperity. Added new enum in order to differentiate the warning messages on "misusing" into 3 categories: function calls, moving an object, copying an object. (At the moment the checker gives the same message in case of copying and moving.) Additional test cases added as well. Note: The dependency is only added for the reason not having conflict problems on the test cases. https://reviews.llvm.org/D38674 Files: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp test/Analysis/MisusedMovedObject.cpp Index: test/Analysis/MisusedMovedObject.cpp === --- test/Analysis/MisusedMovedObject.cpp +++ test/Analysis/MisusedMovedObject.cpp @@ -38,6 +38,7 @@ B() = default; B(const B &) = default; B(B &&) = default; + B& operator=(const B ) = default; void operator=(B &) { return; } @@ -70,6 +71,12 @@ A(A &, char *k) { moveconstruct(std::move(other)); } + void operator=(const A ) { +i = other.i; +d = other.d; +b = other.b; +return; + } void operator=(A &) { moveconstruct(std::move(other)); return; @@ -105,17 +112,42 @@ } void simpleMoveCtorTest() { - A a; - A b; - b = std::move(a); // expected-note {{'a' became 'moved-from' here}} - a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + { +A a; +A b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +a.foo();// expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + } + { +A a; +A b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +b = a; // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}} + } + { +A a; +A b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +b = std::move(a); // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}} + } } void simpleMoveAssignementTest() { - A a; - A b; - b = std::move(a); // expected-note {{'a' became 'moved-from' here}} - a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + { +A a; +A b; +b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +a.foo(); // expected-warning {{Method call on a 'moved-from' object 'a'}} expected-note {{Method call on a 'moved-from' object 'a'}} + } + { +A a; +A b; +b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +A c(a); // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}} + } + { +A a; +A b; +b = std::move(a); // expected-note {{'a' became 'moved-from' here}} +A c(std::move(a)); // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}} + } } void moveInInitListTest() { @@ -270,7 +302,7 @@ { A a; for (int i = 0; i < bignum(); i++) { // expected-note {{Loop condition is true. Entering loop body}} expected-note {{Loop condition is true. Entering loop body}} - constCopyOrMoveCall(std::move(a)); // expected-warning {{Copying a 'moved-from' object 'a'}} expected-note {{Copying a 'moved-from' object 'a'}} + constCopyOrMoveCall(std::move(a)); // expected-warning {{Moving a 'moved-from' object 'a'}} expected-note {{Moving a 'moved-from' object 'a'}} // expected-note@-1 {{'a' became 'moved-from' here}} } } @@ -447,7 +479,7 @@ // Same thing, but with a switch statement. { A a, b; -switch (i) { // expected-note {{Control jumps to 'case 1:' at line 451}} +switch (i) { // expected-note {{Control jumps to 'case 1:' at line 483}} case 1: b = std::move(a); // no-warning break;// expected-note {{Execution jumps to the end of the function}} @@ -459,7 +491,7 @@ // However, if there's a fallthrough, we do warn. { A a, b; -switch (i) { // expected-note {{Control jumps to 'case 1:' at line 463}} +switch (i) { // expected-note {{Control jumps to 'case 1:' at line 495}} case 1: b = std::move(a); // expected-note {{'a' became 'moved-from' here}} case 2: Index: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp @@ -58,6 +58,7 @@ const LocationContext *LCtx, const CallEvent *Call) const; private: + enum MisuseKind {MK_FunCall, MK_Copy, MK_Move}; class MovedBugVisitor :
[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part
jina.nahias updated this revision to Diff 118166. https://reviews.llvm.org/D38672 Files: lib/Headers/avx512fintrin.h lib/Headers/avx512vlintrin.h test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c Index: test/CodeGen/avx512vl-builtins.c === --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -5630,73 +5630,85 @@ } __m256 test_mm256_shuffle_f32x4(__m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> return _mm256_shuffle_f32x4(__A, __B, 3); } __m256 test_mm256_mask_shuffle_f32x4(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}} return _mm256_mask_shuffle_f32x4(__W, __U, __A, __B, 3); } __m256 test_mm256_maskz_shuffle_f32x4(__mmask8 __U, __m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <8 x float> %{{.*}}, <8 x float> %{{.*}}, <8 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}} return _mm256_maskz_shuffle_f32x4(__U, __A, __B, 3); } __m256d test_mm256_shuffle_f64x2(__m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> return _mm256_shuffle_f64x2(__A, __B, 3); } __m256d test_mm256_mask_shuffle_f64x2(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}} return _mm256_mask_shuffle_f64x2(__W, __U, __A, __B, 3); } __m256d test_mm256_maskz_shuffle_f64x2(__mmask8 __U, __m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}} return _mm256_maskz_shuffle_f64x2(__U, __A, __B, 3); } __m256i test_mm256_shuffle_i32x4(__m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> return _mm256_shuffle_i32x4(__A, __B, 3); } __m256i test_mm256_mask_shuffle_i32x4(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}} return _mm256_mask_shuffle_i32x4(__W, __U, __A, __B, 3); } __m256i test_mm256_maskz_shuffle_i32x4(__mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}} return _mm256_maskz_shuffle_i32x4(__U, __A, __B, 3); } __m256i test_mm256_shuffle_i64x2(__m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> return _mm256_shuffle_i64x2(__A, __B, 3); } __m256i test_mm256_mask_shuffle_i64x2(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}} return _mm256_mask_shuffle_i64x2(__W, __U, __A, __B, 3); } __m256i test_mm256_maskz_shuffle_i64x2(__mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x i64>
[PATCH] D38596: Implement attribute target multiversioning
aaron.ballman added a comment. The attribute and sema bits look good to me, but I agree that you might want Richard's opinions before committing. Comment at: lib/Sema/SemaDecl.cpp:9264 + + if (auto *CMD = dyn_cast(FD)) +if (CMD->isVirtual()) { `const auto *` https://reviews.llvm.org/D38596 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38672: lowering shuffle f/i intrinsic - clang part
jina.nahias created this revision. https://reviews.llvm.org/D38672 Files: lib/Headers/avx512fintrin.h lib/Headers/avx512vlintrin.h test/CodeGen/avx512f-builtins.c test/CodeGen/avx512vl-builtins.c Index: test/CodeGen/avx512vl-builtins.c === --- test/CodeGen/avx512vl-builtins.c +++ test/CodeGen/avx512vl-builtins.c @@ -5630,73 +5630,85 @@ } __m256 test_mm256_shuffle_f32x4(__m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> return _mm256_shuffle_f32x4(__A, __B, 3); } __m256 test_mm256_mask_shuffle_f32x4(__m256 __W, __mmask8 __U, __m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}} return _mm256_mask_shuffle_f32x4(__W, __U, __A, __B, 3); } __m256 test_mm256_maskz_shuffle_f32x4(__mmask8 __U, __m256 __A, __m256 __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_f32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.f32x4 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}} return _mm256_maskz_shuffle_f32x4(__U, __A, __B, 3); } __m256d test_mm256_shuffle_f64x2(__m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> return _mm256_shuffle_f64x2(__A, __B, 3); } __m256d test_mm256_mask_shuffle_f64x2(__m256d __W, __mmask8 __U, __m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}} return _mm256_mask_shuffle_f64x2(__W, __U, __A, __B, 3); } __m256d test_mm256_maskz_shuffle_f64x2(__mmask8 __U, __m256d __A, __m256d __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_f64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.f64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}1, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x double> %{{.*}}, <4 x double> %{{.*}} return _mm256_maskz_shuffle_f64x2(__U, __A, __B, 3); } __m256i test_mm256_shuffle_i32x4(__m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> return _mm256_shuffle_i32x4(__A, __B, 3); } __m256i test_mm256_mask_shuffle_i32x4(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}} return _mm256_mask_shuffle_i32x4(__W, __U, __A, __B, 3); } __m256i test_mm256_maskz_shuffle_i32x4(__mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_i32x4 - // CHECK: @llvm.x86.avx512.mask.shuf.i32x4 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}} return _mm256_maskz_shuffle_i32x4(__U, __A, __B, 3); } __m256i test_mm256_shuffle_i64x2(__m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <4 x i32> return _mm256_shuffle_i64x2(__A, __B, 3); } __m256i test_mm256_mask_shuffle_i64x2(__m256i __W, __mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_mask_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}} return _mm256_mask_shuffle_i64x2(__W, __U, __A, __B, 3); } __m256i test_mm256_maskz_shuffle_i64x2(__mmask8 __U, __m256i __A, __m256i __B) { // CHECK-LABEL: @test_mm256_maskz_shuffle_i64x2 - // CHECK: @llvm.x86.avx512.mask.shuf.i64x2 + // CHECK: shufflevector <4 x double> %{{.*}}, <4 x double> %{{.*}}, <4 x i32> + // CHECK: shufflevector <8 x i1> %{{.*}}, <8 x i1> %{{.*}}, <4 x i32> + // CHECK: select <4 x i1>
[libclc] r315170 - ldexp: Fix double precision function return type
Author: jvesely Date: Sat Oct 7 23:56:14 2017 New Revision: 315170 URL: http://llvm.org/viewvc/llvm-project?rev=315170=rev Log: ldexp: Fix double precision function return type Fixes ~1200 external calls from nvtpx library. Reviewer: Jeroen Ketema Signed-off-by: Jan VeselyModified: libclc/trunk/generic/include/math/clc_ldexp.h Modified: libclc/trunk/generic/include/math/clc_ldexp.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/math/clc_ldexp.h?rev=315170=315169=315170=diff == --- libclc/trunk/generic/include/math/clc_ldexp.h (original) +++ libclc/trunk/generic/include/math/clc_ldexp.h Sat Oct 7 23:56:14 2017 @@ -2,5 +2,5 @@ _CLC_DEF _CLC_OVERLOAD float __clc_ldexp #ifdef cl_khr_fp64 #pragma OPENCL EXTENSION cl_khr_fp64 : enable - _CLC_DEF _CLC_OVERLOAD float __clc_ldexp(double, int); + _CLC_DEF _CLC_OVERLOAD double __clc_ldexp(double, int); #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D36562: [Bitfield] Make the bitfield a separate location if it has width of legal integer type and its bit offset is naturally aligned for the type
hfinkel added inline comments. Comment at: include/clang/Basic/DiagnosticDriverKinds.td:335 +def warn_drv_fine_grained_bitfield_accesses_ignored : Warning< + "option '-ffine-grained-bitfield-accesses' cannot be enabled together with sanitizer; flag ignored">, + InGroup; with a sanitizer Comment at: include/clang/Driver/Options.td:1041 + "ffine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>, + HelpText<"Use separate access for bitfields with legal widths and alignments.">; +def fno_fine_grained_bitfield_accesses : Flag<["-"], access -> accesses Comment at: include/clang/Driver/Options.td:1044 + "fno-fine-grained-bitfield-accesses">, Group, Flags<[CC1Option]>, + HelpText<"Use a big integer wrap for a consecutive run of bitfields.">; + Use large-integer access for consecutive bitfield runs. Comment at: include/clang/Frontend/CodeGenOptions.def:182 CODEGENOPT(SoftFloat , 1, 0) ///< -soft-float. +CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Use separate access for bitfields + ///< with legal widths and alignments. These lines are too long. Comment at: lib/CodeGen/CGRecordLayoutBuilder.cpp:449 +// Otherwise, try to add bitfields to the run. +if (Run != FieldEnd && !IsBetterAsSingleFieldRun(Run) && +Field != FieldEnd && !IsBetterAsSingleFieldRun(Field) && Why do you have the `IsBetterAsSingleFieldRun(Run)` check here (where we'll evaluate it multiple times (for all of the fields in the run)). Can't you make the predicate above directly? // Any non-zero-length bitfield can start a new run. if (Field->getBitWidthValue(Context) != 0 && !IsBetterAsSingleFieldRun(Field)) { Run = Field; StartBitOffset = getFieldBitOffset(*Field); ... Repository: rL LLVM https://reviews.llvm.org/D36562 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits