You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.9 KiB
68 lines
1.9 KiB
/*
|
|
* Copyright 2016 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include "FuzzerCodeGenBase.h"
|
|
|
|
#include <iostream>
|
|
|
|
using std::cerr;
|
|
using std::cout;
|
|
using std::endl;
|
|
using std::string;
|
|
|
|
namespace android {
|
|
namespace vts {
|
|
|
|
void FuzzerCodeGenBase::GenerateAll(Formatter & /* header_out */,
|
|
Formatter &source_out) {
|
|
GenerateSourceFile(source_out);
|
|
}
|
|
|
|
void FuzzerCodeGenBase::GenerateHeaderFile(Formatter & /* out */) {
|
|
cout << "Headers are not generated for fuzzer." << endl;
|
|
}
|
|
|
|
void FuzzerCodeGenBase::GenerateSourceFile(Formatter &out) {
|
|
if (!comp_spec_.has_interface()) {
|
|
return;
|
|
}
|
|
GenerateWarningComment(out);
|
|
GenerateSourceIncludeFiles(out);
|
|
GenerateUsingDeclaration(out);
|
|
GenerateOpenNameSpaces(out);
|
|
GenerateGlobalVars(out);
|
|
GenerateLLVMFuzzerInitialize(out);
|
|
GenerateLLVMFuzzerTestOneInput(out);
|
|
GenerateCloseNameSpaces(out);
|
|
}
|
|
|
|
void FuzzerCodeGenBase::GenerateOpenNameSpaces(Formatter &out) {
|
|
out << "namespace android {\n";
|
|
out << "namespace vts {\n\n";
|
|
}
|
|
|
|
void FuzzerCodeGenBase::GenerateCloseNameSpaces(Formatter &out) {
|
|
out << "} // namespace vts\n";
|
|
out << "} // namespace android\n";
|
|
}
|
|
|
|
void FuzzerCodeGenBase::GenerateWarningComment(Formatter &out) {
|
|
out << "// This file was auto-generated by VTS compiler.\n\n";
|
|
}
|
|
|
|
} // namespace vts
|
|
} // namespace android
|