diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-27 21:28:00 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-27 21:28:00 +0000 |
commit | f61103ef335fb273a98c1389e6fddaf796feb4b3 (patch) | |
tree | f0b407548143a8c0192a104a31992ab1b9e0a734 /lib/Sema/JumpDiagnostics.cpp | |
parent | 0903421e36c174a82597f83bd296f3cd5b5f169b (diff) |
Clean up my changes to jump-diagnostic handling for local variables of
class type (or array thereof), eliminating some redundant checks
(thanks Eli!) and adding some tests where the behavior differs in
C++98/03 vs. C++0x.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132218 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/JumpDiagnostics.cpp')
-rw-r--r-- | lib/Sema/JumpDiagnostics.cpp | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp index 44ba103fe0..c1bcbef146 100644 --- a/lib/Sema/JumpDiagnostics.cpp +++ b/lib/Sema/JumpDiagnostics.cpp @@ -140,35 +140,33 @@ static std::pair<unsigned,unsigned> // a trivial default constructor and a trivial destructor, a // cv-qualified version of one of these types, or an array of one of // the preceding types and is declared without an initializer (8.5). - if (VD->hasLocalStorage() && Context.getLangOptions().CPlusPlus) { - // Check whether this is a C++ class. - CXXRecordDecl *Record = T->getAsCXXRecordDecl(); - - if (const Expr *Init = VD->getInit()) { - bool CallsTrivialConstructor = false; - if (Record) { - // FIXME: With generalized initializer lists, this may - // classify "X x{};" as having no initializer. - if (const CXXConstructExpr *Construct - = dyn_cast<CXXConstructExpr>(Init)) - if (const CXXConstructorDecl *Constructor - = Construct->getConstructor()) - if (Constructor->isDefaultConstructor() && - ((Context.getLangOptions().CPlusPlus0x && - Record->hasTrivialDefaultConstructor()) || - (!Context.getLangOptions().CPlusPlus0x && - Record->isPOD()))) - CallsTrivialConstructor = true; - } - - if (!CallsTrivialConstructor) - InDiag = diag::note_protected_by_variable_init; + // Check whether this is a C++ class. + CXXRecordDecl *Record = T->getAsCXXRecordDecl(); + + if (const Expr *Init = VD->getInit()) { + bool CallsTrivialConstructor = false; + if (Record) { + // FIXME: With generalized initializer lists, this may + // classify "X x{};" as having no initializer. + if (const CXXConstructExpr *Construct + = dyn_cast<CXXConstructExpr>(Init)) + if (const CXXConstructorDecl *Constructor + = Construct->getConstructor()) + if (Constructor->isDefaultConstructor() && + ((Context.getLangOptions().CPlusPlus0x && + Record->hasTrivialDefaultConstructor()) || + (!Context.getLangOptions().CPlusPlus0x && + Record->isPOD()))) + CallsTrivialConstructor = true; } - // Note whether we have a class with a non-trivial destructor. - if (Record && !Record->hasTrivialDestructor()) - OutDiag = diag::note_exits_dtor; + if (!CallsTrivialConstructor) + InDiag = diag::note_protected_by_variable_init; } + + // Note whether we have a class with a non-trivial destructor. + if (Record && !Record->hasTrivialDestructor()) + OutDiag = diag::note_exits_dtor; } } |