| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return record.isPOD() || | 94 return record.isPOD() || |
| 95 record.getDescribedClassTemplate() || | 95 record.getDescribedClassTemplate() || |
| 96 record.getTemplateSpecializationKind() || | 96 record.getTemplateSpecializationKind() || |
| 97 record.isDependentType(); | 97 record.isDependentType(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, | 102 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, |
| 103 const Options& options) | 103 const Options& options) |
| 104 : ChromeClassTester(instance), options_(options) { | 104 : ChromeClassTester(instance, options) { |
| 105 // Messages for virtual method specifiers. | 105 // Messages for virtual method specifiers. |
| 106 diag_method_requires_override_ = | 106 diag_method_requires_override_ = |
| 107 diagnostic().getCustomDiagID(getErrorLevel(), kMethodRequiresOverride); | 107 diagnostic().getCustomDiagID(getErrorLevel(), kMethodRequiresOverride); |
| 108 diag_redundant_virtual_specifier_ = | 108 diag_redundant_virtual_specifier_ = |
| 109 diagnostic().getCustomDiagID(getErrorLevel(), kRedundantVirtualSpecifier); | 109 diagnostic().getCustomDiagID(getErrorLevel(), kRedundantVirtualSpecifier); |
| 110 diag_base_method_virtual_and_final_ = | 110 diag_base_method_virtual_and_final_ = |
| 111 diagnostic().getCustomDiagID(getErrorLevel(), kBaseMethodVirtualAndFinal); | 111 diagnostic().getCustomDiagID(getErrorLevel(), kBaseMethodVirtualAndFinal); |
| 112 | 112 |
| 113 // Messages for destructors. | 113 // Messages for destructors. |
| 114 diag_no_explicit_dtor_ = | 114 diag_no_explicit_dtor_ = |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 if (CXXDestructorDecl* dtor = record->getDestructor()) { | 586 if (CXXDestructorDecl* dtor = record->getDestructor()) { |
| 587 if (dtor->getAccess() == AS_public) { | 587 if (dtor->getAccess() == AS_public) { |
| 588 loc = dtor->getInnerLocStart(); | 588 loc = dtor->getInnerLocStart(); |
| 589 return PublicDestructor; | 589 return PublicDestructor; |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 | 592 |
| 593 return None; | 593 return None; |
| 594 } | 594 } |
| 595 | 595 |
| 596 // Adds either a warning or error, based on the current handling of | |
| 597 // -Werror. | |
| 598 DiagnosticsEngine::Level FindBadConstructsConsumer::getErrorLevel() { | |
| 599 #if defined(LLVM_ON_WIN32) | |
| 600 // TODO(dcheng): Re-enable -Werror for these diagnostics on Windows once all | |
| 601 // the pre-existing warnings are cleaned up. https://crbug.com/467287 | |
| 602 return DiagnosticsEngine::Warning; | |
| 603 #else | |
| 604 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error | |
| 605 : DiagnosticsEngine::Warning; | |
| 606 #endif | |
| 607 } | |
| 608 | |
| 609 // Returns true if |base| specifies one of the Chromium reference counted | 596 // Returns true if |base| specifies one of the Chromium reference counted |
| 610 // classes (base::RefCounted / base::RefCountedThreadSafe). | 597 // classes (base::RefCounted / base::RefCountedThreadSafe). |
| 611 bool FindBadConstructsConsumer::IsRefCountedCallback( | 598 bool FindBadConstructsConsumer::IsRefCountedCallback( |
| 612 const CXXBaseSpecifier* base, | 599 const CXXBaseSpecifier* base, |
| 613 CXXBasePath& path, | 600 CXXBasePath& path, |
| 614 void* user_data) { | 601 void* user_data) { |
| 615 FindBadConstructsConsumer* self = | 602 FindBadConstructsConsumer* self = |
| 616 static_cast<FindBadConstructsConsumer*>(user_data); | 603 static_cast<FindBadConstructsConsumer*>(user_data); |
| 617 | 604 |
| 618 const TemplateSpecializationType* base_type = | 605 const TemplateSpecializationType* base_type = |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 // one of those, it means there is at least one member after a factory. | 817 // one of those, it means there is at least one member after a factory. |
| 831 if (weak_ptr_factory_location.isValid() && | 818 if (weak_ptr_factory_location.isValid() && |
| 832 !param_is_weak_ptr_factory_to_self) { | 819 !param_is_weak_ptr_factory_to_self) { |
| 833 diagnostic().Report(weak_ptr_factory_location, | 820 diagnostic().Report(weak_ptr_factory_location, |
| 834 diag_weak_ptr_factory_order_); | 821 diag_weak_ptr_factory_order_); |
| 835 } | 822 } |
| 836 } | 823 } |
| 837 } | 824 } |
| 838 | 825 |
| 839 } // namespace chrome_checker | 826 } // namespace chrome_checker |
| OLD | NEW |