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

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

Issue 2060553002: GC plugin: improve error reporting when tracing illegal fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: robustify namespace equality checking instead Created 4 years, 6 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/blink_gc_plugin/RecordInfo.h ('k') | tools/clang/blink_gc_plugin/TracingStatus.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/clang/blink_gc_plugin/RecordInfo.cpp
diff --git a/tools/clang/blink_gc_plugin/RecordInfo.cpp b/tools/clang/blink_gc_plugin/RecordInfo.cpp
index 1eef514f929a49ad9f4c31449caaa657efaf5dad..46b8606a344d06d92c71eafd0cc3c2c5608021da 100644
--- a/tools/clang/blink_gc_plugin/RecordInfo.cpp
+++ b/tools/clang/blink_gc_plugin/RecordInfo.cpp
@@ -4,6 +4,7 @@
#include "Config.h"
#include "RecordInfo.h"
+#include "clang/Sema/Sema.h"
using namespace clang;
using std::string;
@@ -556,6 +557,16 @@ TracingStatus RecordInfo::NeedsTracing(Edge::NeedsTracingOption option) {
return fields_need_tracing_;
}
+static bool isInStdNamespace(clang::Sema& sema, NamespaceDecl* ns)
+{
+ while (ns) {
+ if (sema.getStdNamespace()->InEnclosingNamespaceSetOf(ns))
+ return true;
+ ns = dyn_cast<NamespaceDecl>(ns->getParent());
+ }
+ return false;
+}
+
Edge* RecordInfo::CreateEdge(const Type* type) {
if (!type) {
return 0;
@@ -588,6 +599,18 @@ Edge* RecordInfo::CreateEdge(const Type* type) {
return 0;
}
+ if (Config::IsUniquePtr(info->name()) && info->GetTemplateArgs(1, &args)) {
+ // Check that this is std::unique_ptr
+ NamespaceDecl* ns =
+ dyn_cast<NamespaceDecl>(info->record()->getDeclContext());
+ clang::Sema& sema = cache_->instance().getSema();
+ if (!isInStdNamespace(sema, ns))
+ return 0;
+ if (Edge* ptr = CreateEdge(args[0]))
+ return new UniquePtr(ptr);
+ return 0;
+ }
+
if (Config::IsMember(info->name()) && info->GetTemplateArgs(1, &args)) {
if (Edge* ptr = CreateEdge(args[0]))
return new Member(ptr);
@@ -600,7 +623,8 @@ Edge* RecordInfo::CreateEdge(const Type* type) {
return 0;
}
- if (Config::IsPersistent(info->name())) {
+ bool is_persistent = Config::IsPersistent(info->name());
+ if (is_persistent || Config::IsCrossThreadPersistent(info->name())) {
// Persistent might refer to v8::Persistent, so check the name space.
// TODO: Consider using a more canonical identification than names.
NamespaceDecl* ns =
@@ -609,8 +633,12 @@ Edge* RecordInfo::CreateEdge(const Type* type) {
return 0;
if (!info->GetTemplateArgs(1, &args))
return 0;
- if (Edge* ptr = CreateEdge(args[0]))
- return new Persistent(ptr);
+ if (Edge* ptr = CreateEdge(args[0])) {
+ if (is_persistent)
+ return new Persistent(ptr);
+ else
+ return new CrossThreadPersistent(ptr);
+ }
return 0;
}
« no previous file with comments | « tools/clang/blink_gc_plugin/RecordInfo.h ('k') | tools/clang/blink_gc_plugin/TracingStatus.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698