Files
clang-p2996/mlir/lib/Tools/PDLL/ODS/Constraint.cpp
River Riddle b3fc0fa84a [mlir][PDLL] Don't use the result of Constraint::getDefName() when uniquing
In the case of anonymous defs this may return the name of the base def class,
which can lead to two different defs with the same name (which hits an assert).
This commit adds a new `getUniqueDefName` method that returns a unique name
for the constraint.

Differential Revision: https://reviews.llvm.org/D124074
2022-04-26 18:33:16 -07:00

27 lines
970 B
C++

//===- Constraint.cpp -----------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "mlir/Tools/PDLL/ODS/Constraint.h"
using namespace mlir;
using namespace mlir::pdll::ods;
//===----------------------------------------------------------------------===//
// Constraint
//===----------------------------------------------------------------------===//
StringRef Constraint::getDemangledName() const {
StringRef demangledName = name;
// Drop the "anonymous" suffix if present.
size_t anonymousSuffix = demangledName.find("(anonymous_");
if (anonymousSuffix != StringRef::npos)
demangledName = demangledName.take_front(anonymousSuffix);
return demangledName;
}