mirror of
https://github.com/intel/llvm.git
synced 2026-01-22 07:01:03 +08:00
__is_target_environment: Check the environment after parsing it
This ensures that target triples with environment versions can still work with __is_target_environment. llvm-svn: 320854
This commit is contained in:
@@ -1643,10 +1643,9 @@ static bool isTargetOS(const TargetInfo &TI, const IdentifierInfo *II) {
|
||||
/// Implements the __is_target_environment builtin macro.
|
||||
static bool isTargetEnvironment(const TargetInfo &TI,
|
||||
const IdentifierInfo *II) {
|
||||
StringRef EnvName = TI.getTriple().getEnvironmentName();
|
||||
if (EnvName.empty())
|
||||
EnvName = "unknown";
|
||||
return EnvName.equals_lower(II->getName());
|
||||
std::string EnvName = (llvm::Twine("---") + II->getName().lower()).str();
|
||||
llvm::Triple Env(EnvName);
|
||||
return TI.getTriple().getEnvironment() == Env.getEnvironment();
|
||||
}
|
||||
|
||||
/// ExpandBuiltinMacro - If an identifier token is read that is to be expanded
|
||||
|
||||
6
clang/test/Preprocessor/is_target_environment_version.c
Normal file
6
clang/test/Preprocessor/is_target_environment_version.c
Normal file
@@ -0,0 +1,6 @@
|
||||
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-pc-windows-msvc18.0.0 -verify %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
#if !__is_target_environment(msvc)
|
||||
#error "mismatching environment"
|
||||
#endif
|
||||
Reference in New Issue
Block a user