2021-10-30 04:25:12 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include <string>
|
2022-02-25 07:53:37 +08:00
|
|
|
|
2021-10-30 04:25:12 +08:00
|
|
|
#include "Luau/BuiltinDefinitions.h"
|
|
|
|
#include "Luau/Common.h"
|
2023-04-01 02:42:49 +08:00
|
|
|
#include "Luau/Frontend.h"
|
2022-02-25 07:53:37 +08:00
|
|
|
#include "Luau/Linter.h"
|
|
|
|
#include "Luau/ModuleResolver.h"
|
|
|
|
#include "Luau/Parser.h"
|
2021-10-30 04:25:12 +08:00
|
|
|
|
|
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size)
|
|
|
|
{
|
|
|
|
Luau::ParseOptions options;
|
|
|
|
|
|
|
|
Luau::Allocator allocator;
|
|
|
|
Luau::AstNameTable names(allocator);
|
|
|
|
|
|
|
|
Luau::ParseResult parseResult = Luau::Parser::parse(reinterpret_cast<const char*>(Data), Size, names, allocator, options);
|
|
|
|
|
|
|
|
// "static" here is to accelerate fuzzing process by only creating and populating the type environment once
|
2023-04-01 02:42:49 +08:00
|
|
|
static Luau::NullFileResolver fileResolver;
|
|
|
|
static Luau::NullConfigResolver configResolver;
|
|
|
|
static Luau::Frontend frontend{&fileResolver, &configResolver};
|
|
|
|
static int once = (Luau::registerBuiltinGlobals(frontend), 1);
|
2021-10-30 04:25:12 +08:00
|
|
|
(void)once;
|
2023-04-01 02:42:49 +08:00
|
|
|
static int once2 = (Luau::freeze(frontend.globals.globalTypes), 1);
|
2021-10-30 04:25:12 +08:00
|
|
|
(void)once2;
|
|
|
|
|
|
|
|
if (parseResult.errors.empty())
|
|
|
|
{
|
2023-04-01 02:42:49 +08:00
|
|
|
Luau::TypeChecker typeck(frontend.globals.globalScope, &frontend.moduleResolver, frontend.builtinTypes, &frontend.iceHandler);
|
2021-10-30 04:25:12 +08:00
|
|
|
|
|
|
|
Luau::LintOptions lintOptions;
|
|
|
|
lintOptions.warningMask = ~0ull;
|
|
|
|
|
2022-02-18 09:18:01 +08:00
|
|
|
Luau::lint(parseResult.root, names, typeck.globalScope, nullptr, {}, lintOptions);
|
2021-10-30 04:25:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|