My native C++ COM component uses ATL. In DllRegisterServer()
I call CComModule::RegisterServer()
:
STDAPI DllRegisterServer()
{
return _Module.RegisterServer(FALSE); // <<< notice FALSE here
}
FALSE
is passed to indicate to not register the type library.
ATL is available as sources, so I in fact compile the implementation of CComModule::RegisterServer()
. Somewhere down the call stack there's an if
statement:
if( doRegisterTypeLibrary ) { //<< FALSE goes here
// do some stuff, then call RegisterTypeLib()
}
The compiler sees all of the above code and so it can see that in fact the if
condition is always false, yet when I inspect the linker progress messages I see that the reference to RegisterTypeLib()
is still there, so the if
statement is not eliminated.
Can I make Visual C++ 9 perform better static analysis and actually see that some code is never called and not emit that code?