clang-tools  3.8.0
TypeTraits.cpp
Go to the documentation of this file.
1 //===--- TypeTraits.cpp - clang-tidy---------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "TypeTraits.h"
11 #include "clang/AST/ASTContext.h"
12 #include "clang/AST/DeclCXX.h"
13 
14 namespace clang {
15 namespace tidy {
16 namespace type_traits {
17 
18 namespace {
19 bool classHasTrivialCopyAndDestroy(QualType Type) {
20  auto *Record = Type->getAsCXXRecordDecl();
21  return Record && Record->hasDefinition() &&
22  !Record->hasNonTrivialCopyConstructor() &&
23  !Record->hasNonTrivialDestructor();
24 }
25 } // namespace
26 
27 llvm::Optional<bool> isExpensiveToCopy(QualType Type, ASTContext &Context) {
28  if (Type->isDependentType())
29  return llvm::None;
30  return !Type.isTriviallyCopyableType(Context) &&
31  !classHasTrivialCopyAndDestroy(Type);
32 }
33 
34 } // type_traits
35 } // namespace tidy
36 } // namespace clang
llvm::Optional< bool > isExpensiveToCopy(QualType Type, ASTContext &Context)
Definition: TypeTraits.cpp:27
ClangTidyContext & Context
Definition: ClangTidy.cpp:93