Summary: IsExpensiveToCopy can return false positives for incomplete types, so ignore them.
All existing ClangTidy tests that depend on this function still pass as the types are complete.
Reviewers: alexfh, aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26195
llvm-svn: 286008
llvm::Optional<bool> isExpensiveToCopy(QualType Type,
const ASTContext &Context) {
- if (Type->isDependentType())
+ if (Type->isDependentType() || Type->isIncompleteType())
return llvm::None;
return !Type.isTriviallyCopyableType(Context) &&
!classHasTrivialCopyAndDestroy(Type) &&
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -fix-errors -- --std=c++11
// CHECK-FIXES: #include <utility>
ExpensiveToCopyType B;
B = A;
}
+
+// Ensure that incomplete types result in an error from the frontend and not a
+// clang-tidy diagnostic about IncompleteType being expensive to copy.
+struct IncompleteType;
+void NegativeForIncompleteType(IncompleteType I) {
+ // CHECK-MESSAGES: [[@LINE-1]]:47: error: variable has incomplete type 'IncompleteType' [clang-diagnostic-error]
+}