diff options
author | dcheng <dcheng@chromium.org> | 2015-03-11 20:01:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-12 03:02:08 +0000 |
commit | e28744603bed12e58eded50f63b852b1a4f7dba3 (patch) | |
tree | 4803132f8c188d6100863922fd0bb0f20543a631 /tools/clang | |
parent | 5e468cbea3590c900f967b2cb43354442997b926 (diff) | |
download | chromium_src-e28744603bed12e58eded50f63b852b1a4f7dba3.zip chromium_src-e28744603bed12e58eded50f63b852b1a4f7dba3.tar.gz chromium_src-e28744603bed12e58eded50f63b852b1a4f7dba3.tar.bz2 |
Don't warn about inline ctors/dtors if inline is specified.
Allow the use of 'inline' as an escape hatch for the checks for inline
ctors/dtors bloating code size.
BUG=464911
Review URL: https://codereview.chromium.org/986113003
Cr-Commit-Position: refs/heads/master@{#320218}
Diffstat (limited to 'tools/clang')
-rw-r--r-- | tools/clang/plugins/FindBadConstructsConsumer.cpp | 9 | ||||
-rw-r--r-- | tools/clang/plugins/tests/inline_ctor.h | 20 |
2 files changed, 25 insertions, 4 deletions
diff --git a/tools/clang/plugins/FindBadConstructsConsumer.cpp b/tools/clang/plugins/FindBadConstructsConsumer.cpp index dabc6e9..770e255 100644 --- a/tools/clang/plugins/FindBadConstructsConsumer.cpp +++ b/tools/clang/plugins/FindBadConstructsConsumer.cpp @@ -296,9 +296,9 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( emitWarning(it->getInnerLocStart(), "Complex constructor has an inlined body."); } - } else if (it->isInlined() && !it->isDeleted() && - (!it->isCopyOrMoveConstructor() || - it->isExplicitlyDefaulted())) { + } else if (it->isInlined() && !it->isInlineSpecified() && + !it->isDeleted() && (!it->isCopyOrMoveConstructor() || + it->isExplicitlyDefaulted())) { // isInlined() is a more reliable check than hasInlineBody(), but // unfortunately, it results in warnings for implicit copy/move // constructors in the previously mentioned situation. To preserve @@ -319,7 +319,8 @@ void FindBadConstructsConsumer::CheckCtorDtorWeight( "Complex class/struct needs an explicit out-of-line " "destructor."); } else if (CXXDestructorDecl* dtor = record->getDestructor()) { - if (dtor->isInlined() && !dtor->isDeleted()) { + if (dtor->isInlined() && !dtor->isInlineSpecified() && + !dtor->isDeleted()) { emitWarning(dtor->getInnerLocStart(), "Complex destructor has an inline body."); } diff --git a/tools/clang/plugins/tests/inline_ctor.h b/tools/clang/plugins/tests/inline_ctor.h index c1be1ec..9c6c286 100644 --- a/tools/clang/plugins/tests/inline_ctor.h +++ b/tools/clang/plugins/tests/inline_ctor.h @@ -30,4 +30,24 @@ class DeletedMembersInHeaderAreOKThough { std::vector<std::string> two_; }; +class ExplicitlyInlinedIsAlsoOK { + ExplicitlyInlinedIsAlsoOK(); + ~ExplicitlyInlinedIsAlsoOK(); + ExplicitlyInlinedIsAlsoOK(const ExplicitlyInlinedIsAlsoOK&); + + private: + std::vector<int> one_; + std::vector<std::string> two_; +}; + +inline ExplicitlyInlinedIsAlsoOK::ExplicitlyInlinedIsAlsoOK() { +} + +inline ExplicitlyInlinedIsAlsoOK::~ExplicitlyInlinedIsAlsoOK() { +} + +inline ExplicitlyInlinedIsAlsoOK::ExplicitlyInlinedIsAlsoOK( + const ExplicitlyInlinedIsAlsoOK&) { +} + #endif // INLINE_CTOR_H_ |