Commit b6261f43 authored by Ramin Halavati's avatar Ramin Halavati Committed by Commit Bot

Move traffic annotation auditor's clang tool switches to a text file.

Switches that are passed from traffic annotation auditor to clang tool
are moved from source to a text file for easier update.

Bug: 690323
Change-Id: Icb1fbfdfde6898532158bb3c9ee0e4710a3e043b
Reviewed-on: https://chromium-review.googlesource.com/997738Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Commit-Queue: Ramin Halavati <rhalavati@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548442}
parent 85ad9323
......@@ -61,6 +61,12 @@ const base::FilePath kSafeListPath =
.Append(FILE_PATH_LITERAL("auditor"))
.Append(FILE_PATH_LITERAL("safe_list.txt"));
const base::FilePath kClangToolSwitchesPath =
base::FilePath(FILE_PATH_LITERAL("tools"))
.Append(FILE_PATH_LITERAL("traffic_annotation"))
.Append(FILE_PATH_LITERAL("auditor"))
.Append(FILE_PATH_LITERAL("traffic_annotation_extractor_switches.txt"));
// The folder that includes the latest Clang built-in library. Inside this
// folder, there should be another folder with version number, like
// '.../lib/clang/6.0.0', which would be passed to the clang tool.
......@@ -77,10 +83,6 @@ const base::FilePath kRunToolScript =
.Append(FILE_PATH_LITERAL("scripts"))
.Append(FILE_PATH_LITERAL("run_tool.py"));
const std::string kClangToolSwitches[] = {
"-Wno-comment", "-Wno-tautological-unsigned-enum-zero-compare",
"-Wno-tautological-constant-compare", "-Wno-error=unknown-warning-option"};
// Checks if the list of |path_filters| include the given |file_path|, or there
// are path filters which are a folder (don't have a '.' in their name), and
// match the file name.
......@@ -112,6 +114,14 @@ TrafficAnnotationAuditor::TrafficAnnotationAuditor(
DCHECK(!source_path.empty());
DCHECK(!build_path.empty());
DCHECK(!clang_tool_path.empty());
std::string file_content;
if (base::ReadFileToString(kClangToolSwitchesPath, &file_content)) {
clang_tool_switches_ = base::SplitString(
file_content, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
} else {
LOG(ERROR) << "Could not read " << kClangToolSwitchesPath;
}
}
TrafficAnnotationAuditor::~TrafficAnnotationAuditor() = default;
......@@ -168,8 +178,9 @@ bool TrafficAnnotationAuditor::RunClangTool(
base::MakeAbsoluteFilePath(clang_tool_path_).MaybeAsASCII().c_str(),
base::MakeAbsoluteFilePath(GetClangLibraryPath()).MaybeAsASCII().c_str());
for (const std::string& item : kClangToolSwitches)
for (const std::string& item : clang_tool_switches_)
fprintf(options_file, "--tool-arg=--extra-arg=%s ", item.c_str());
if (use_compile_commands)
fprintf(options_file, "--all ");
......
......@@ -159,6 +159,8 @@ class TrafficAnnotationAuditor {
const base::FilePath build_path_;
const base::FilePath clang_tool_path_;
std::vector<std::string> clang_tool_switches_;
TrafficAnnotationExporter exporter_;
std::string clang_tool_raw_output_;
......
-Wno-comment
-Wno-tautological-unsigned-enum-zero-compare
-Wno-tautological-constant-compare
-Wno-error=unknown-warning-option
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment