Chromium Code Reviews| Index: tools/gn/parser_fuzzer.cc |
| diff --git a/tools/gn/parser_fuzzer.cc b/tools/gn/parser_fuzzer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5ff13da43e3401e8fd433b1fb72ca7513208385e |
| --- /dev/null |
| +++ b/tools/gn/parser_fuzzer.cc |
| @@ -0,0 +1,24 @@ |
| +// Copyright (c) 2016 The Chromium Authors. All rights reserved. |
|
brettw
2016/08/23 21:46:38
Nit: no "(c)"
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include <stdint.h> |
| + |
| +#include "tools/gn/input_file.h" |
| +#include "tools/gn/parser.h" |
| +#include "tools/gn/source_file.h" |
| +#include "tools/gn/tokenizer.h" |
| + |
| +extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) { |
| + SourceFile source; |
| + InputFile input(source); |
| + input.SetContents(std::string(reinterpret_cast<const char*>(data), size)); |
| + |
| + Err err; |
| + std::vector<Token> tokens = Tokenizer::Tokenize(&input, &err); |
| + |
| + if (!err.has_error()) |
| + Parser::Parse(tokens, &err); |
| + |
| + return 0; |
| +} |