[MC/AsmParser] Avoid setting MCSymbol.IsUsed in some cases
[oota-llvm.git] / lib / MC / WinCOFFObjectWriter.cpp
index 3aabce6d6885d39e36ac3a538067e720ddde62ff..56ef1c7a2735d2fcf3c979c5b77d163c04cc329f 100644 (file)
@@ -228,7 +228,7 @@ bool COFFSymbol::should_keep() const {
   }
 
   // if this is a safeseh handler, keep it
-  if (MC && (MC->getFlags() & COFF::SF_SafeSEH))
+  if (MC && (cast<MCSymbolCOFF>(MC)->isSafeSEH()))
     return true;
 
   // if the section its in is being droped, drop it
@@ -394,7 +394,7 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
   COFFSymbol *coff_symbol = GetOrCreateCOFFSymbol(&Symbol);
   SymbolMap[&Symbol] = coff_symbol;
 
-  if (Symbol.getFlags() & COFF::SF_WeakExternal) {
+  if (cast<MCSymbolCOFF>(Symbol).isWeakExternal()) {
     coff_symbol->Data.StorageClass = COFF::IMAGE_SYM_CLASS_WEAK_EXTERNAL;
 
     if (Symbol.isVariable()) {
@@ -430,8 +430,7 @@ void WinCOFFObjectWriter::DefineSymbol(const MCSymbol &Symbol,
 
     const MCSymbolCOFF &SymbolCOFF = cast<MCSymbolCOFF>(Symbol);
     coff_symbol->Data.Type = SymbolCOFF.getType();
-    coff_symbol->Data.StorageClass =
-        (Symbol.getFlags() & COFF::SF_ClassMask) >> COFF::SF_ClassShift;
+    coff_symbol->Data.StorageClass = SymbolCOFF.getClass();
 
     // If no storage class was specified in the streamer, define it here.
     if (coff_symbol->Data.StorageClass == COFF::IMAGE_SYM_CLASS_NULL) {
@@ -527,13 +526,12 @@ bool WinCOFFObjectWriter::ExportSymbol(const MCSymbol &Symbol,
   if (!Symbol.isTemporary())
     return true;
 
-  // Absolute temporary labels are never visible.
-  if (!Symbol.isInSection())
+  // Temporary variable symbols are invisible.
+  if (Symbol.isVariable())
     return false;
 
-  // For now, all non-variable symbols are exported,
-  // the linker will sort the rest out for us.
-  return !Symbol.isVariable();
+  // Absolute temporary labels are never visible.
+  return !Symbol.isAbsolute();
 }
 
 bool WinCOFFObjectWriter::IsPhysicalSection(COFFSection *S) {