[PATCH] D75453: [Driver][ARM] fix undefined behaviour when checking architecture version
Jan Ole Hüser via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 6 08:38:48 PDT 2020
j0le updated this revision to Diff 255354.
j0le added a comment.
I added a test case.
I hope the folder "clang/tests/Driver" is the right one.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75453/new/
https://reviews.llvm.org/D75453
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/windows-thumbv7em.cpp
Index: clang/test/Driver/windows-thumbv7em.cpp
===================================================================
--- /dev/null
+++ clang/test/Driver/windows-thumbv7em.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cpp --target=thumbv7em-none-windows-eabi-coff \
+// RUN: -mcpu=cortex-m7 -c %s -o /dev/null 2>&1 \
+// RUN: | FileCheck --allow-empty %s
+
+// CHECK-NOT: error: the target architecture 'thumbv7em' is not supported by the target 'thumbv7em-none-windows-eabi'
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4091,9 +4091,10 @@
if (Triple.isOSWindows() && (Triple.getArch() == llvm::Triple::arm ||
Triple.getArch() == llvm::Triple::thumb)) {
unsigned Offset = Triple.getArch() == llvm::Triple::arm ? 4 : 6;
- unsigned Version;
- Triple.getArchName().substr(Offset).getAsInteger(10, Version);
- if (Version < 7)
+ unsigned Version = 0;
+ bool Failure =
+ Triple.getArchName().substr(Offset).consumeInteger(10, Version);
+ if (Failure || Version < 7)
D.Diag(diag::err_target_unsupported_arch) << Triple.getArchName()
<< TripleStr;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75453.255354.patch
Type: text/x-patch
Size: 1310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200406/9db8b3ab/attachment-0001.bin>
More information about the cfe-commits
mailing list