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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 "constructor."); | 281 "constructor."); |
282 } else { | 282 } else { |
283 // Iterate across all the constructors in this file and yell if we | 283 // Iterate across all the constructors in this file and yell if we |
284 // find one that tries to be inline. | 284 // find one that tries to be inline. |
285 for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); | 285 for (CXXRecordDecl::ctor_iterator it = record->ctor_begin(); |
286 it != record->ctor_end(); | 286 it != record->ctor_end(); |
287 ++it) { | 287 ++it) { |
288 // The current check is buggy. An implicit copy constructor does not | 288 // The current check is buggy. An implicit copy constructor does not |
289 // have an inline body, so this check never fires for classes with a | 289 // have an inline body, so this check never fires for classes with a |
290 // user-declared out-of-line constructor. | 290 // user-declared out-of-line constructor. |
291 if (it->hasInlineBody()) { | 291 if (it->hasInlineBody() && options_.check_implicit_copy_ctors) { |
292 if (it->isCopyConstructor() && | 292 if (it->isCopyConstructor() && |
293 !record->hasUserDeclaredCopyConstructor()) { | 293 !record->hasUserDeclaredCopyConstructor()) { |
294 // In general, implicit constructors are generated on demand. But | 294 // In general, implicit constructors are generated on demand. But |
295 // in the Windows component build, dllexport causes instantiation of | 295 // in the Windows component build, dllexport causes instantiation of |
296 // the copy constructor which means that this fires on many more | 296 // the copy constructor which means that this fires on many more |
297 // classes. For now, suppress this on dllexported classes. | 297 // classes. For now, suppress this on dllexported classes. |
298 // (This does mean that windows component builds will not emit this | 298 // (This does mean that windows component builds will not emit this |
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 |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 // one of those, it means there is at least one member after a factory. | 866 // one of those, it means there is at least one member after a factory. |
867 if (weak_ptr_factory_location.isValid() && | 867 if (weak_ptr_factory_location.isValid() && |
868 !param_is_weak_ptr_factory_to_self) { | 868 !param_is_weak_ptr_factory_to_self) { |
869 diagnostic().Report(weak_ptr_factory_location, | 869 diagnostic().Report(weak_ptr_factory_location, |
870 diag_weak_ptr_factory_order_); | 870 diag_weak_ptr_factory_order_); |
871 } | 871 } |
872 } | 872 } |
873 } | 873 } |
874 | 874 |
875 } // namespace chrome_checker | 875 } // namespace chrome_checker |
OLD | NEW |