| 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 "clang/Sema/Sema.h" | 10 #include "clang/Sema/Sema.h" |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 } | 768 } |
| 769 | 769 |
| 770 // Check |record| to determine if it has any problematic refcounting | 770 // Check |record| to determine if it has any problematic refcounting |
| 771 // issues and, if so, print them as warnings/errors based on the current | 771 // issues and, if so, print them as warnings/errors based on the current |
| 772 // value of getErrorLevel(). | 772 // value of getErrorLevel(). |
| 773 // | 773 // |
| 774 // If |record| is a C++ class, and if it inherits from one of the Chromium | 774 // If |record| is a C++ class, and if it inherits from one of the Chromium |
| 775 // ref-counting classes (base::RefCounted / base::RefCountedThreadSafe), | 775 // ref-counting classes (base::RefCounted / base::RefCountedThreadSafe), |
| 776 // ensure that there are no public destructors in the class hierarchy. This | 776 // ensure that there are no public destructors in the class hierarchy. This |
| 777 // is to guard against accidentally stack-allocating a RefCounted class or | 777 // is to guard against accidentally stack-allocating a RefCounted class or |
| 778 // sticking it in a non-ref-counted container (like scoped_ptr<>). | 778 // sticking it in a non-ref-counted container (like std::unique_ptr<>). |
| 779 void FindBadConstructsConsumer::CheckRefCountedDtors( | 779 void FindBadConstructsConsumer::CheckRefCountedDtors( |
| 780 SourceLocation record_location, | 780 SourceLocation record_location, |
| 781 CXXRecordDecl* record) { | 781 CXXRecordDecl* record) { |
| 782 // Skip anonymous structs. | 782 // Skip anonymous structs. |
| 783 if (record->getIdentifier() == NULL) | 783 if (record->getIdentifier() == NULL) |
| 784 return; | 784 return; |
| 785 | 785 |
| 786 // Determine if the current type is even ref-counted. | 786 // Determine if the current type is even ref-counted. |
| 787 CXXBasePaths refcounted_path; | 787 CXXBasePaths refcounted_path; |
| 788 if (!record->lookupInBases( | 788 if (!record->lookupInBases( |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 instance().getSourceManager().getSpellingLoc(fd->getLocation()))) | 943 instance().getSourceManager().getSpellingLoc(fd->getLocation()))) |
| 944 continue; | 944 continue; |
| 945 | 945 |
| 946 // Parse and build AST for yet-uninstantiated template functions. | 946 // Parse and build AST for yet-uninstantiated template functions. |
| 947 clang::LateParsedTemplate* lpt = sema.LateParsedTemplateMap[fd]; | 947 clang::LateParsedTemplate* lpt = sema.LateParsedTemplateMap[fd]; |
| 948 sema.LateTemplateParser(sema.OpaqueParser, *lpt); | 948 sema.LateTemplateParser(sema.OpaqueParser, *lpt); |
| 949 } | 949 } |
| 950 } | 950 } |
| 951 | 951 |
| 952 } // namespace chrome_checker | 952 } // namespace chrome_checker |
| OLD | NEW |