xref: /freebsd/contrib/llvm-project/llvm/lib/MC/MCSymbolXCOFF.cpp (revision 77013d11e6483b970af25e13c9b892075742f7e5)
1 //===- lib/MC/MCSymbolXCOFF.cpp - XCOFF Code Symbol Representation --------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/MC/MCSectionXCOFF.h"
10 
11 using namespace llvm;
12 
13 MCSectionXCOFF *MCSymbolXCOFF::getRepresentedCsect() const {
14   assert(RepresentedCsect &&
15          "Trying to get csect representation of this symbol but none was set.");
16   assert(!getName().equals(getUnqualifiedName()) &&
17          "Symbol does not represent a csect; MCSectionXCOFF that represents "
18          "the symbol should not be (but is) set.");
19   assert(getSymbolTableName().equals(RepresentedCsect->getSymbolTableName()) &&
20          "SymbolTableNames need to be the same for this symbol and its csect "
21          "representation.");
22   return RepresentedCsect;
23 }
24 
25 void MCSymbolXCOFF::setRepresentedCsect(MCSectionXCOFF *C) {
26   assert(C && "Assigned csect should not be null.");
27   assert((!RepresentedCsect || RepresentedCsect == C) &&
28          "Trying to set a csect that doesn't match the one that this symbol is "
29          "already mapped to.");
30   assert(!getName().equals(getUnqualifiedName()) &&
31          "Symbol does not represent a csect; can only set a MCSectionXCOFF "
32          "representation for a csect.");
33   assert(getSymbolTableName().equals(C->getSymbolTableName()) &&
34          "SymbolTableNames need to be the same for this symbol and its csect "
35          "representation.");
36   RepresentedCsect = C;
37 }
38