Merge "header-checker: Update clang prebuilts to clang-r365631"

This commit is contained in:
Logan Chien
2019-08-28 02:29:20 +00:00
committed by Gerrit Code Review
5 changed files with 91 additions and 30 deletions

View File

@@ -165,6 +165,7 @@ cc_library_host_static {
"src/repr/symbol/so_file_parser.cpp", "src/repr/symbol/so_file_parser.cpp",
"src/repr/symbol/version_script_parser.cpp", "src/repr/symbol/version_script_parser.cpp",
"src/utils/api_level.cpp", "src/utils/api_level.cpp",
"src/utils/command_line_utils.cpp",
"src/utils/config_file.cpp", "src/utils/config_file.cpp",
"src/utils/collect_exported_headers.cpp", "src/utils/collect_exported_headers.cpp",
"src/utils/string_utils.cpp", "src/utils/string_utils.cpp",

View File

@@ -16,6 +16,7 @@
#include "dumper/fixed_argv.h" #include "dumper/fixed_argv.h"
#include "dumper/frontend_action_factory.h" #include "dumper/frontend_action_factory.h"
#include "utils/command_line_utils.h"
#include "utils/header_abi_util.h" #include "utils/header_abi_util.h"
#include <clang/Frontend/FrontendActions.h> #include <clang/Frontend/FrontendActions.h>
@@ -40,6 +41,7 @@ using header_checker::dumper::HeaderCheckerFrontendActionFactory;
using header_checker::dumper::HeaderCheckerOptions; using header_checker::dumper::HeaderCheckerOptions;
using header_checker::repr::TextFormatIR; using header_checker::repr::TextFormatIR;
using header_checker::utils::CollectAllExportedHeaders; using header_checker::utils::CollectAllExportedHeaders;
using header_checker::utils::HideIrrelevantCommandLineOptions;
using header_checker::utils::RealPath; using header_checker::utils::RealPath;
@@ -83,22 +85,8 @@ static llvm::cl::opt<TextFormatIR> output_format(
llvm::cl::init(TextFormatIR::Json), llvm::cl::init(TextFormatIR::Json),
llvm::cl::cat(header_checker_category)); llvm::cl::cat(header_checker_category));
// Hide irrelevant command line options defined in LLVM libraries.
static void HideIrrelevantCommandLineOptions() {
llvm::StringMap<llvm::cl::Option *> &map = llvm::cl::getRegisteredOptions();
for (llvm::StringMapEntry<llvm::cl::Option *> &p : map) {
if (p.second->Category == &header_checker_category) {
continue;
}
if (p.first().startswith("help")) {
continue;
}
p.second->setHiddenFlag(llvm::cl::Hidden);
}
}
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
HideIrrelevantCommandLineOptions(); HideIrrelevantCommandLineOptions(header_checker_category);
// Tweak argc and argv to workaround clang version mismatches. // Tweak argc and argv to workaround clang version mismatches.
FixedArgv fixed_argv(argc, argv); FixedArgv fixed_argv(argc, argv);

View File

@@ -17,6 +17,7 @@
#include "repr/ir_reader.h" #include "repr/ir_reader.h"
#include "repr/symbol/so_file_parser.h" #include "repr/symbol/so_file_parser.h"
#include "repr/symbol/version_script_parser.h" #include "repr/symbol/version_script_parser.h"
#include "utils/command_line_utils.h"
#include "utils/header_abi_util.h" #include "utils/header_abi_util.h"
#include <llvm/Support/CommandLine.h> #include <llvm/Support/CommandLine.h>
@@ -37,6 +38,7 @@
using namespace header_checker; using namespace header_checker;
using header_checker::repr::TextFormatIR; using header_checker::repr::TextFormatIR;
using header_checker::utils::CollectAllExportedHeaders; using header_checker::utils::CollectAllExportedHeaders;
using header_checker::utils::HideIrrelevantCommandLineOptions;
static constexpr std::size_t kSourcesPerBatchThread = 7; static constexpr std::size_t kSourcesPerBatchThread = 7;
@@ -446,22 +448,8 @@ bool HeaderAbiLinker::ReadExportedSymbolsFromSharedObjectFile() {
return true; return true;
} }
// Hide irrelevant command line options defined in LLVM libraries.
static void HideIrrelevantCommandLineOptions() {
llvm::StringMap<llvm::cl::Option *> &map = llvm::cl::getRegisteredOptions();
for (llvm::StringMapEntry<llvm::cl::Option *> &p : map) {
if (p.second->Category == &header_linker_category) {
continue;
}
if (p.first().startswith("help")) {
continue;
}
p.second->setHiddenFlag(llvm::cl::Hidden);
}
}
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
HideIrrelevantCommandLineOptions(); HideIrrelevantCommandLineOptions(header_linker_category);
llvm::cl::ParseCommandLineOptions(argc, argv, "header-linker"); llvm::cl::ParseCommandLineOptions(argc, argv, "header-linker");
if (so_file.empty() && version_script.empty()) { if (so_file.empty() && version_script.empty()) {

View File

@@ -0,0 +1,52 @@
// Copyright (C) 2019 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 "command_line_utils.h"
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringMap.h>
#include <llvm/Support/CommandLine.h>
#include <algorithm>
namespace header_checker {
namespace utils {
static bool IsOptionInCategory(const llvm::cl::Option &option,
const llvm::cl::OptionCategory &category) {
const llvm::SmallVectorImpl<llvm::cl::OptionCategory *> &categories =
option.Categories;
auto iter = std::find(categories.begin(), categories.end(), &category);
return iter != categories.end();
}
void HideIrrelevantCommandLineOptions(
const llvm::cl::OptionCategory &category) {
llvm::StringMap<llvm::cl::Option *> &map = llvm::cl::getRegisteredOptions();
for (llvm::StringMapEntry<llvm::cl::Option *> &p : map) {
if (IsOptionInCategory(*p.second, category)) {
continue;
}
if (p.first().startswith("help")) {
continue;
}
p.second->setHiddenFlag(llvm::cl::Hidden);
}
}
} // namespace utils
} // namespace header_checker

View File

@@ -0,0 +1,32 @@
// Copyright (C) 2019 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.
#ifndef COMMAND_LINE_UTILS_H_
#define COMMAND_LINE_UTILS_H_
#include <llvm/Support/CommandLine.h>
namespace header_checker {
namespace utils {
// Hide irrelevant command line options defined in LLVM libraries.
void HideIrrelevantCommandLineOptions(const llvm::cl::OptionCategory &category);
} // namespace utils
} // namespace header_checker
#endif // COMMAND_LINE_UTILS_H_