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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
646 (*non_trivial_member)++; | 646 (*non_trivial_member)++; |
647 break; | 647 break; |
648 } | 648 } |
649 case Type::TemplateSpecialization: { | 649 case Type::TemplateSpecialization: { |
650 TemplateName name = | 650 TemplateName name = |
651 dyn_cast<TemplateSpecializationType>(type)->getTemplateName(); | 651 dyn_cast<TemplateSpecializationType>(type)->getTemplateName(); |
652 bool whitelisted_template = false; | 652 bool whitelisted_template = false; |
653 | 653 |
654 // HACK: I'm at a loss about how to get the syntax checker to get | 654 // HACK: I'm at a loss about how to get the syntax checker to get |
655 // whether a template is externed or not. For the first pass here, | 655 // whether a template is externed or not. For the first pass here, |
656 // just do retarded string comparisons. | 656 // just do simple string comparisons. |
657 // | |
658 // The check for "atomic_int" is a quick hack; The real fix will be to | |
659 // check the class after template instantiation. TODO(dcheng): Do the real | |
dcheng
2016/11/08 21:06:20
=P
| |
660 // fix. https://bugs.chromium.org/p/chromium/issues/detail?id=663463 | |
657 if (TemplateDecl* decl = name.getAsTemplateDecl()) { | 661 if (TemplateDecl* decl = name.getAsTemplateDecl()) { |
658 std::string base_name = decl->getNameAsString(); | 662 std::string base_name = decl->getNameAsString(); |
659 if (base_name == "basic_string") | 663 if (base_name == "basic_string" || base_name == "atomic_int") |
660 whitelisted_template = true; | 664 whitelisted_template = true; |
661 } | 665 } |
662 | 666 |
663 if (whitelisted_template) | 667 if (whitelisted_template) |
664 (*non_trivial_member)++; | 668 (*non_trivial_member)++; |
665 else | 669 else |
666 (*templated_non_trivial_member)++; | 670 (*templated_non_trivial_member)++; |
667 break; | 671 break; |
668 } | 672 } |
669 case Type::Elaborated: { | 673 case Type::Elaborated: { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1014 } | 1018 } |
1015 } else if (non_reference_type->isPointerType()) { | 1019 } else if (non_reference_type->isPointerType()) { |
1016 non_reference_type = non_reference_type->getPointeeType(); | 1020 non_reference_type = non_reference_type->getPointeeType(); |
1017 continue; | 1021 continue; |
1018 } | 1022 } |
1019 break; | 1023 break; |
1020 } | 1024 } |
1021 } | 1025 } |
1022 | 1026 |
1023 } // namespace chrome_checker | 1027 } // namespace chrome_checker |
OLD | NEW |