[WebAssembly] Update to match llvm changes
authorSam Clegg <sbc@chromium.org>
Mon, 14 May 2018 22:42:33 +0000 (22:42 +0000)
committerSam Clegg <sbc@chromium.org>
Mon, 14 May 2018 22:42:33 +0000 (22:42 +0000)
Subscribers: dschuff, jgravelle-google, aheejin, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D46849

llvm-svn: 332306

lld/test/wasm/symbol-type-mismatch.ll
lld/wasm/SymbolTable.cpp
lld/wasm/Symbols.cpp
lld/wasm/Symbols.h

index b38a219..4738c4b 100644 (file)
@@ -7,5 +7,5 @@ target triple = "wasm32-unknown-unknown"
 @ret32 = extern_weak global i32, align 4
 
 ; CHECK: error: symbol type mismatch: ret32
-; CHECK: >>> defined as Data in {{.*}}symbol-type-mismatch.ll.tmp.o
-; CHECK: >>> defined as Function in {{.*}}.ret32.o
+; CHECK: >>> defined as WASM_SYMBOL_TYPE_DATA in {{.*}}symbol-type-mismatch.ll.tmp.o
+; CHECK: >>> defined as WASM_SYMBOL_TYPE_FUNCTION in {{.*}}.ret32.o
index 54e04ab..e86d82f 100644 (file)
@@ -69,17 +69,17 @@ std::pair<Symbol *, bool> SymbolTable::insert(StringRef Name) {
 }
 
 static void reportTypeError(const Symbol *Existing, const InputFile *File,
-                            StringRef Type) {
+                            llvm::wasm::WasmSymbolType Type) {
   error("symbol type mismatch: " + toString(*Existing) + "\n>>> defined as " +
         toString(Existing->getWasmType()) + " in " +
-        toString(Existing->getFile()) + "\n>>> defined as " + Type + " in " +
-        toString(File));
+        toString(Existing->getFile()) + "\n>>> defined as " + toString(Type) +
+        " in " + toString(File));
 }
 
 static void checkFunctionType(const Symbol *Existing, const InputFile *File,
                               const WasmSignature *NewSig) {
   if (!isa<FunctionSymbol>(Existing)) {
-    reportTypeError(Existing, File, "Function");
+    reportTypeError(Existing, File, WASM_SYMBOL_TYPE_FUNCTION);
     return;
   }
 
@@ -98,7 +98,7 @@ static void checkFunctionType(const Symbol *Existing, const InputFile *File,
 static void checkGlobalType(const Symbol *Existing, const InputFile *File,
                             const WasmGlobalType *NewType) {
   if (!isa<GlobalSymbol>(Existing)) {
-    reportTypeError(Existing, File, "Global");
+    reportTypeError(Existing, File, WASM_SYMBOL_TYPE_GLOBAL);
     return;
   }
 
@@ -112,7 +112,7 @@ static void checkGlobalType(const Symbol *Existing, const InputFile *File,
 
 static void checkDataType(const Symbol *Existing, const InputFile *File) {
   if (!isa<DataSymbol>(Existing))
-    reportTypeError(Existing, File, "Data");
+    reportTypeError(Existing, File, WASM_SYMBOL_TYPE_DATA);
 }
 
 DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name,
index 1139e26..82310c4 100644 (file)
@@ -31,13 +31,13 @@ DefinedGlobal *WasmSym::StackPointer;
 
 WasmSymbolType Symbol::getWasmType() const {
   if (isa<FunctionSymbol>(this))
-    return llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION;
+    return WASM_SYMBOL_TYPE_FUNCTION;
   if (isa<DataSymbol>(this))
-    return llvm::wasm::WASM_SYMBOL_TYPE_DATA;
+    return WASM_SYMBOL_TYPE_DATA;
   if (isa<GlobalSymbol>(this))
-    return llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL;
+    return WASM_SYMBOL_TYPE_GLOBAL;
   if (isa<SectionSymbol>(this))
-    return llvm::wasm::WASM_SYMBOL_TYPE_SECTION;
+    return WASM_SYMBOL_TYPE_SECTION;
   llvm_unreachable("invalid symbol kind");
 }
 
@@ -239,17 +239,3 @@ std::string lld::toString(wasm::Symbol::Kind Kind) {
   }
   llvm_unreachable("invalid symbol kind");
 }
-
-std::string lld::toString(WasmSymbolType Type) {
-  switch (Type) {
-  case llvm::wasm::WASM_SYMBOL_TYPE_FUNCTION:
-    return "Function";
-  case llvm::wasm::WASM_SYMBOL_TYPE_DATA:
-    return "Data";
-  case llvm::wasm::WASM_SYMBOL_TYPE_GLOBAL:
-    return "Global";
-  case llvm::wasm::WASM_SYMBOL_TYPE_SECTION:
-    return "Section";
-  }
-  llvm_unreachable("invalid symbol type");
-}
index 0fa599f..8556d32 100644 (file)
@@ -340,7 +340,6 @@ T *replaceSymbol(Symbol *S, ArgT &&... Arg) {
 // Returns a symbol name for an error message.
 std::string toString(const wasm::Symbol &Sym);
 std::string toString(wasm::Symbol::Kind Kind);
-std::string toString(WasmSymbolType Type);
 
 } // namespace lld