LCOV - code coverage report
Current view: top level - lib/MC - MCSectionWasm.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 22 31 71.0 %
Date: 2018-10-20 13:21:21 Functions: 5 6 83.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- lib/MC/MCSectionWasm.cpp - Wasm Code Section Representation --------===//
       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/MCSectionWasm.h"
      11             : #include "llvm/MC/MCAsmInfo.h"
      12             : #include "llvm/MC/MCExpr.h"
      13             : #include "llvm/MC/MCSymbol.h"
      14             : #include "llvm/Support/raw_ostream.h"
      15             : 
      16             : using namespace llvm;
      17             : 
      18        8631 : MCSectionWasm::~MCSectionWasm() {} // anchor.
      19             : 
      20             : // Decides whether a '.section' directive
      21             : // should be printed before the section name.
      22        2952 : bool MCSectionWasm::ShouldOmitSectionDirective(StringRef Name,
      23             :                                                const MCAsmInfo &MAI) const {
      24        2952 :   return MAI.shouldOmitSectionDirective(Name);
      25             : }
      26             : 
      27        2792 : static void printName(raw_ostream &OS, StringRef Name) {
      28        2792 :   if (Name.find_first_not_of("0123456789_."
      29             :                              "abcdefghijklmnopqrstuvwxyz"
      30             :                              "ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) {
      31        2791 :     OS << Name;
      32        2791 :     return;
      33             :   }
      34             :   OS << '"';
      35          79 :   for (const char *B = Name.begin(), *E = Name.end(); B < E; ++B) {
      36          78 :     if (*B == '"') // Unquoted "
      37           0 :       OS << "\\\"";
      38          78 :     else if (*B != '\\') // Neither " or backslash
      39             :       OS << *B;
      40           0 :     else if (B + 1 == E) // Trailing backslash
      41           0 :       OS << "\\\\";
      42             :     else {
      43           0 :       OS << B[0] << B[1]; // Quoted character
      44             :       ++B;
      45             :     }
      46             :   }
      47             :   OS << '"';
      48             : }
      49             : 
      50        2952 : void MCSectionWasm::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
      51             :                                          raw_ostream &OS,
      52             :                                          const MCExpr *Subsection) const {
      53             : 
      54        2952 :   if (ShouldOmitSectionDirective(SectionName, MAI)) {
      55         160 :     OS << '\t' << getSectionName();
      56         160 :     if (Subsection) {
      57             :       OS << '\t';
      58           0 :       Subsection->print(OS, &MAI);
      59             :     }
      60             :     OS << '\n';
      61         160 :     return;
      62             :   }
      63             : 
      64        2792 :   OS << "\t.section\t";
      65        2792 :   printName(OS, getSectionName());
      66        2792 :   OS << ",\"";
      67             : 
      68             :   // TODO: Print section flags.
      69             : 
      70             :   OS << '"';
      71             : 
      72             :   OS << ',';
      73             : 
      74             :   // If comment string is '@', e.g. as on ARM - use '%' instead
      75        2792 :   if (MAI.getCommentString()[0] == '@')
      76             :     OS << '%';
      77             :   else
      78             :     OS << '@';
      79             : 
      80             :   // TODO: Print section type.
      81             : 
      82        2792 :   if (isUnique())
      83           0 :     OS << ",unique," << UniqueID;
      84             : 
      85             :   OS << '\n';
      86             : 
      87        2792 :   if (Subsection) {
      88           0 :     OS << "\t.subsection\t";
      89           0 :     Subsection->print(OS, &MAI);
      90             :     OS << '\n';
      91             :   }
      92             : }
      93             : 
      94           0 : bool MCSectionWasm::UseCodeAlign() const { return false; }
      95             : 
      96        1655 : bool MCSectionWasm::isVirtualSection() const { return false; }

Generated by: LCOV version 1.13