forked from OSchip/llvm-project
Add notifier hooks to symbol table.
This is the one interesting aspect from: http://reviews.llvm.org/D4965 These hooks are useful for flavor specific processing, such as recording that a DefinedAtom replaced a weak SharedLibraryAtom. llvm-svn: 216122
This commit is contained in:
parent
bba72c7c1e
commit
bb38f7bdaa
|
@ -224,6 +224,20 @@ public:
|
|||
}
|
||||
InputGraph &getInputGraph() const { return *_inputGraph; }
|
||||
|
||||
/// Notify the LinkingContext when an atom is added to the symbol table.
|
||||
/// This is an opportunity for flavor specific work to be done.
|
||||
virtual void notifySymbolTableAdd(const Atom *atom) const {
|
||||
}
|
||||
|
||||
/// Notify the LinkingContext when the symbol table found a name collision.
|
||||
/// The useNew parameter specifies which the symbol table plans to keep,
|
||||
/// but that can be changed by the LinkingContext. This is also an
|
||||
/// opportunity for flavor specific processing.
|
||||
virtual void notifySymbolTableCoalesce(const Atom *existingAtom,
|
||||
const Atom *newAtom,
|
||||
bool &useNew) const {
|
||||
}
|
||||
|
||||
/// This method adds undefined symbols specified by the -u option to the to
|
||||
/// the list of undefined symbols known to the linker. This option essentially
|
||||
/// forces an undefined symbol to be created. You may also need to call
|
||||
|
|
|
@ -171,6 +171,7 @@ bool SymbolTable::addByName(const Atom &newAtom) {
|
|||
const Atom *existing = findByName(name);
|
||||
if (existing == nullptr) {
|
||||
// Name is not in symbol table yet, add it associate with this atom.
|
||||
_context.notifySymbolTableAdd(&newAtom);
|
||||
_nameTable[name] = &newAtom;
|
||||
return true;
|
||||
}
|
||||
|
@ -299,6 +300,9 @@ bool SymbolTable::addByName(const Atom &newAtom) {
|
|||
break;
|
||||
}
|
||||
|
||||
// Give context a chance to change which is kept.
|
||||
_context.notifySymbolTableCoalesce(existing, &newAtom, useNew);
|
||||
|
||||
if (useNew) {
|
||||
// Update name table to use new atom.
|
||||
_nameTable[name] = &newAtom;
|
||||
|
|
Loading…
Reference in New Issue