From 7b2745447783faa5f94b6f31377fba9284b2e321 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Wed, 8 Aug 2018 22:23:57 +0000 Subject: [ADT] Normalize empty triple components LLVM triple normalization is handling "unknown" and empty components differently; for example given "x86_64-unknown-linux-gnu" and "x86_64-linux-gnu" which should be equivalent, triple normalization returns "x86_64-unknown-linux-gnu" and "x86_64--linux-gnu". autoconf's config.sub returns "x86_64-unknown-linux-gnu" for both "x86_64-linux-gnu" and "x86_64-unknown-linux-gnu". This changes the triple normalization to behave the same way, replacing empty triple components with "unknown". This addresses PR37129. Differential Revision: https://reviews.llvm.org/D50219 llvm-svn: 339294 --- llvm/lib/Support/Triple.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Support/Triple.cpp') diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index b14d6492b1e..c48be2d0cba 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -887,6 +887,12 @@ std::string Triple::normalize(StringRef Str) { } } + // Replace empty components with "unknown" value. + for (unsigned i = 0, e = Components.size(); i < e; ++i) { + if (Components[i].empty()) + Components[i] = "unknown"; + } + // Special case logic goes here. At this point Arch, Vendor and OS have the // correct values for the computed components. std::string NormalizedEnvironment; -- cgit v1.2.3