Commit 82a8c6b0 authored by Brad King's avatar Brad King
Browse files

ENH: Exception safe link interface computation

This fixes cmTarget::GetLinkInterface to compute and return the link
interface in an exception-safe manner.  We manage the link interface
returned by cmTarget::ComputeLinkInterface using auto_ptr.
parent 2b85fcdd
......@@ -3696,19 +3696,22 @@ cmTargetLinkInterface const* cmTarget::GetLinkInterface(const char* config)
if(i == this->LinkInterface.end())
// Compute the link interface for this configuration.
cmTargetLinkInterface* iface = this->ComputeLinkInterface(config);
// Store the information for this configuration.
std::map<cmStdString, cmTargetLinkInterface*>::value_type
entry(config?config:"", iface);
entry(config?config:"", 0);
i = this->LinkInterface.insert(entry).first;
i->second = iface.release();
return i->second;
cmTargetLinkInterface* cmTarget::ComputeLinkInterface(const char* config)
cmTarget::ComputeLinkInterface(const char* config)
// Construct the property name suffix for this configuration.
std::string suffix = "_";
......@@ -3739,14 +3742,14 @@ cmTargetLinkInterface* cmTarget::ComputeLinkInterface(const char* config)
// If still not set, there is no link interface.
return 0;
return cmsys::auto_ptr<cmTargetLinkInterface>();
// Allocate the interface.
cmTargetLinkInterface* iface = new cmTargetLinkInterface;
cmsys::auto_ptr<cmTargetLinkInterface> iface(new cmTargetLinkInterface);
return 0;
return cmsys::auto_ptr<cmTargetLinkInterface>();
// Expand the list of libraries in the interface.
......@@ -21,6 +21,8 @@
#include "cmPropertyMap.h"
#include "cmPolicies.h"
#include <cmsys/auto_ptr.hxx>
class cmake;
class cmMakefile;
class cmSourceFile;
......@@ -533,7 +535,8 @@ private:
cmTargetLinkInformationMap LinkInformation;
// Link interface.
cmTargetLinkInterface* ComputeLinkInterface(const char* config);
ComputeLinkInterface(const char* config);
cmTargetLinkInterfaceMap LinkInterface;
// The cmMakefile instance that owns this target. This should
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment