summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-07-15 20:12:07 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-16 17:31:29 (GMT)
commit535fd6ce6d514deebc8c95424df83f73989f55a5 (patch)
tree568a68aef2720e3f58fbfa862b8b0318dc5a2f0b /Source
parent6e7e881c57e8ff7295a1007d329708143b54baad (diff)
downloadCMake-535fd6ce6d514deebc8c95424df83f73989f55a5.zip
CMake-535fd6ce6d514deebc8c95424df83f73989f55a5.tar.gz
CMake-535fd6ce6d514deebc8c95424df83f73989f55a5.tar.bz2
cmTarget: Make GetLink*Libraries methods safer to use
Split the library lists out of LinkImplementation and LinkInterface into LinkImplementationLibraries and LinkInterfaceLibraries parent classes, respectively. Return these from GetLinkImplementationLibraries and GetLinkInterfaceLibraries, respectively, so that callers cannot access parts of the structures that have not been populated.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx2
-rw-r--r--Source/cmTarget.cxx31
-rw-r--r--Source/cmTarget.h38
3 files changed, 39 insertions, 32 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 3b83cd3..1c15bd3 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -1114,7 +1114,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
else if (std::find_if(transBegin, transEnd,
cmStrCmp(interfacePropertyName)) != transEnd)
{
- const cmTarget::LinkImplementation *impl
+ const cmTarget::LinkImplementationLibraries *impl
= target->GetLinkImplementationLibraries(context->Config);
if(impl)
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index cdece87..b36a600 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4379,7 +4379,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const
{
return false;
}
- if(LinkImplementation const* impl =
+ if(LinkImplementationLibraries const* impl =
this->GetLinkImplementationLibraries(config))
{
return !impl->Libraries.empty();
@@ -5935,7 +5935,7 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(
}
//----------------------------------------------------------------------------
-cmTarget::LinkInterface const*
+cmTarget::LinkInterfaceLibraries const*
cmTarget::GetLinkInterfaceLibraries(const std::string& config,
cmTarget const* head,
bool usage_requirements_only) const
@@ -6017,7 +6017,7 @@ void processILibs(const std::string& config,
if (item.Target && emitted.insert(item.Target).second)
{
tgts.push_back(item.Target);
- if(cmTarget::LinkInterface const* iface =
+ if(cmTarget::LinkInterfaceLibraries const* iface =
item.Target->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator
@@ -6041,7 +6041,7 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const
this->Internal->CacheLinkImplementationClosureDone[config] = true;
std::set<cmTarget const*> emitted;
- cmTarget::LinkImplementation const* impl
+ cmTarget::LinkImplementationLibraries const* impl
= this->GetLinkImplementationLibraries(config);
for(std::vector<cmLinkImplItem>::const_iterator
@@ -6059,7 +6059,7 @@ void cmTarget::GetTransitivePropertyTargets(const std::string& config,
cmTarget const* headTarget,
std::vector<cmTarget const*> &tgts) const
{
- if(cmTarget::LinkInterface const* iface =
+ if(cmTarget::LinkInterfaceLibraries const* iface =
this->GetLinkInterfaceLibraries(config, headTarget, true))
{
for(std::vector<cmLinkItem>::const_iterator it = iface->Libraries.begin();
@@ -6177,7 +6177,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
// to the link implementation.
{
// The link implementation is the default link interface.
- cmTarget::LinkImplementation const* impl =
+ cmTarget::LinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget);
std::copy(impl->Libraries.begin(), impl->Libraries.end(),
std::back_inserter(iface.Libraries));
@@ -6294,7 +6294,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
|| thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD)
{
// The link implementation is the default link interface.
- cmTarget::LinkImplementation const*
+ cmTarget::LinkImplementationLibraries const*
impl = thisTarget->GetLinkImplementationLibrariesInternal(config,
headTarget);
iface.ImplementationIsInterface = true;
@@ -6345,7 +6345,7 @@ void cmTargetInternals::AddInterfaceEntries(
cmTarget const* thisTarget, std::string const& config,
std::string const& prop, std::vector<TargetPropertyEntry*>& entries)
{
- if(cmTarget::LinkImplementation const* impl =
+ if(cmTarget::LinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibraries(config))
{
for (std::vector<cmLinkImplItem>::const_iterator
@@ -6383,7 +6383,7 @@ cmTarget::GetLinkImplementation(const std::string& config) const
if(!impl.LibrariesDone)
{
impl.LibrariesDone = true;
- this->ComputeLinkImplementation(config, impl, this);
+ this->ComputeLinkImplementationLibraries(config, impl, this);
}
if(!impl.LanguagesDone)
{
@@ -6394,14 +6394,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const
}
//----------------------------------------------------------------------------
-cmTarget::LinkImplementation const*
+cmTarget::LinkImplementationLibraries const*
cmTarget::GetLinkImplementationLibraries(const std::string& config) const
{
return this->GetLinkImplementationLibrariesInternal(config, this);
}
//----------------------------------------------------------------------------
-cmTarget::LinkImplementation const*
+cmTarget::LinkImplementationLibraries const*
cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
cmTarget const* head) const
{
@@ -6418,15 +6418,16 @@ cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config,
if(!impl.LibrariesDone)
{
impl.LibrariesDone = true;
- this->ComputeLinkImplementation(config, impl, head);
+ this->ComputeLinkImplementationLibraries(config, impl, head);
}
return &impl;
}
//----------------------------------------------------------------------------
-void cmTarget::ComputeLinkImplementation(const std::string& config,
- LinkImplementation& impl,
- cmTarget const* head) const
+void
+cmTarget::ComputeLinkImplementationLibraries(const std::string& config,
+ LinkImplementation& impl,
+ cmTarget const* head) const
{
// Collect libraries directly linked in this configuration.
for (std::vector<cmValueWithOrigin>::const_iterator
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 4005443..8e21d4f 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -262,13 +262,15 @@ public:
/** The link interface specifies transitive library dependencies and
other information needed by targets that link to this target. */
- struct LinkInterface
+ struct LinkInterfaceLibraries
{
- // Languages whose runtime libraries must be linked.
- std::vector<std::string> Languages;
-
// Libraries listed in the interface.
std::vector<cmLinkItem> Libraries;
+ };
+ struct LinkInterface: public LinkInterfaceLibraries
+ {
+ // Languages whose runtime libraries must be linked.
+ std::vector<std::string> Languages;
// Shared library dependencies needed for linking on some platforms.
std::vector<cmLinkItem> SharedDeps;
@@ -290,22 +292,21 @@ public:
if the target cannot be linked. */
LinkInterface const* GetLinkInterface(const std::string& config,
cmTarget const* headTarget) const;
- LinkInterface const* GetLinkInterfaceLibraries(const std::string& config,
- cmTarget const* headTarget,
- bool usage_requirements_only) const;
+ LinkInterfaceLibraries const*
+ GetLinkInterfaceLibraries(const std::string& config,
+ cmTarget const* headTarget,
+ bool usage_requirements_only) const;
void GetTransitivePropertyTargets(const std::string& config,
cmTarget const* headTarget,
std::vector<cmTarget const*> &libs) const;
+
std::vector<cmTarget const*> const&
GetLinkImplementationClosure(const std::string& config) const;
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
- struct LinkImplementation
+ struct LinkImplementationLibraries
{
- // Languages whose runtime libraries must be linked.
- std::vector<std::string> Languages;
-
// Libraries linked directly in this configuration.
std::vector<cmLinkImplItem> Libraries;
@@ -313,10 +314,15 @@ public:
// Needed only for OLD behavior of CMP0003.
std::vector<cmLinkItem> WrongConfigLibraries;
};
+ struct LinkImplementation: public LinkImplementationLibraries
+ {
+ // Languages whose runtime libraries must be linked.
+ std::vector<std::string> Languages;
+ };
LinkImplementation const*
GetLinkImplementation(const std::string& config) const;
- LinkImplementation const*
+ LinkImplementationLibraries const*
GetLinkImplementationLibraries(const std::string& config) const;
/** Link information from the transitive closure of the link
@@ -778,12 +784,12 @@ private:
GetImportLinkInterface(const std::string& config, cmTarget const* head,
bool usage_requirements_only) const;
- LinkImplementation const*
+ LinkImplementationLibraries const*
GetLinkImplementationLibrariesInternal(const std::string& config,
cmTarget const* head) const;
- void ComputeLinkImplementation(const std::string& config,
- LinkImplementation& impl,
- cmTarget const* head) const;
+ void ComputeLinkImplementationLibraries(const std::string& config,
+ LinkImplementation& impl,
+ cmTarget const* head) const;
void ComputeLinkImplementationLanguages(const std::string& config,
LinkImplementation& impl) const;
void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const;