[all-commits] [llvm/llvm-project] 070acb: [Driver][ARM] parse version of arm/thumb architect...
Dani via All-commits
all-commits at lists.llvm.org
Wed Jul 1 03:14:12 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 070acb1d1e51ffd289a46b8f93e993635d0053b7
https://github.com/llvm/llvm-project/commit/070acb1d1e51ffd289a46b8f93e993635d0053b7
Author: Daniel Kiss <daniel.kiss at arm.com>
Date: 2020-07-01 (Wed, 01 Jul 2020)
Changed paths:
M clang/lib/Driver/ToolChains/Clang.cpp
A clang/test/Driver/windows-thumbv7em.cpp
Log Message:
-----------
[Driver][ARM] parse version of arm/thumb architecture correctly
Summary:
If you execute the following commandline multiple times, the behavior was not always the same:
clang++ --target=thumbv7em-none-windows-eabi-coff -march=armv7-m -mcpu=cortex-m7 -o temp.obj -c -x c++ empty.cpp
Most of the time the compilation succeeded, but sometimes clang reported this error:
clang++: error: the target architecture 'thumbv7em' is not supported by the target 'thumbv7em-none-windows-eabi'
The cause of the inconsistent behavior was the uninitialized variable Version.
With these commandline arguments, the variable Version was not set by getAsInteger(),
because it cannot parse a number from the substring "7em" (of "thumbv7em").
To get a consistent behaviour, it's enough to initialize the variable Version to zero.
Zero is smaller than 7, so the comparison will be true.
Then the command always fails with the error message seen above.
By using consumeInteger() instead of getAsInteger() we get 7 from the substring "7em"
and the command does not fail.
Reviewers: compnerd, danielkiss
Reviewed By: danielkiss
Subscribers: danielkiss, kristof.beyls, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75453
More information about the All-commits
mailing list