[PATCH] D80160: [Tooling] Drop leading/trailing whitespace from compile_flags.txt lines
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 19 02:40:49 PDT 2020
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG48aa781ae44a: [Tooling] Drop leading/trailing whitespace from compile_flags.txt lines (authored by sammccall).
Changed prior to commit:
https://reviews.llvm.org/D80160?vs=264716&id=264828#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80160/new/
https://reviews.llvm.org/D80160
Files:
clang/lib/Tooling/CompilationDatabase.cpp
clang/test/Tooling/fixed-database.cpp
Index: clang/test/Tooling/fixed-database.cpp
===================================================================
--- clang/test/Tooling/fixed-database.cpp
+++ clang/test/Tooling/fixed-database.cpp
@@ -5,7 +5,7 @@
// RUN: cp "%S/Inputs/fixed-header.h" "%t/Include/"
// -I flag is relative to %t (where compile_flags is), not Src/.
// RUN: echo '-IInclude/' >> %t/compile_flags.txt
-// RUN: echo "-Dklazz=class" >> %t/compile_flags.txt
+// RUN: echo " -Dklazz=class " >> %t/compile_flags.txt
// RUN: echo '-std=c++11' >> %t/compile_flags.txt
// RUN: clang-check "%t/Src/test.cpp" 2>&1
// RUN: echo > %t/compile_flags.txt
Index: clang/lib/Tooling/CompilationDatabase.cpp
===================================================================
--- clang/lib/Tooling/CompilationDatabase.cpp
+++ clang/lib/Tooling/CompilationDatabase.cpp
@@ -368,8 +368,14 @@
ErrorMsg = "Error while opening fixed database: " + Result.message();
return nullptr;
}
- std::vector<std::string> Args{llvm::line_iterator(**File),
- llvm::line_iterator()};
+ std::vector<std::string> Args;
+ for (llvm::StringRef Line :
+ llvm::make_range(llvm::line_iterator(**File), llvm::line_iterator())) {
+ // Stray whitespace is almost certainly unintended.
+ Line = Line.trim();
+ if (!Line.empty())
+ Args.push_back(Line.str());
+ }
return std::make_unique<FixedCompilationDatabase>(
llvm::sys::path::parent_path(Path), std::move(Args));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80160.264828.patch
Type: text/x-patch
Size: 1487 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200519/f3da51ca/attachment.bin>
More information about the cfe-commits
mailing list