Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Side by Side Diff: tools/clang/plugins/FindBadConstructsConsumer.cpp

Issue 2490473007: Improved check for trivial templates. (Closed)
Patch Set: Check isStdNamespace, too. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/clang/plugins/tests/trivial_ctor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 } 668 }
669 case Type::Elaborated: { 669 case Type::Elaborated: {
670 CountType(dyn_cast<ElaboratedType>(type)->getNamedType().getTypePtr(), 670 CountType(dyn_cast<ElaboratedType>(type)->getNamedType().getTypePtr(),
671 trivial_member, 671 trivial_member,
672 non_trivial_member, 672 non_trivial_member,
673 templated_non_trivial_member); 673 templated_non_trivial_member);
674 break; 674 break;
675 } 675 }
676 case Type::Typedef: { 676 case Type::Typedef: {
677 while (const TypedefType* TT = dyn_cast<TypedefType>(type)) { 677 while (const TypedefType* TT = dyn_cast<TypedefType>(type)) {
678 type = TT->getDecl()->getUnderlyingType().getTypePtr(); 678 if (auto* decl = TT->getDecl()) {
679 const std::string name = decl->getNameAsString();
680 if (auto* context = decl->getDeclContext()) {
dcheng 2016/11/10 06:58:56 I've learned that null checking this shouldn't be
hans 2016/11/10 16:35:36 I don't think it should be necessary. I don't see
palmer 2016/11/10 23:25:58 Done.
681 if (name == "atomic_int" && context->isStdNamespace()) {
682 (*trivial_member)++;
683 return;
684 }
685 }
686 type = decl->getUnderlyingType().getTypePtr();
687 }
679 } 688 }
680 CountType(type, 689 CountType(type,
681 trivial_member, 690 trivial_member,
682 non_trivial_member, 691 non_trivial_member,
683 templated_non_trivial_member); 692 templated_non_trivial_member);
684 break; 693 break;
685 } 694 }
686 default: { 695 default: {
687 // Stupid assumption: anything we see that isn't the above is a POD 696 // Stupid assumption: anything we see that isn't the above is a POD
688 // or reference type. 697 // or reference type.
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1023 }
1015 } else if (non_reference_type->isPointerType()) { 1024 } else if (non_reference_type->isPointerType()) {
1016 non_reference_type = non_reference_type->getPointeeType(); 1025 non_reference_type = non_reference_type->getPointeeType();
1017 continue; 1026 continue;
1018 } 1027 }
1019 break; 1028 break;
1020 } 1029 }
1021 } 1030 }
1022 1031
1023 } // namespace chrome_checker 1032 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « no previous file | tools/clang/plugins/tests/trivial_ctor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698