clang-format bits of code to make another patch readable.
[oota-llvm.git] / lib / MC / MCObjectWriter.cpp
1 //===- lib/MC/MCObjectWriter.cpp - MCObjectWriter implementation ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/MC/MCAssembler.h"
11 #include "llvm/MC/MCExpr.h"
12 #include "llvm/MC/MCObjectWriter.h"
13 #include "llvm/MC/MCSymbol.h"
14
15 using namespace llvm;
16
17 MCObjectWriter::~MCObjectWriter() {
18 }
19
20 bool MCObjectWriter::IsSymbolRefDifferenceFullyResolved(
21     const MCAssembler &Asm, const MCSymbolRefExpr *A, const MCSymbolRefExpr *B,
22     bool InSet) const {
23   // Modified symbol references cannot be resolved.
24   if (A->getKind() != MCSymbolRefExpr::VK_None ||
25       B->getKind() != MCSymbolRefExpr::VK_None)
26     return false;
27
28   const MCSymbol &SA = A->getSymbol();
29   const MCSymbol &SB = B->getSymbol();
30   if (SA.AliasedSymbol().isUndefined() || SB.AliasedSymbol().isUndefined())
31     return false;
32
33   const MCSymbolData &DataA = Asm.getSymbolData(SA);
34   const MCSymbolData &DataB = Asm.getSymbolData(SB);
35   if(!DataA.getFragment() || !DataB.getFragment())
36     return false;
37
38   return IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA,
39                                                 *DataB.getFragment(),
40                                                 InSet,
41                                                 false);
42 }
43
44 bool
45 MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
46                                                       const MCSymbolData &DataA,
47                                                       const MCFragment &FB,
48                                                       bool InSet,
49                                                       bool IsPCRel) const {
50   const MCSection &SecA = DataA.getSymbol().AliasedSymbol().getSection();
51   const MCSection &SecB = FB.getParent()->getSection();
52   // On ELF and COFF  A - B is absolute if A and B are in the same section.
53   return &SecA == &SecB;
54 }
55
56 bool MCObjectWriter::isWeak(const MCSymbolData &SD) const { return false; }