aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Neuendorffer <stephen.neuendorffer@amd.com>2024-04-01 17:04:29 -0700
committerGitHub <noreply@github.com>2024-04-01 17:04:29 -0700
commit6d0174e70641b1ea172ffed07c43604ef15e28ae (patch)
tree1078c48c76bb065f1f37ff1b1b1436e42e92d215
parent1079fc4f543c42bb09a33d2d79d90edd9c0bac91 (diff)
downloadllvm-6d0174e70641b1ea172ffed07c43604ef15e28ae.zip
llvm-6d0174e70641b1ea172ffed07c43604ef15e28ae.tar.gz
llvm-6d0174e70641b1ea172ffed07c43604ef15e28ae.tar.bz2
[libc] allow libc-hdrgen to work on windows files (#87292)
The code does some (overly simple?) checks on file syntax. These checks assume unix line endings and fail on windows. This commit updates the code to strip extra whitespace, making the checks more robust, particularly in the presence of windows line endings. Fixes #86023
-rw-r--r--libc/utils/HdrGen/Generator.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libc/utils/HdrGen/Generator.cpp b/libc/utils/HdrGen/Generator.cpp
index 3bcf005..d926d5d 100644
--- a/libc/utils/HdrGen/Generator.cpp
+++ b/libc/utils/HdrGen/Generator.cpp
@@ -84,11 +84,19 @@ void Generator::generate(llvm::raw_ostream &OS, llvm::RecordKeeper &Records) {
Line = Line.drop_front(CommandPrefixSize);
P = Line.split("(");
+ // It's possible that we have windows line endings, so strip off the extra
+ // CR.
+ P.second = P.second.trim();
if (P.second.empty() || P.second[P.second.size() - 1] != ')') {
SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
llvm::SourceMgr::DK_Error,
"Command argument list should begin with '(' "
"and end with ')'.");
+ SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
+ llvm::SourceMgr::DK_Error, P.second.data());
+ SrcMgr.PrintMessage(llvm::SMLoc::getFromPointer(P.second.data()),
+ llvm::SourceMgr::DK_Error,
+ std::to_string(P.second.size()));
std::exit(1);
}
llvm::StringRef CommandName = P.first;