Skip to content

Commit 036ea34

Browse files
committed
Make clang report invalid target versions for all environment.
Followup for llvm#75373 1. Make this feature not just available for android, but everyone. 2. Correct some target triples. 3. Add opencl to the environment type list.
1 parent a5052ba commit 036ea34

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/TargetParser/Triple.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,13 @@ StringRef Triple::getEnvironmentVersionString() const {
12311231
StringRef EnvironmentTypeName = getEnvironmentTypeName(getEnvironment());
12321232
EnvironmentName.consume_front(EnvironmentTypeName);
12331233

1234-
if (EnvironmentName.starts_with("-")) {
1235-
// arch-vendor-os-env-obj is correct
1236-
StringRef ObjectFormatType = getObjectFormatTypeName(getObjectFormat());
1237-
if (ObjectFormatType == StringRef(EnvironmentName).split('-').second)
1238-
return "";
1234+
if (EnvironmentName.contains("-")) {
1235+
// -obj is the suffix
1236+
if (getObjectFormat() != Triple::UnknownObjectFormat) {
1237+
StringRef ObjectFormatTypeName = getObjectFormatTypeName(getObjectFormat());
1238+
StringRef Suffix = (Twine("-") + ObjectFormatTypeName).str();
1239+
EnvironmentName.consume_back(Suffix);
1240+
}
12391241
}
12401242
return EnvironmentName;
12411243
}

0 commit comments

Comments
 (0)