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

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

Issue 2108823004: clang-plugins: Don't strip non const references in auto raw ptr fixits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 if (!non_reference_type->isPointerType()) 117 if (!non_reference_type->isPointerType())
118 return "auto"; 118 return "auto";
119 119
120 std::string result = 120 std::string result =
121 GetAutoReplacementTypeAsString(non_reference_type->getPointeeType()); 121 GetAutoReplacementTypeAsString(non_reference_type->getPointeeType());
122 result += "*"; 122 result += "*";
123 if (non_reference_type.isLocalConstQualified()) 123 if (non_reference_type.isLocalConstQualified())
124 result += " const"; 124 result += " const";
125 if (non_reference_type.isLocalVolatileQualified()) 125 if (non_reference_type.isLocalVolatileQualified())
126 result += " volatile"; 126 result += " volatile";
127 if (type->isReferenceType() && !non_reference_type.isLocalConstQualified()) {
128 if (type->isLValueReferenceType())
129 result += "&";
130 else if (type->isRValueReferenceType())
131 result += "&&";
132 }
127 return result; 133 return result;
128 } 134 }
129 135
130 } // namespace 136 } // namespace
131 137
132 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance, 138 FindBadConstructsConsumer::FindBadConstructsConsumer(CompilerInstance& instance,
133 const Options& options) 139 const Options& options)
134 : ChromeClassTester(instance, options) { 140 : ChromeClassTester(instance, options) {
135 if (options.check_ipc) { 141 if (options.check_ipc) {
136 ipc_visitor_.reset(new CheckIPCVisitor(instance)); 142 ipc_visitor_.reset(new CheckIPCVisitor(instance));
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 } 1021 }
1016 } else if (non_reference_type->isPointerType()) { 1022 } else if (non_reference_type->isPointerType()) {
1017 non_reference_type = non_reference_type->getPointeeType(); 1023 non_reference_type = non_reference_type->getPointeeType();
1018 continue; 1024 continue;
1019 } 1025 }
1020 break; 1026 break;
1021 } 1027 }
1022 } 1028 }
1023 1029
1024 } // namespace chrome_checker 1030 } // namespace chrome_checker
OLDNEW
« no previous file with comments | « no previous file | tools/clang/plugins/tests/auto_raw_pointer.cpp » ('j') | tools/clang/plugins/tests/auto_raw_pointer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698