| 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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 instance().getSourceManager().getSpellingLoc(fd->getLocation()))) | 975 instance().getSourceManager().getSpellingLoc(fd->getLocation()))) |
| 976 continue; | 976 continue; |
| 977 | 977 |
| 978 // Parse and build AST for yet-uninstantiated template functions. | 978 // Parse and build AST for yet-uninstantiated template functions. |
| 979 clang::LateParsedTemplate* lpt = sema.LateParsedTemplateMap[fd].get(); | 979 clang::LateParsedTemplate* lpt = sema.LateParsedTemplateMap[fd].get(); |
| 980 sema.LateTemplateParser(sema.OpaqueParser, *lpt); | 980 sema.LateTemplateParser(sema.OpaqueParser, *lpt); |
| 981 } | 981 } |
| 982 } | 982 } |
| 983 | 983 |
| 984 void FindBadConstructsConsumer::CheckVarDecl(clang::VarDecl* var_decl) { | 984 void FindBadConstructsConsumer::CheckVarDecl(clang::VarDecl* var_decl) { |
| 985 if (!options_.check_auto_raw_pointer) | |
| 986 return; | |
| 987 | |
| 988 // Check whether auto deduces to a raw pointer. | 985 // Check whether auto deduces to a raw pointer. |
| 989 QualType non_reference_type = var_decl->getType().getNonReferenceType(); | 986 QualType non_reference_type = var_decl->getType().getNonReferenceType(); |
| 990 // We might have a case where the type is written as auto*, but the actual | 987 // We might have a case where the type is written as auto*, but the actual |
| 991 // type is deduced to be an int**. For that reason, keep going down the | 988 // type is deduced to be an int**. For that reason, keep going down the |
| 992 // pointee type until we get an 'auto' or a non-pointer type. | 989 // pointee type until we get an 'auto' or a non-pointer type. |
| 993 for (;;) { | 990 for (;;) { |
| 994 const clang::AutoType* auto_type = | 991 const clang::AutoType* auto_type = |
| 995 non_reference_type->getAs<clang::AutoType>(); | 992 non_reference_type->getAs<clang::AutoType>(); |
| 996 if (auto_type) { | 993 if (auto_type) { |
| 997 if (auto_type->isDeduced()) { | 994 if (auto_type->isDeduced()) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1024 } | 1021 } |
| 1025 } else if (non_reference_type->isPointerType()) { | 1022 } else if (non_reference_type->isPointerType()) { |
| 1026 non_reference_type = non_reference_type->getPointeeType(); | 1023 non_reference_type = non_reference_type->getPointeeType(); |
| 1027 continue; | 1024 continue; |
| 1028 } | 1025 } |
| 1029 break; | 1026 break; |
| 1030 } | 1027 } |
| 1031 } | 1028 } |
| 1032 | 1029 |
| 1033 } // namespace chrome_checker | 1030 } // namespace chrome_checker |
| OLD | NEW |