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

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

Issue 2780113002: Refactor banned directory checking so Blink can opt into certain checks. (Closed)
Patch Set: Created 3 years, 9 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
Index: tools/clang/plugins/FindBadConstructsConsumer.cpp
diff --git a/tools/clang/plugins/FindBadConstructsConsumer.cpp b/tools/clang/plugins/FindBadConstructsConsumer.cpp
index 4c93af4d03b9937525b4f4073e6b5f50552314f9..b1eebfcfb147eaaccb7e45412116f63d24dea7a0 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,11 @@ 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::kIgnored || type == LocationType::kBlink;
dcheng 2017/03/29 04:18:40 In the future, when location type is kBlink, we wo
+ return SuppressibleDiagnosticBuilder(&diagnostic(), loc, diagnostic_id,
+ ignored);
}
// Checks that virtual methods are correctly annotated, and have no body in a
@@ -609,7 +621,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::kIgnored || type == LocationType::kBlink)
dcheng 2017/03/29 04:18:40 Ditto: this is needed for now, but this should be
emit = false;
else {
StringRef name = Lexer::getImmediateMacroName(
@@ -998,8 +1011,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::kIgnored) {
dcheng 2017/03/29 04:18:40 Note: We only ignore kIgnored here: kBlink gets fi
// 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
« tools/clang/plugins/ChromeClassTester.cpp ('K') | « tools/clang/plugins/FindBadConstructsConsumer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698