From 1913115204027ad779949094c454d704462e77d0 Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Wed, 17 Jan 2018 04:46:04 +0000 Subject: [CodeGen] Fix a crash on mangling multiversioned functions `multiVersionSortPriority` expects features to have no prefix. We currently carry them around in the format "+${feature}". llvm-svn: 322618 --- clang/lib/CodeGen/CodeGenModule.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index fb16c8f2607..68c82870846 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -753,8 +753,12 @@ static void AppendTargetMangling(const CodeGenModule &CGM, const auto &Target = CGM.getTarget(); TargetAttr::ParsedTargetAttr Info = Attr->parse([&Target](StringRef LHS, StringRef RHS) { - return Target.multiVersionSortPriority(LHS) > - Target.multiVersionSortPriority(RHS); + // Multiversioning doesn't allow "no-${feature}", so we can + // only have "+" prefixes here. + assert(LHS.startswith("+") && RHS.startswith("+") && + "Features should always have a prefix."); + return Target.multiVersionSortPriority(LHS.substr(1)) > + Target.multiVersionSortPriority(RHS.substr(1)); }); bool IsFirst = true; -- cgit v1.2.3