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

Unified Diff: tools/clang/plugins/FindBadConstructsConsumer.cpp

Issue 2780113002: Refactor banned directory checking so Blink can opt into certain checks. (Closed)
Patch Set: better enum names Created 3 years, 8 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 | « tools/clang/plugins/FindBadConstructsConsumer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/plugins/FindBadConstructsConsumer.cpp
diff --git a/tools/clang/plugins/FindBadConstructsConsumer.cpp b/tools/clang/plugins/FindBadConstructsConsumer.cpp
index 4c93af4d03b9937525b4f4073e6b5f50552314f9..629090c557ab1e05b678b36b6f83d5565f0a32c6 100644
--- a/tools/clang/plugins/FindBadConstructsConsumer.cpp
+++ b/tools/clang/plugins/FindBadConstructsConsumer.cpp
@@ -216,8 +216,14 @@ bool FindBadConstructsConsumer::VisitVarDecl(clang::VarDecl* var_decl) {
return true;
}
-void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location,
+void FindBadConstructsConsumer::CheckChromeClass(LocationType location_type,
+ SourceLocation record_location,
CXXRecordDecl* record) {
+ // TODO(dcheng): After emitWarning() is removed, move warning filtering into
+ // ReportIfSpellingLocNotIgnored.
+ if (location_type == LocationType::kBlink)
+ return;
+
bool implementation_file = InImplementationFile(record_location);
if (!implementation_file) {
@@ -245,11 +251,15 @@ void FindBadConstructsConsumer::CheckChromeClass(SourceLocation record_location,
CheckWeakPtrFactoryMembers(record_location, record);
}
-void FindBadConstructsConsumer::CheckChromeEnum(SourceLocation enum_location,
+void FindBadConstructsConsumer::CheckChromeEnum(LocationType location_type,
+ SourceLocation enum_location,
EnumDecl* enum_decl) {
if (!options_.check_enum_last_value)
return;
+ if (location_type == LocationType::kBlink)
+ return;
+
bool got_one = false;
bool is_signed = false;
llvm::APSInt max_so_far;
@@ -451,9 +461,12 @@ SuppressibleDiagnosticBuilder
FindBadConstructsConsumer::ReportIfSpellingLocNotIgnored(
SourceLocation loc,
unsigned diagnostic_id) {
- return SuppressibleDiagnosticBuilder(
- &diagnostic(), loc, diagnostic_id,
- InBannedDirectory(instance().getSourceManager().getSpellingLoc(loc)));
+ LocationType type =
+ ClassifyLocation(instance().getSourceManager().getSpellingLoc(loc));
+ bool ignored =
+ type == LocationType::kThirdParty || type == LocationType::kBlink;
+ return SuppressibleDiagnosticBuilder(&diagnostic(), loc, diagnostic_id,
+ ignored);
}
// Checks that virtual methods are correctly annotated, and have no body in a
@@ -609,7 +622,8 @@ void FindBadConstructsConsumer::CheckVirtualBodies(
bool emit = true;
if (loc.isMacroID()) {
SourceManager& manager = instance().getSourceManager();
- if (InBannedDirectory(manager.getSpellingLoc(loc)))
+ LocationType type = ClassifyLocation(manager.getSpellingLoc(loc));
+ if (type == LocationType::kThirdParty || type == LocationType::kBlink)
emit = false;
else {
StringRef name = Lexer::getImmediateMacroName(
@@ -998,8 +1012,10 @@ void FindBadConstructsConsumer::CheckVarDecl(clang::VarDecl* var_decl) {
// Check if we should even be considering this type (note that there
// should be fewer auto types than banned namespace/directory types,
// so check this last.
+ LocationType location_type =
+ ClassifyLocation(var_decl->getLocStart());
if (!InBannedNamespace(var_decl) &&
- !InBannedDirectory(var_decl->getLocStart())) {
+ location_type != LocationType::kThirdParty) {
// The range starts from |var_decl|'s loc start, which is the
// beginning of the full expression defining this |var_decl|. It
// ends, however, where this |var_decl|'s type loc ends, since
« no previous file with comments | « tools/clang/plugins/FindBadConstructsConsumer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698