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

Unified Diff: tools/gn/c_include_iterator.cc

Issue 1217093007: Add a //nogncheck anntation to GN include checker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/gn/c_include_iterator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/c_include_iterator.cc
diff --git a/tools/gn/c_include_iterator.cc b/tools/gn/c_include_iterator.cc
index 25eba9d3f7a90470e1622bb174481fa1c261b6fb..9e719c740929b261fde2bae8e39f057feddedbdf 100644
--- a/tools/gn/c_include_iterator.cc
+++ b/tools/gn/c_include_iterator.cc
@@ -105,6 +105,11 @@ IncludeType ExtractInclude(const base::StringPiece& line,
return type;
}
+// Returns true if this line has a "nogncheck" comment associated with it.
+bool HasNoCheckAnnotation(const base::StringPiece& line) {
+ return line.find("nogncheck") != base::StringPiece::npos;
+}
+
} // namespace
const int CIncludeIterator::kMaxNonIncludeLines = 10;
@@ -129,7 +134,7 @@ bool CIncludeIterator::GetNextIncludeString(base::StringPiece* out,
base::StringPiece include_contents;
int begin_char;
IncludeType type = ExtractInclude(line, &include_contents, &begin_char);
- if (type == INCLUDE_USER) {
+ if (type == INCLUDE_USER && !HasNoCheckAnnotation(line)) {
// Only count user includes for now.
*out = include_contents;
*location = LocationRange(
« no previous file with comments | « no previous file | tools/gn/c_include_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698