OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This clang plugin checks various invariants of the Blink garbage | 5 // This clang plugin checks various invariants of the Blink garbage |
6 // collection infrastructure. | 6 // collection infrastructure. |
7 // | 7 // |
8 // Errors are described at: | 8 // Errors are described at: |
9 // http://www.chromium.org/developers/blink-gc-plugin-errors | 9 // http://www.chromium.org/developers/blink-gc-plugin-errors |
10 | 10 |
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 return true; | 1053 return true; |
1054 return false; | 1054 return false; |
1055 } | 1055 } |
1056 | 1056 |
1057 bool InCheckedNamespace(RecordInfo* info) { | 1057 bool InCheckedNamespace(RecordInfo* info) { |
1058 if (!info) | 1058 if (!info) |
1059 return false; | 1059 return false; |
1060 DeclContext* context = info->record()->getDeclContext(); | 1060 DeclContext* context = info->record()->getDeclContext(); |
1061 if (context->isRecord()) | 1061 if (context->isRecord()) |
1062 return InCheckedNamespace(cache_.Lookup(context)); | 1062 return InCheckedNamespace(cache_.Lookup(context)); |
1063 if (context->isNamespace()) { | 1063 while (context->isNamespace()) { |
1064 const NamespaceDecl* decl = dyn_cast<NamespaceDecl>(context); | 1064 NamespaceDecl* decl = dyn_cast<NamespaceDecl>(context); |
1065 if (decl->isAnonymousNamespace()) | 1065 if (decl->isAnonymousNamespace()) |
1066 return false; | 1066 return false; |
1067 return options_.checked_namespaces.find(decl->getNameAsString()) != | 1067 if (options_.checked_namespaces.find(decl->getNameAsString()) != |
1068 options_.checked_namespaces.end(); | 1068 options_.checked_namespaces.end()) |
| 1069 return true; |
| 1070 context = decl->getDeclContext(); |
1069 } | 1071 } |
1070 return false; | 1072 return false; |
1071 } | 1073 } |
1072 | 1074 |
1073 bool GetFilename(SourceLocation loc, string* filename) { | 1075 bool GetFilename(SourceLocation loc, string* filename) { |
1074 const SourceManager& source_manager = instance_.getSourceManager(); | 1076 const SourceManager& source_manager = instance_.getSourceManager(); |
1075 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); | 1077 SourceLocation spelling_location = source_manager.getSpellingLoc(loc); |
1076 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); | 1078 PresumedLoc ploc = source_manager.getPresumedLoc(spelling_location); |
1077 if (ploc.isInvalid()) { | 1079 if (ploc.isInvalid()) { |
1078 // If we're in an invalid location, we're looking at things that aren't | 1080 // If we're in an invalid location, we're looking at things that aren't |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 | 1431 |
1430 private: | 1432 private: |
1431 BlinkGCPluginOptions options_; | 1433 BlinkGCPluginOptions options_; |
1432 }; | 1434 }; |
1433 | 1435 |
1434 } // namespace | 1436 } // namespace |
1435 | 1437 |
1436 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( | 1438 static FrontendPluginRegistry::Add<BlinkGCPluginAction> X( |
1437 "blink-gc-plugin", | 1439 "blink-gc-plugin", |
1438 "Check Blink GC invariants"); | 1440 "Check Blink GC invariants"); |
OLD | NEW |