[PATCH] D41269: [COFF] Warn for locally imported symbols

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 14 19:01:03 PST 2017


smeenai added inline comments.


================
Comment at: COFF/SymbolTable.cpp:102
         LocalImportChunks.push_back(cast<DefinedLocalImport>(Sym)->getChunk());
+        UndefsToLocalImports.try_emplace(Sym, D);
         continue;
----------------
ruiu wrote:
> Can you just call warn() here?
I definitely want to report the object file which is importing the symbol (link.exe does even better and reports the function that's doing the import, but I believe reporting the object file is the best we can do). As far as I can tell, the only way to figure out the object file(s) that are doing the import is to loop through the symbols in `Config->GCRoot` and every object file, as is done below (in the loops I've modified). I could duplicate those loops here to inline the warning, but it seemed better to avoid the duplication and reuse the existing loops.


================
Comment at: test/COFF/locally-imported.test:6
 
+# WARN: warning: [[INPUT:[^:]+]]: locally defined symbol imported: main (defined in [[INPUT]])
+
----------------
ruiu wrote:
> I wouldn't repeat the filename twice in the same line.
The file in which the symbol is defined and the file in which it's imported would normally be different.

If you want, I can change the test so that the symbol is defined and imported in different object files (or perhaps add a different test case which does that), to demonstrate the different filenames.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D41269





More information about the llvm-commits mailing list