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

Unified Diff: tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp

Issue 261973002: Blink GC plugin: require that GC derived classes do not override their new(size_t) operator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: only check new(size_t) Created 6 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/blink_gc_plugin/RecordInfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp
diff --git a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp
index 47ab43c92997fcca0aef20f8aca6d848d7dd7feb..eec7d84c7fa446720097eff8062022ee04d8079a 100644
--- a/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp
+++ b/tools/clang/blink_gc_plugin/BlinkGCPlugin.cpp
@@ -116,6 +116,10 @@ const char kDerivesNonStackAllocated[] =
"[blink-gc] Stack-allocated class %0 derives class %1"
" which is not stack allocated.";
+const char kClassOverridesNew[] =
+ "[blink-gc] Garbage collected class %0"
+ " is not permitted to override its new operator.";
+
struct BlinkGCPluginOptions {
BlinkGCPluginOptions() : enable_oilpan(false), dump_graph(false) {}
bool enable_oilpan;
@@ -564,6 +568,8 @@ class BlinkGCPluginConsumer : public ASTConsumer {
diagnostic_.getCustomDiagID(getErrorLevel(), kMissingFinalizeDispatch);
diag_derives_non_stack_allocated_ =
diagnostic_.getCustomDiagID(getErrorLevel(), kDerivesNonStackAllocated);
+ diag_class_overrides_new_ =
+ diagnostic_.getCustomDiagID(getErrorLevel(), kClassOverridesNew);
// Register note messages.
diag_field_requires_tracing_note_ = diagnostic_.getCustomDiagID(
@@ -700,6 +706,9 @@ class BlinkGCPluginConsumer : public ASTConsumer {
CheckDispatch(info);
+ if (CXXMethodDecl* newop = info->DeclaresNewOperator())
+ ReportClassOverridesNew(info, newop);
+
// TODO: Remove this exception once TreeShared is properly traced.
if (!info->IsTreeShared()) {
CheckGCRootsVisitor visitor;
@@ -1236,6 +1245,13 @@ class BlinkGCPluginConsumer : public ASTConsumer {
<< info->record() << base->info()->record();
}
+ void ReportClassOverridesNew(RecordInfo* info, CXXMethodDecl* newop) {
+ SourceLocation loc = newop->getLocStart();
+ SourceManager& manager = instance_.getSourceManager();
+ FullSourceLoc full_loc(loc, manager);
+ diagnostic_.Report(full_loc, diag_class_overrides_new_) << info->record();
+ }
+
void NoteManualDispatchMethod(CXXMethodDecl* dispatch) {
SourceLocation loc = dispatch->getLocStart();
SourceManager& manager = instance_.getSourceManager();
@@ -1316,6 +1332,7 @@ class BlinkGCPluginConsumer : public ASTConsumer {
unsigned diag_missing_trace_dispatch_;
unsigned diag_missing_finalize_dispatch_;
unsigned diag_derives_non_stack_allocated_;
+ unsigned diag_class_overrides_new_;
unsigned diag_field_requires_tracing_note_;
unsigned diag_raw_ptr_to_gc_managed_class_note_;
« no previous file with comments | « no previous file | tools/clang/blink_gc_plugin/RecordInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698