diff options
author | Marcin Swiderski <marcin.sfider@gmail.com> | 2010-10-25 07:00:40 +0000 |
---|---|---|
committer | Marcin Swiderski <marcin.sfider@gmail.com> | 2010-10-25 07:00:40 +0000 |
commit | 52e4bc1fede9b96bf6caec8fe6138e675ea14146 (patch) | |
tree | 0af2c9d3101b5cbce8a601ac4cb65de113c20b89 /clang/lib/Analysis/CFG.cpp | |
parent | a242417a90973f2a98cbf5b64681754d47809d30 (diff) | |
download | bcm5719-llvm-52e4bc1fede9b96bf6caec8fe6138e675ea14146.tar.gz bcm5719-llvm-52e4bc1fede9b96bf6caec8fe6138e675ea14146.zip |
Added generation of destructors for constant size arrays.
There's only one destructor call generated for each not empty array (at least for now this should be enough).
llvm-svn: 117251
Diffstat (limited to 'clang/lib/Analysis/CFG.cpp')
-rw-r--r-- | clang/lib/Analysis/CFG.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 6f7be9a252c..1026035b3bb 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -641,8 +641,14 @@ LocalScope* CFGBuilder::addLocalScopeForVarDecl(VarDecl* VD, return Scope; } - // Check if type is a C++ class with non-trivial destructor. + // Check for constant size array. Set type to array element type. + if (const ConstantArrayType *AT = Context->getAsConstantArrayType(QT)) { + if (AT->getSize() == 0) + return Scope; + QT = AT->getElementType(); + } + // Check if type is a C++ class with non-trivial destructor. if (const CXXRecordDecl* CD = QT->getAsCXXRecordDecl()) if (!CD->hasTrivialDestructor()) { // Add the variable to scope @@ -2707,9 +2713,11 @@ static void print_elem(llvm::raw_ostream &OS, StmtPrinterHelper* Helper, VarDecl* VD = DE.getVarDecl(); Helper->handleDecl(VD, OS); - Type* T = VD->getType().getTypePtr(); + const Type* T = VD->getType().getTypePtr(); if (const ReferenceType* RT = T->getAs<ReferenceType>()) T = RT->getPointeeType().getTypePtr(); + else if (const Type *ET = T->getArrayElementTypeNoTypeQual()) + T = ET; OS << ".~" << T->getAsCXXRecordDecl()->getName().str() << "()"; OS << " (Implicit destructor)\n"; |