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

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

Issue 1504033010: Follow macro invocations when checking if a violation happened in a .cc file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 5 years 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 } 181 }
182 182
183 return false; 183 return false;
184 } 184 }
185 185
186 std::string ChromeClassTester::GetNamespace(const Decl* record) { 186 std::string ChromeClassTester::GetNamespace(const Decl* record) {
187 return GetNamespaceImpl(record->getDeclContext(), ""); 187 return GetNamespaceImpl(record->getDeclContext(), "");
188 } 188 }
189 189
190 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) { 190 bool ChromeClassTester::InImplementationFile(SourceLocation record_location) {
191 if (options_.follow_macro_expansion) {
192 // If |record_location| is a macro, check where it was called.
193 const SourceManager& source_manager = instance_.getSourceManager();
194 record_location = source_manager.getExpansionRange(record_location).first;
Jeffrey Yasskin 2015/12/10 04:19:20 I thought I could just go to the outermost macro a
195 }
196
191 std::string filename; 197 std::string filename;
192 if (!GetFilename(record_location, &filename)) 198 if (!GetFilename(record_location, &filename))
193 return false; 199 return false;
194 200
195 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") || 201 if (ends_with(filename, ".cc") || ends_with(filename, ".cpp") ||
196 ends_with(filename, ".mm")) { 202 ends_with(filename, ".mm")) {
197 return true; 203 return true;
198 } 204 }
199 205
200 return false; 206 return false;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 } 321 }
316 322
317 *filename = ploc.getFilename(); 323 *filename = ploc.getFilename();
318 return true; 324 return true;
319 } 325 }
320 326
321 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() { 327 DiagnosticsEngine::Level ChromeClassTester::getErrorLevel() {
322 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error 328 return diagnostic().getWarningsAsErrors() ? DiagnosticsEngine::Error
323 : DiagnosticsEngine::Warning; 329 : DiagnosticsEngine::Warning;
324 } 330 }
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