[PATCH] D51002: [Tooling] Allow -flto flags and filter out -Wa, flags
Chih-Hung Hsieh via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 22 10:14:31 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340421: [Tooling] Allow -flto flags and filter out -Wa, flags (authored by chh, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D51002?vs=161578&id=161985#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51002
Files:
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/test/Tooling/clang-check-analyzer.cpp
Index: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
===================================================================
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp
@@ -218,6 +218,15 @@
ArrayRef<std::string> Arr;
};
+// Filter of tools unused flags such as -no-integrated-as and -Wa,*.
+// They are not used for syntax checking, and could confuse targets
+// which don't support these options.
+struct FilterUnusedFlags {
+ bool operator() (StringRef S) {
+ return (S == "-no-integrated-as") || S.startswith("-Wa,");
+ }
+};
+
} // namespace
/// Strips any positional args and possible argv[0] from a command-line
@@ -275,10 +284,7 @@
// up with no jobs but then this is the user's fault.
Args.push_back("placeholder.cpp");
- // Remove -no-integrated-as; it's not used for syntax checking,
- // and it confuses targets which don't support this option.
- Args.erase(std::remove_if(Args.begin(), Args.end(),
- MatchesAny(std::string("-no-integrated-as"))),
+ Args.erase(std::remove_if(Args.begin(), Args.end(), FilterUnusedFlags()),
Args.end());
const std::unique_ptr<driver::Compilation> Compilation(
@@ -291,9 +297,11 @@
CompileJobAnalyzer CompileAnalyzer;
for (const auto &Cmd : Jobs) {
- // Collect only for Assemble and Compile jobs. If we do all jobs we get
- // duplicates since Link jobs point to Assemble jobs as inputs.
+ // Collect only for Assemble, Backend, and Compile jobs. If we do all jobs
+ // we get duplicates since Link jobs point to Assemble jobs as inputs.
+ // -flto* flags make the BackendJobClass, which still needs analyzer.
if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass ||
+ Cmd.getSource().getKind() == driver::Action::BackendJobClass ||
Cmd.getSource().getKind() == driver::Action::CompileJobClass) {
CompileAnalyzer.run(&Cmd.getSource());
}
Index: cfe/trunk/test/Tooling/clang-check-analyzer.cpp
===================================================================
--- cfe/trunk/test/Tooling/clang-check-analyzer.cpp
+++ cfe/trunk/test/Tooling/clang-check-analyzer.cpp
@@ -1,4 +1,7 @@
// RUN: clang-check -analyze "%s" -- -c 2>&1 | FileCheck %s
+// RUN: clang-check -analyze "%s" -- -c -flto -Wa,--noexecstack 2>&1 | FileCheck %s
+// RUN: clang-check -analyze "%s" -- -c -no-integrated-as -flto=thin 2>&1 | FileCheck %s
+// RUN: clang-check -analyze "%s" -- -c -flto=full 2>&1 | FileCheck %s
// CHECK: Dereference of null pointer
void a(int *x) { if(x){} *x = 47; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51002.161985.patch
Type: text/x-patch
Size: 2604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/5f04a9a4/attachment.bin>
More information about the llvm-commits
mailing list