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

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

Issue 2490473007: Improved check for trivial templates. (Closed)
Patch Set: Check in Type::Typedef, and add a test expectations file. 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.txt » ('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 const std::string name = TT->getDecl()->getNameAsString();
679 if (name == "atomic_int") {
dcheng 2016/11/10 00:41:03 Nit: I wonder if we should get the decl context an
680 (*trivial_member)++;
681 return;
682 }
678 type = TT->getDecl()->getUnderlyingType().getTypePtr(); 683 type = TT->getDecl()->getUnderlyingType().getTypePtr();
679 } 684 }
680 CountType(type, 685 CountType(type,
681 trivial_member, 686 trivial_member,
682 non_trivial_member, 687 non_trivial_member,
683 templated_non_trivial_member); 688 templated_non_trivial_member);
684 break; 689 break;
685 } 690 }
686 default: { 691 default: {
687 // Stupid assumption: anything we see that isn't the above is a POD 692 // Stupid assumption: anything we see that isn't the above is a POD
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 } 1019 }
1015 } else if (non_reference_type->isPointerType()) { 1020 } else if (non_reference_type->isPointerType()) {
1016 non_reference_type = non_reference_type->getPointeeType(); 1021 non_reference_type = non_reference_type->getPointeeType();
1017 continue; 1022 continue;
1018 } 1023 }
1019 break; 1024 break;
1020 } 1025 }
1021 } 1026 }
1022 1027
1023 } // namespace chrome_checker 1028 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « no previous file | tools/clang/plugins/tests/trivial_ctor.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698