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

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

Issue 1126413004: plugin: Don't warn about inline virtual methods from system macros; whitelist two non-system macros. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 7 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/clang/plugins/tests/system/windows.h » ('j') | 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 a7b75198f53375197dfe14d88284ed0e1f3b8255..c03e8bf8d1d56fcdc1ae5ce3c665e1aa0ba24fcc 100644
--- a/tools/clang/plugins/FindBadConstructsConsumer.cpp
+++ b/tools/clang/plugins/FindBadConstructsConsumer.cpp
@@ -508,9 +508,27 @@ void FindBadConstructsConsumer::CheckVirtualBodies(
if (method->hasBody() && method->hasInlineBody()) {
if (CompoundStmt* cs = dyn_cast<CompoundStmt>(method->getBody())) {
if (cs->size()) {
- emitWarning(cs->getLBracLoc(),
- "virtual methods with non-empty bodies shouldn't be "
- "declared inline.");
+ SourceLocation loc = cs->getLBracLoc();
+ // CR_BEGIN_MSG_MAP_EX and BEGIN_SAFE_MSG_MAP_EX try to be compatible
+ // to BEGIN_MSG_MAP(_EX). So even though they are in chrome code,
+ // we can't easily fix them, so explicitly whitelist them here.
+ bool emit = true;
+ if (loc.isMacroID()) {
+ SourceManager& manager = instance().getSourceManager();
+ if (InBannedDirectory(manager.getSpellingLoc(loc)))
+ emit = false;
+ else {
+ StringRef name = Lexer::getImmediateMacroName(
+ loc, manager, instance().getLangOpts());
+ if (name == "CR_BEGIN_MSG_MAP_EX" ||
+ name == "BEGIN_SAFE_MSG_MAP_EX")
+ emit = false;
+ }
+ }
+ if (emit)
+ emitWarning(loc,
+ "virtual methods with non-empty bodies shouldn't be "
+ "declared inline.");
}
}
}
« no previous file with comments | « no previous file | tools/clang/plugins/tests/system/windows.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698