[clang-tools-extra] r251103 - Make isExpensiveToCopy() tri-state.
Manuel Klimek via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 23 03:00:58 PDT 2015
Author: klimek
Date: Fri Oct 23 05:00:50 2015
New Revision: 251103
URL: http://llvm.org/viewvc/llvm-project?rev=251103&view=rev
Log:
Make isExpensiveToCopy() tri-state.
This allows returning "don't know" for dependent types.
Modified:
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
Modified: clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/Matchers.h?rev=251103&r1=251102&r2=251103&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/Matchers.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/Matchers.h Fri Oct 23 05:00:50 2015
@@ -18,7 +18,9 @@ namespace tidy {
namespace matchers {
AST_MATCHER(QualType, isExpensiveToCopy) {
- return type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
+ llvm::Optional<bool> IsExpensive =
+ type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
+ return IsExpensive && *IsExpensive;
}
} // namespace matchers
Modified: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp?rev=251103&r1=251102&r2=251103&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp Fri Oct 23 05:00:50 2015
@@ -24,9 +24,11 @@ bool classHasTrivialCopyAndDestroy(QualT
}
} // namespace
-bool isExpensiveToCopy(QualType Type, ASTContext &Context) {
+llvm::Optional<bool> isExpensiveToCopy(QualType Type, ASTContext &Context) {
+ if (Type->isDependentType())
+ return llvm::None;
return !Type.isTriviallyCopyableType(Context) &&
- !classHasTrivialCopyAndDestroy(Type);
+ !classHasTrivialCopyAndDestroy(Type);
}
} // type_traits
Modified: clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h?rev=251103&r1=251102&r2=251103&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h Fri Oct 23 05:00:50 2015
@@ -18,7 +18,7 @@ namespace tidy {
namespace type_traits {
// \brief Returns true If \c Type is expensive to copy.
-bool isExpensiveToCopy(QualType Type, ASTContext &Context);
+llvm::Optional<bool> isExpensiveToCopy(QualType Type, ASTContext &Context);
} // type_traits
} // namespace tidy
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp?rev=251103&r1=251102&r2=251103&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp Fri Oct 23 05:00:50 2015
@@ -120,11 +120,6 @@ struct NegativeParamTriviallyCopyable {
int I_;
};
-template <typename T> struct NegativeDependentType {
- NegativeDependentType(T Value) : T_(Value) {}
- T T_;
-};
-
struct NegativeNotPassedByValue {
NegativeNotPassedByValue(const Movable &M) : M_(M) {}
NegativeNotPassedByValue(const Movable M) : M_(M) {}
More information about the cfe-commits
mailing list