| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "FindBadConstructsConsumer.h" | 5 #include "FindBadConstructsConsumer.h" |
| 6 | 6 |
| 7 #include "clang/Frontend/CompilerInstance.h" | 7 #include "clang/Frontend/CompilerInstance.h" |
| 8 #include "clang/AST/Attr.h" | 8 #include "clang/AST/Attr.h" |
| 9 #include "clang/Lex/Lexer.h" | 9 #include "clang/Lex/Lexer.h" |
| 10 #include "llvm/Support/raw_ostream.h" | 10 #include "llvm/Support/raw_ostream.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 // warning in some cases where it is emitted in other configs, but | 299 // warning in some cases where it is emitted in other configs, but |
| 300 // that's the better tradeoff at this point). | 300 // that's the better tradeoff at this point). |
| 301 // TODO(dcheng): With the RecursiveASTVisitor, these warnings might | 301 // TODO(dcheng): With the RecursiveASTVisitor, these warnings might |
| 302 // be emitted on other platforms too, reevaluate if we want to keep | 302 // be emitted on other platforms too, reevaluate if we want to keep |
| 303 // surpressing this then http://crbug.com/467288 | 303 // surpressing this then http://crbug.com/467288 |
| 304 if (!record->hasAttr<DLLExportAttr>()) | 304 if (!record->hasAttr<DLLExportAttr>()) |
| 305 emitWarning(record_location, | 305 emitWarning(record_location, |
| 306 "Complex class/struct needs an explicit out-of-line " | 306 "Complex class/struct needs an explicit out-of-line " |
| 307 "copy constructor."); | 307 "copy constructor."); |
| 308 } else { | 308 } else { |
| 309 emitWarning(it->getInnerLocStart(), | 309 // See the comment in the previous branch about copy constructors. |
| 310 "Complex constructor has an inlined body."); | 310 // This does the same for implicit move constructors. |
| 311 bool is_likely_compiler_generated_dllexport_move_ctor = |
| 312 it->isMoveConstructor() && |
| 313 !record->hasUserDeclaredMoveConstructor() && |
| 314 record->hasAttr<DLLExportAttr>(); |
| 315 if (!is_likely_compiler_generated_dllexport_move_ctor) |
| 316 emitWarning(it->getInnerLocStart(), |
| 317 "Complex constructor has an inlined body."); |
| 311 } | 318 } |
| 312 } else if (it->isInlined() && !it->isInlineSpecified() && | 319 } else if (it->isInlined() && !it->isInlineSpecified() && |
| 313 !it->isDeleted() && (!it->isCopyOrMoveConstructor() || | 320 !it->isDeleted() && (!it->isCopyOrMoveConstructor() || |
| 314 it->isExplicitlyDefaulted())) { | 321 it->isExplicitlyDefaulted())) { |
| 315 // isInlined() is a more reliable check than hasInlineBody(), but | 322 // isInlined() is a more reliable check than hasInlineBody(), but |
| 316 // unfortunately, it results in warnings for implicit copy/move | 323 // unfortunately, it results in warnings for implicit copy/move |
| 317 // constructors in the previously mentioned situation. To preserve | 324 // constructors in the previously mentioned situation. To preserve |
| 318 // compatibility with existing Chromium code, only warn if it's an | 325 // compatibility with existing Chromium code, only warn if it's an |
| 319 // explicitly defaulted copy or move constructor. | 326 // explicitly defaulted copy or move constructor. |
| 320 emitWarning(it->getInnerLocStart(), | 327 emitWarning(it->getInnerLocStart(), |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 855 // one of those, it means there is at least one member after a factory. | 862 // one of those, it means there is at least one member after a factory. |
| 856 if (weak_ptr_factory_location.isValid() && | 863 if (weak_ptr_factory_location.isValid() && |
| 857 !param_is_weak_ptr_factory_to_self) { | 864 !param_is_weak_ptr_factory_to_self) { |
| 858 diagnostic().Report(weak_ptr_factory_location, | 865 diagnostic().Report(weak_ptr_factory_location, |
| 859 diag_weak_ptr_factory_order_); | 866 diag_weak_ptr_factory_order_); |
| 860 } | 867 } |
| 861 } | 868 } |
| 862 } | 869 } |
| 863 | 870 |
| 864 } // namespace chrome_checker | 871 } // namespace chrome_checker |
| OLD | NEW |