diff options
author | Serge Guelton <sguelton@redhat.com> | 2019-06-20 20:25:59 +0000 |
---|---|---|
committer | Serge Guelton <sguelton@redhat.com> | 2019-06-20 20:25:59 +0000 |
commit | 60ca31a7ddabb46c9ea3762949629433c5eb4c8c (patch) | |
tree | abd6878a7c01f0b1ec8bd08bfda0c550e9018028 /clang/lib/Tooling/InterpolatingCompilationDatabase.cpp | |
parent | 273d97e6bf4eef567499fd3bb0ff23eb6897de9b (diff) | |
download | bcm5719-llvm-60ca31a7ddabb46c9ea3762949629433c5eb4c8c.tar.gz bcm5719-llvm-60ca31a7ddabb46c9ea3762949629433c5eb4c8c.zip |
[clang-tidy] Fail gracefully upon empty database fields
Fix bz#42281
Differential Revision: https://reviews.llvm.org/D63613
llvm-svn: 363975
Diffstat (limited to 'clang/lib/Tooling/InterpolatingCompilationDatabase.cpp')
-rw-r--r-- | clang/lib/Tooling/InterpolatingCompilationDatabase.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp index 8b1030f3607..a467d1318e2 100644 --- a/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp +++ b/clang/lib/Tooling/InterpolatingCompilationDatabase.cpp @@ -150,7 +150,8 @@ struct TransferableCommand { // spelling of each argument; re-rendering is lossy for aliased flags. // E.g. in CL mode, /W4 maps to -Wall. auto OptTable = clang::driver::createDriverOptTable(); - Cmd.CommandLine.emplace_back(OldArgs.front()); + if (!OldArgs.empty()) + Cmd.CommandLine.emplace_back(OldArgs.front()); for (unsigned Pos = 1; Pos < OldArgs.size();) { using namespace driver::options; @@ -243,7 +244,8 @@ private: } // Otherwise just check the clang executable file name. - return llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl"); + return !CmdLine.empty() && + llvm::sys::path::stem(CmdLine.front()).endswith_lower("cl"); } // Map the language from the --std flag to that of the -x flag. |