diff --git a/build/clang-plugin/Checks.inc b/build/clang-plugin/Checks.inc index 79ec296f4f13..b492f22a47fa 100644 --- a/build/clang-plugin/Checks.inc +++ b/build/clang-plugin/Checks.inc @@ -10,6 +10,7 @@ CHECK(CanRunScriptChecker, "can-run-script") CHECK(DanglingOnTemporaryChecker, "dangling-on-temporary") CHECK(ExplicitImplicitChecker, "implicit-constructor") CHECK(ExplicitOperatorBoolChecker, "explicit-operator-bool") +CHECK(JSHandleRootedTypedefChecker, "js-handle-rooted-typedef") CHECK(KungFuDeathGripChecker, "kungfu-death-grip") #ifdef TARGET_IS_WINDOWS CHECK(LoadLibraryUsageChecker, "load-library-usage") diff --git a/build/clang-plugin/ChecksIncludes.inc b/build/clang-plugin/ChecksIncludes.inc index 77d14cc18ce5..7b098ab3dbf0 100644 --- a/build/clang-plugin/ChecksIncludes.inc +++ b/build/clang-plugin/ChecksIncludes.inc @@ -15,6 +15,7 @@ #include "LoadLibraryUsageChecker.h" #include "FopenUsageChecker.h" #endif +#include "JSHandleRootedTypedefChecker.h" #include "KungFuDeathGripChecker.h" #include "MustOverrideChecker.h" #include "MustReturnFromCallerChecker.h" diff --git a/build/clang-plugin/CustomMatchers.h b/build/clang-plugin/CustomMatchers.h index 005452c7dc3a..c1d150f72e87 100644 --- a/build/clang-plugin/CustomMatchers.h +++ b/build/clang-plugin/CustomMatchers.h @@ -10,7 +10,7 @@ #if CLANG_VERSION_FULL >= 1300 // Starting with clang-13 Expr::isRValue has been renamed to Expr::isPRValue -#define isRValue isPRValue +#define isRValue isPRValue #endif namespace clang { @@ -431,6 +431,43 @@ AST_MATCHER(MemberExpr, hasKnownLiveAnnotation) { return Field && hasCustomAttribute(Field); } +#define GENERATE_JSTYPEDEF_PAIR(templateName) \ + {templateName "Function", templateName ""}, \ + {templateName "Id", templateName ""}, \ + {templateName "Object", templateName ""}, \ + {templateName "Script", templateName ""}, \ + {templateName "String", templateName ""}, \ + {templateName "Symbol", templateName ""}, \ + {templateName "BigInt", templateName ""}, \ + {templateName "Value", templateName ""}, \ + {templateName "ValueVector", \ + templateName ">"}, \ + {templateName "ObjectVector", \ + templateName ">"}, \ + { \ + templateName "IdVector", \ + templateName ">" \ + } + +static const char *const JSHandleRootedTypedefMap[][2] = { + GENERATE_JSTYPEDEF_PAIR("JS::Handle"), + GENERATE_JSTYPEDEF_PAIR("JS::MutableHandle"), + GENERATE_JSTYPEDEF_PAIR("JS::Rooted"), + // Technically there is no PersistentRootedValueVector, and that's okay + GENERATE_JSTYPEDEF_PAIR("JS::PersistentRooted"), +}; + +AST_MATCHER(DeclaratorDecl, isUsingJSHandleRootedTypedef) { + QualType Type = Node.getType(); + std::string TypeName = Type.getAsString(); + for (auto &pair : JSHandleRootedTypedefMap) { + if (!TypeName.compare(pair[0])) { + return true; + } + } + return false; +} + } // namespace ast_matchers } // namespace clang diff --git a/build/clang-plugin/JSHandleRootedTypedefChecker.cpp b/build/clang-plugin/JSHandleRootedTypedefChecker.cpp new file mode 100644 index 000000000000..687b694a37b2 --- /dev/null +++ b/build/clang-plugin/JSHandleRootedTypedefChecker.cpp @@ -0,0 +1,46 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "JSHandleRootedTypedefChecker.h" +#include "CustomMatchers.h" + +void JSHandleRootedTypedefChecker::registerMatchers(MatchFinder *AstMatcher) { + AstMatcher->addMatcher( + declaratorDecl(isUsingJSHandleRootedTypedef()).bind("declaratorDecl"), + this); +} + +std::string getReplacement(std::string TypeName) { + for (auto &pair : JSHandleRootedTypedefMap) { + if (!TypeName.compare(pair[0])) { + return pair[1]; + } + } + llvm_unreachable("Unexpected type name"); +} + +void JSHandleRootedTypedefChecker::check( + const MatchFinder::MatchResult &Result) { + const char *Warning = "The fully qualified types are preferred over the " + "shorthand typedefs for JS::Handle/JS::Rooted types " + "outside SpiderMonkey."; + + const DeclaratorDecl *Declarator = + Result.Nodes.getNodeAs("declaratorDecl"); + + // Detect SpiderMonkey path. Admittedly hacky but works + bool IsSpiderMonkey = Declarator->getBeginLoc() + .printToString(Result.Context->getSourceManager()) + .find("js") != std::string::npos; + if (IsSpiderMonkey) { + // Using typedefs within SpiderMonkey is okay. + return; + } + + std::string Replacement = getReplacement(Declarator->getType().getAsString()); + diag(Declarator->getBeginLoc(), Warning, DiagnosticIDs::Warning) + << FixItHint::CreateReplacement( + Declarator->getTypeSourceInfo()->getTypeLoc().getSourceRange(), + Replacement); +} diff --git a/build/clang-plugin/JSHandleRootedTypedefChecker.h b/build/clang-plugin/JSHandleRootedTypedefChecker.h new file mode 100644 index 000000000000..32fc8fff9bd9 --- /dev/null +++ b/build/clang-plugin/JSHandleRootedTypedefChecker.h @@ -0,0 +1,19 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef BUILD_CLANG_PLUGIN_JSHANDLEROOTEDTYPEDEFCHECKER_H_ +#define BUILD_CLANG_PLUGIN_JSHANDLEROOTEDTYPEDEFCHECKER_H_ + +#include "plugin.h" + +class JSHandleRootedTypedefChecker : public BaseCheck { +public: + JSHandleRootedTypedefChecker(StringRef CheckName, + ContextType *Context = nullptr) + : BaseCheck(CheckName, Context) {} + void registerMatchers(MatchFinder *AstMatcher) override; + void check(const MatchFinder::MatchResult &Result) override; +}; + +#endif diff --git a/build/clang-plugin/moz.build b/build/clang-plugin/moz.build index 61bfdd6fa2d5..f0938a0b67b5 100644 --- a/build/clang-plugin/moz.build +++ b/build/clang-plugin/moz.build @@ -18,6 +18,7 @@ HOST_SOURCES += [ "DiagnosticsMatcher.cpp", "ExplicitImplicitChecker.cpp", "ExplicitOperatorBoolChecker.cpp", + "JSHandleRootedTypedefChecker.cpp", "KungFuDeathGripChecker.cpp", "MozCheckAction.cpp", "MustOverrideChecker.cpp", diff --git a/build/clang-plugin/tests/TestJSHandleRootedTypedef.cpp b/build/clang-plugin/tests/TestJSHandleRootedTypedef.cpp new file mode 100644 index 000000000000..5b34169a8f14 --- /dev/null +++ b/build/clang-plugin/tests/TestJSHandleRootedTypedef.cpp @@ -0,0 +1,156 @@ +#include "js/TypeDecls.h" +#include "js/Value.h" +#include "js/GCVector.h" +#include "js/Id.h" + +class Foo { + void HandleFunction(JS::HandleFunction){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleId(JS::HandleId){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleObject(JS::HandleObject){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleScript(JS::HandleScript){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleString(JS::HandleString){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleSymbol(JS::HandleSymbol){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleBigInt(JS::HandleBigInt){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleValue(JS::HandleValue){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleValueVector(JS::HandleValueVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleObjectVector(JS::HandleObjectVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void HandleIdVector(JS::HandleIdVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + void MutableHandleFunction(JS::MutableHandleFunction){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleId(JS::MutableHandleId){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleObject(JS::MutableHandleObject){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleScript(JS::MutableHandleScript){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleString(JS::MutableHandleString){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleSymbol(JS::MutableHandleSymbol){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleBigInt(JS::MutableHandleBigInt){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleValue(JS::MutableHandleValue){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleValueVector(JS::MutableHandleValueVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleObjectVector(JS::MutableHandleObjectVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + void MutableHandleIdVector(JS::MutableHandleIdVector){}; // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + // Examples of preferred forms + void FullHandleFunction(JS::Handle){}; + void FullHandleId(JS::Handle){}; + void FullHandleObject(JS::Handle){}; + void FullHandleScript(JS::Handle){}; + void FullHandleString(JS::Handle){}; + void FullHandleSymbol(JS::Handle){}; + void FullHandleBigInt(JS::Handle){}; + void FullHandleValue(JS::Handle){}; + void FullHandleValueVector(JS::Handle>){}; + void FullHandleObjectVector(JS::Handle>){}; + void FullHandleIdVector(JS::Handle>){}; + + void FullMutableHandleFunction(JS::MutableHandle){}; + void FullMutableHandleId(JS::MutableHandle){}; + void FullMutableHandleObject(JS::MutableHandle){}; + void FullMutableHandleScript(JS::MutableHandle){}; + void FullMutableHandleString(JS::MutableHandle){}; + void FullMutableHandleSymbol(JS::MutableHandle){}; + void FullMutableHandleBigInt(JS::MutableHandle){}; + void FullMutableHandleValue(JS::MutableHandle){}; + void FullMutableHandleValueVector(JS::MutableHandle>){}; + void FullMutableHandleObjectVector(JS::MutableHandle>){}; + void FullMutableHandleIdVector(JS::MutableHandle>){}; +}; + +static void Bar(JSContext *aCx) { + JS::RootedObject RootedObject(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedFunction RootedFunction(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedScript RootedScript(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedString RootedString(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedSymbol RootedSymbol(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedBigInt RootedBigInt(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedId RootedId(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedValue RootedValue(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + JS::RootedValueVector RootedValueVector(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedObjectVector RootedObjectVector(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::RootedIdVector RootedIdVector(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + JS::PersistentRootedFunction PersistentRootedFunction(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedId PersistentRootedId(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedObject PersistentRootedObject(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedScript PersistentRootedScript(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedString PersistentRootedString(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedSymbol PersistentRootedSymbol(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedBigInt PersistentRootedBigInt(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedValue PersistentRootedValue(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + JS::PersistentRootedIdVector PersistentRootedIdVector(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::PersistentRootedObjectVector PersistentRootedObjectVector(aCx); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + JS::HandleFunction HandleFunction(RootedFunction); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleId HandleId(RootedId); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleObject HandleObject(RootedObject); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleScript HandleScript(RootedScript); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleString HandleString(RootedString); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleSymbol HandleSymbol(RootedSymbol); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleBigInt HandleBigInt(RootedBigInt); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleValue HandleValue(RootedValue); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleValueVector HandleValueVector(RootedValueVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleObjectVector HandleObjectVector(RootedObjectVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::HandleIdVector HandleIdVector(RootedIdVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + JS::MutableHandleFunction MutableHandleFunction(&RootedFunction); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleId MutableHandleId(&RootedId); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleObject MutableHandleObject(&RootedObject); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleScript MutableHandleScript(&RootedScript); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleString MutableHandleString(&RootedString); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleSymbol MutableHandleSymbol(&RootedSymbol); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleBigInt MutableHandleBigInt(&RootedBigInt); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleValue MutableHandleValue(&RootedValue); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleValueVector MutableHandleValueVector(&RootedValueVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleObjectVector MutableHandleObjectVector(&RootedObjectVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + JS::MutableHandleIdVector MutableHandleIdVector(&RootedIdVector); // expected-warning {{The fully qualified types are preferred over the shorthand typedefs for JS::Handle/JS::Rooted types outside SpiderMonkey.}} + + // Examples of preferred forms + JS::Rooted FullRootedObject(aCx); + JS::Rooted FullRootedFunction(aCx); + JS::Rooted FullRootedScript(aCx); + JS::Rooted FullRootedString(aCx); + JS::Rooted FullRootedSymbol(aCx); + JS::Rooted FullRootedBigInt(aCx); + JS::Rooted FullRootedId(aCx); + JS::Rooted FullRootedValue(aCx); + + JS::RootedVector FullRootedValueVector(aCx); + JS::RootedVector FullRootedObjectVector(aCx); + JS::RootedVector FullRootedIdVector(aCx); + + JS::PersistentRooted FullPersistentRootedFunction(aCx); + JS::PersistentRooted FullPersistentRootedId(aCx); + JS::PersistentRooted FullPersistentRootedObject(aCx); + JS::PersistentRooted FullPersistentRootedScript(aCx); + JS::PersistentRooted FullPersistentRootedString(aCx); + JS::PersistentRooted FullPersistentRootedSymbol(aCx); + JS::PersistentRooted FullPersistentRootedBigInt(aCx); + JS::PersistentRooted FullPersistentRootedValue(aCx); + + JS::PersistentRootedVector FullPersistentRootedIdVector(aCx); + JS::PersistentRootedVector FullPersistentRootedObjectVector(aCx); + + JS::Handle FullHandleFunction(FullRootedFunction); + JS::Handle FullHandleId(FullRootedId); + JS::Handle FullHandleObject(FullRootedObject); + JS::Handle FullHandleScript(FullRootedScript); + JS::Handle FullHandleString(FullRootedString); + JS::Handle FullHandleSymbol(FullRootedSymbol); + JS::Handle FullHandleBigInt(FullRootedBigInt); + JS::Handle FullHandleValue(FullRootedValue); + JS::Handle> FullHandleValueVector(FullRootedValueVector); + JS::Handle> FullHandleObjectVector(FullRootedObjectVector); + JS::Handle> FullHandleIdVector(FullRootedIdVector); + + JS::MutableHandle FullMutableHandleFunction(&FullRootedFunction); + JS::MutableHandle FullMutableHandleId(&FullRootedId); + JS::MutableHandle FullMutableHandleObject(&FullRootedObject); + JS::MutableHandle FullMutableHandleScript(&FullRootedScript); + JS::MutableHandle FullMutableHandleString(&FullRootedString); + JS::MutableHandle FullMutableHandleSymbol(&FullRootedSymbol); + JS::MutableHandle FullMutableHandleBigInt(&FullRootedBigInt); + JS::MutableHandle FullMutableHandleValue(&FullRootedValue); + JS::MutableHandle> FullMutableHandleValueVector(&FullRootedValueVector); + JS::MutableHandle> FullMutableHandleObjectVector(&FullRootedObjectVector); + JS::MutableHandle> FullMutableHandleIdVector(&FullRootedIdVector); +} diff --git a/build/clang-plugin/tests/moz.build b/build/clang-plugin/tests/moz.build index e190779e63f1..31283b84bc14 100644 --- a/build/clang-plugin/tests/moz.build +++ b/build/clang-plugin/tests/moz.build @@ -17,6 +17,7 @@ SOURCES += [ "TestGlobalClass.cpp", "TestHeapClass.cpp", "TestInheritTypeAnnotationsFromTemplateArgs.cpp", + "TestJSHandleRootedTypedef.cpp", "TestKungFuDeathGrip.cpp", "TestMultipleAnnotations.cpp", "TestMustOverride.cpp", @@ -72,7 +73,16 @@ NoVisibilityFlags() # syntax-only build (no codegen), without a limit on the number of errors. COMPILE_FLAGS["OS_CXXFLAGS"] = [ f for f in COMPILE_FLAGS.get("OS_CXXFLAGS", []) if not f.startswith("-W") -] + ["-fsyntax-only", "-Xclang", "-verify", "-ferror-limit=0", "-Wno-invalid-noreturn"] +] + [ + "-fsyntax-only", + "-Xclang", + "-verify", + "-ferror-limit=0", + "-Wno-invalid-noreturn", + # For SpiderMonkey headers in TestJSHandleRootedTypedef.cpp + "-Wno-attributes", + "-Wno-invalid-offsetof", +] COMPILE_FLAGS["OS_CFLAGS"] = [ f for f in COMPILE_FLAGS.get("OS_CFLAGS", []) if not f.startswith("-W") ] + [