llvm-project/clang/lib/Driver
Daniel Kiss 070acb1d1e [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
2020-07-01 12:13:52 +02:00
..
ToolChains [Driver][ARM] parse version of arm/thumb architecture correctly 2020-07-01 12:13:52 +02:00
Action.cpp Add Statically Linked Libraries 2020-06-22 19:48:49 +00:00
CMakeLists.txt [VE] Clang toolchain for VE 2020-06-24 10:12:09 +02:00
Compilation.cpp [CUDA][HIP] Add -Xarch_device and -Xarch_host options 2020-03-24 10:13:05 -04:00
DarwinSDKInfo.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Distro.cpp Add support of the next Ubuntu (Ubuntu 20.10 - Groovy Gorilla) 2020-05-19 08:30:25 +02:00
Driver.cpp Clang Driver: refactor support for writing response files to be 2020-06-29 18:27:02 -04:00
DriverOptions.cpp [Driver] Use shared singleton instance of DriverOptTable 2019-09-04 14:26:28 +00:00
InputInfo.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Job.cpp Clang Driver: refactor support for writing response files to be 2020-06-29 18:27:02 -04:00
Multilib.cpp Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
OptionUtils.cpp [NFC] Move OptionUtils from Basic to Driver 2019-12-23 08:11:23 -05:00
Phases.cpp [clang][ifs] Clang Interface Stubs ToolChain plumbing. 2019-10-08 15:23:14 +00:00
SanitizerArgs.cpp [SanitizeCoverage] Rename -fsanitize-coverage-{white,black}list to -fsanitize-coverage-{allow,block}list 2020-06-19 22:22:47 -07:00
Tool.cpp Clang Driver: refactor support for writing response files to be 2020-06-29 18:27:02 -04:00
ToolChain.cpp Add Statically Linked Libraries 2020-06-22 19:48:49 +00:00
Types.cpp Recognize *.hxx as a C++ header extension, like *.hpp. 2020-06-08 11:50:34 +02:00
XRayArgs.cpp [Driver] Delete CC1 -fxray-function-index and clean up some tests 2020-06-17 13:00:22 -07:00