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

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

Issue 2265093002: clang plugin: Remove follow-macro-expansion toggle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | tools/clang/plugins/FindBadConstructsAction.cpp » ('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 // A general interface for filtering and only acting on classes in Chromium C++ 5 // A general interface for filtering and only acting on classes in Chromium C++
6 // code. 6 // code.
7 7
8 #include "ChromeClassTester.h" 8 #include "ChromeClassTester.h"
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return true; 190 return true;
191 if (HasIgnoredBases(base_record)) 191 if (HasIgnoredBases(base_record))
192 return true; 192 return true;
193 } 193 }
194 return false; 194 return false;
195 } 195 }
196 196
197 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { 197 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) {
198 std::string filename; 198 std::string filename;
199 199
200 if (options_.follow_macro_expansion) { 200 // If |record_location| is a macro, check the whole chain of expansions.
201 // If |record_location| is a macro, check the whole chain of expansions. 201 const SourceManager& source_manager = instance_.getSourceManager();
202 const SourceManager& source_manager = instance_.getSourceManager(); 202 while (true) {
203 while (true) { 203 if (GetFilename(record_location, &filename)) {
204 if (GetFilename(record_location, &filename)) { 204 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") ||
205 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || 205 ends_with(filename, ".mm")) {
206 ends_with(filename, ".mm")) { 206 return true;
207 return true;
208 }
209 } 207 }
210 if (!record_location.isMacroID()) {
211 break;
212 }
213 record_location =
214 source_manager.getImmediateExpansionRange(record_location).first;
215 } 208 }
216 } else { 209 if (!record_location.isMacroID()) {
217 if (!GetFilename(record_location, &filename)) 210 break;
218 return false;
219
220 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") ||
221 ends_with(filename, ".mm")) {
222 return true;
223 } 211 }
212 record_location =
213 source_manager.getImmediateExpansionRange(record_location).first;
224 } 214 }
225 215
226 return false; 216 return false;
227 } 217 }
228 218
229 void ChromeClassTester::BuildBannedLists() { 219 void ChromeClassTester::BuildBannedLists() {
230 banned_namespaces_.emplace("std"); 220 banned_namespaces_.emplace("std");
231 banned_namespaces_.emplace("__gnu_cxx"); 221 banned_namespaces_.emplace("__gnu_cxx");
232 222
233 if (options_.enforce_in_thirdparty_webkit) { 223 if (options_.enforce_in_thirdparty_webkit) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 327 }
338 328
339 *filename = ploc.getFilename(); 329 *filename = ploc.getFilename();
340 return true; 330 return true;
341 } 331 }
342 332
343 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { 333 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() {
344 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error 334 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error
345 : DiagnosticsEngine::Warning; 335 : DiagnosticsEngine::Warning;
346 } 336 }
OLDNEW
« no previous file with comments | « no previous file | tools/clang/plugins/FindBadConstructsAction.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698