| Index: tools/clang/blink_gc_plugin/CheckSingletonVisitor.h
|
| diff --git a/tools/clang/blink_gc_plugin/CheckSingletonVisitor.h b/tools/clang/blink_gc_plugin/CheckSingletonVisitor.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..4e6df24f2b78ea0731581a3a0de92ed2644b8c3e
|
| --- /dev/null
|
| +++ b/tools/clang/blink_gc_plugin/CheckSingletonVisitor.h
|
| @@ -0,0 +1,53 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef TOOLS_BLINK_GC_PLUGIN_CHECK_SINGLETON_VISITOR_H_
|
| +#define TOOLS_BLINK_GC_PLUGIN_CHECK_SINGLETON_VISITOR_H_
|
| +
|
| +#include <set>
|
| +#include <utility>
|
| +#include <vector>
|
| +
|
| +#include "clang/AST/AST.h"
|
| +
|
| +class RecordInfo;
|
| +
|
| +// This visitor checks that a persistent static singleton's type
|
| +// is safe. Safety is currently defined as:
|
| +// - the type doesn't derive from blink::ScriptWrappable.
|
| +// - the type doesn't contain a ScriptWrappable-derived member,
|
| +// transitively.
|
| +//
|
| +class CheckSingletonVisitor final {
|
| + public:
|
| + using Errors = std::vector<std::pair<std::string, const clang::Type*>>;
|
| +
|
| + CheckSingletonVisitor();
|
| + ~CheckSingletonVisitor();
|
| +
|
| + const Errors& illegal_types() const { return illegal_types_; }
|
| +
|
| + bool CheckIfSafe(RecordInfo*, const clang::Type*);
|
| +
|
| + bool VisitType(clang::Type*);
|
| +
|
| + private:
|
| + void CheckScriptWrappable(const std::string&, const clang::Type*);
|
| +
|
| + bool IsScriptWrappable(RecordInfo*);
|
| + bool InheritsScriptWrappable(clang::CXXRecordDecl*);
|
| +
|
| + void PushType(const clang::Type*);
|
| + void PushType(const std::string&, const clang::Type*);
|
| +
|
| + std::string GenerateErrorContext(const std::string&);
|
| +
|
| + Errors illegal_types_;
|
| + RecordInfo* info_ = nullptr;
|
| + std::vector<std::pair<std::string, const clang::Type*>> types_stack_;
|
| + std::set<const clang::Type*> already_seen_;
|
| + std::vector<std::string> error_context_;
|
| +};
|
| +
|
| +#endif // TOOLS_BLINK_GC_PLUGIN_CHECK_SINGLETON_VISITOR_H_
|
|
|