summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-17 14:44:09 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-18 12:07:46 (GMT)
commita093b1a4f3c8c40c55c50ad8e701ceb599961140 (patch)
tree4cd25b87073e83558763b122d2816627e5b55e15
parente022e2d8734ffbc0378b75d85b32a2524302dd50 (diff)
downloadCMake-a093b1a4f3c8c40c55c50ad8e701ceb599961140.zip
CMake-a093b1a4f3c8c40c55c50ad8e701ceb599961140.tar.gz
CMake-a093b1a4f3c8c40c55c50ad8e701ceb599961140.tar.bz2
cmLinkItem: Add backtrace
Carry a backtrace on every link item, not just link implementation items. For now the non-impl items will still have empty backtraces at runtime, but this will allow us to introduce values over time.
-rw-r--r--Source/cmComputeLinkDepends.cxx3
-rw-r--r--Source/cmComputeTargetDepends.cxx20
-rw-r--r--Source/cmGeneratorTarget.cxx28
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmLinkItem.cxx12
-rw-r--r--Source/cmLinkItem.h9
6 files changed, 39 insertions, 37 deletions
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index aa17de6..e3d53e4 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -6,6 +6,7 @@
#include "cmComputeComponentGraph.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
@@ -565,7 +566,7 @@ cmLinkItem cmComputeLinkDepends::ResolveLinkItem(int depender_index,
from = depender;
}
}
- return from->ResolveLinkItem(name);
+ return from->ResolveLinkItem(name, cmListFileBacktrace());
}
void cmComputeLinkDepends::InferDependencies()
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 268e749..28e1251 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -6,6 +6,7 @@
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmLinkItem.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmPolicies.h"
@@ -22,8 +23,6 @@
#include <stdio.h>
#include <utility>
-class cmListFileBacktrace;
-
/*
This class is meant to analyze inter-target dependencies globally
@@ -208,7 +207,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
for (cmSourceFile const* o : objectFiles) {
std::string const& objLib = o->GetObjectLibrary();
if (!objLib.empty()) {
- cmLinkItem const& objItem = depender->ResolveLinkItem(objLib);
+ cmLinkItem const& objItem =
+ depender->ResolveLinkItem(objLib, cmListFileBacktrace());
if (emitted.insert(objItem).second) {
if (depender->GetType() != cmStateEnums::EXECUTABLE &&
depender->GetType() != cmStateEnums::STATIC_LIBRARY &&
@@ -230,7 +230,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
cmLinkImplementation const* impl = depender->GetLinkImplementation(it);
// A target should not depend on itself.
- emitted.insert(cmLinkItem(depender));
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
for (cmLinkImplItem const& lib : impl->Libraries) {
// Don't emit the same library twice for this target.
if (emitted.insert(lib).second) {
@@ -246,7 +246,7 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
std::set<cmLinkItem> const& tutils = depender->GetUtilityItems();
std::set<cmLinkItem> emitted;
// A target should not depend on itself.
- emitted.insert(cmLinkItem(depender));
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
for (cmLinkItem const& litem : tutils) {
// Don't emit the same utility twice for this target.
if (emitted.insert(litem).second) {
@@ -289,7 +289,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(
if (dependee) {
// A target should not depend on itself.
- emitted.insert(cmLinkItem(depender));
+ emitted.insert(cmLinkItem(depender, cmListFileBacktrace()));
this->AddInterfaceDepends(depender_index, dependee, config, emitted);
}
}
@@ -327,13 +327,7 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
e << "The dependency target \"" << dependee_name << "\" of target \""
<< depender->GetName() << "\" does not exist.";
- cmListFileBacktrace const* backtrace =
- depender->GetUtilityBacktrace(dependee_name.AsStr());
- if (backtrace) {
- cm->IssueMessage(messageType, e.str(), *backtrace);
- } else {
- cm->IssueMessage(messageType, e.str());
- }
+ cm->IssueMessage(messageType, e.str(), dependee_name.Backtrace);
}
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index ea283c6..6ce6512 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -676,11 +676,14 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
this->UtilityItemsDone = true;
std::set<std::string> const& utilities = this->GetUtilities();
for (std::string const& i : utilities) {
+ cmListFileBacktrace const* bt = this->GetUtilityBacktrace(i);
if (cmGeneratorTarget* gt =
this->LocalGenerator->FindGeneratorTargetToUse(i)) {
- this->UtilityItems.insert(cmLinkItem(gt));
+ this->UtilityItems.insert(
+ cmLinkItem(gt, bt ? *bt : cmListFileBacktrace()));
} else {
- this->UtilityItems.insert(cmLinkItem(i));
+ this->UtilityItems.insert(
+ cmLinkItem(i, bt ? *bt : cmListFileBacktrace()));
}
}
}
@@ -4618,6 +4621,7 @@ void cmGeneratorTarget::ReportPropertyOrigin(
}
void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
+ cmListFileBacktrace const& bt,
std::vector<cmLinkItem>& items) const
{
for (std::string const& n : names) {
@@ -4625,7 +4629,7 @@ void cmGeneratorTarget::LookupLinkItems(std::vector<std::string> const& names,
if (name == this->GetName() || name.empty()) {
continue;
}
- items.push_back(this->ResolveLinkItem(name));
+ items.push_back(this->ResolveLinkItem(name, bt));
}
}
@@ -4647,7 +4651,7 @@ void cmGeneratorTarget::ExpandLinkItems(
false, headTarget, this,
&dagChecker),
libs);
- this->LookupLinkItems(libs, items);
+ this->LookupLinkItems(libs, cge->GetBacktrace(), items);
hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
}
@@ -5200,7 +5204,7 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
iface.HadHeadSensitiveCondition);
std::vector<std::string> deps;
cmSystemTools::ExpandListArgument(info->SharedDeps, deps);
- this->LookupLinkItems(deps, iface.SharedDeps);
+ this->LookupLinkItems(deps, cmListFileBacktrace(), iface.SharedDeps);
}
return &iface;
@@ -5736,7 +5740,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
}
// The entry is meant for this configuration.
- impl.Libraries.emplace_back(this->ResolveLinkItem(name), *btIt,
+ impl.Libraries.emplace_back(this->ResolveLinkItem(name, *btIt),
evaluated != *le);
}
@@ -5764,7 +5768,8 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries(
continue;
}
// Support OLD behavior for CMP0003.
- impl.WrongConfigLibraries.push_back(this->ResolveLinkItem(name));
+ impl.WrongConfigLibraries.push_back(
+ this->ResolveLinkItem(name, cmListFileBacktrace()));
}
}
}
@@ -5811,12 +5816,13 @@ cmGeneratorTarget::TargetOrString cmGeneratorTarget::ResolveTargetReference(
return resolved;
}
-cmLinkItem cmGeneratorTarget::ResolveLinkItem(std::string const& name) const
+cmLinkItem cmGeneratorTarget::ResolveLinkItem(
+ std::string const& name, cmListFileBacktrace const& bt) const
{
TargetOrString resolved = this->ResolveTargetReference(name);
if (!resolved.Target) {
- return cmLinkItem(resolved.String);
+ return cmLinkItem(resolved.String, bt);
}
// Skip targets that will not really be linked. This is probably a
@@ -5824,10 +5830,10 @@ cmLinkItem cmGeneratorTarget::ResolveLinkItem(std::string const& name) const
// within the project.
if (resolved.Target->GetType() == cmStateEnums::EXECUTABLE &&
!resolved.Target->IsExecutableWithExports()) {
- return cmLinkItem(resolved.Target->GetName());
+ return cmLinkItem(resolved.Target->GetName(), bt);
}
- return cmLinkItem(resolved.Target);
+ return cmLinkItem(resolved.Target, bt);
}
std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 98669c3..07274ce 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -362,7 +362,8 @@ public:
};
TargetOrString ResolveTargetReference(std::string const& name) const;
- cmLinkItem ResolveLinkItem(std::string const& name) const;
+ cmLinkItem ResolveLinkItem(std::string const& name,
+ cmListFileBacktrace const& bt) const;
// Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change
@@ -838,6 +839,7 @@ private:
std::vector<cmLinkItem>& items,
bool& hadHeadSensitiveCondition) const;
void LookupLinkItems(std::vector<std::string> const& names,
+ cmListFileBacktrace const& bt,
std::vector<cmLinkItem>& items) const;
void GetSourceFiles(std::vector<std::string>& files,
diff --git a/Source/cmLinkItem.cxx b/Source/cmLinkItem.cxx
index 69b6821..121731d 100644
--- a/Source/cmLinkItem.cxx
+++ b/Source/cmLinkItem.cxx
@@ -12,15 +12,18 @@ cmLinkItem::cmLinkItem()
{
}
-cmLinkItem::cmLinkItem(std::string const& n)
+cmLinkItem::cmLinkItem(std::string const& n, cmListFileBacktrace const& bt)
: String(n)
, Target(nullptr)
+ , Backtrace(bt)
{
}
-cmLinkItem::cmLinkItem(cmGeneratorTarget const* t)
+cmLinkItem::cmLinkItem(cmGeneratorTarget const* t,
+ cmListFileBacktrace const& bt)
: String()
, Target(t)
+ , Backtrace(bt)
{
}
@@ -58,15 +61,12 @@ std::ostream& operator<<(std::ostream& os, cmLinkItem const& item)
cmLinkImplItem::cmLinkImplItem()
: cmLinkItem()
- , Backtrace()
, FromGenex(false)
{
}
-cmLinkImplItem::cmLinkImplItem(cmLinkItem item, cmListFileBacktrace const& bt,
- bool fromGenex)
+cmLinkImplItem::cmLinkImplItem(cmLinkItem item, bool fromGenex)
: cmLinkItem(std::move(item))
- , Backtrace(bt)
, FromGenex(fromGenex)
{
}
diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h
index 74fd298..e1ddd22 100644
--- a/Source/cmLinkItem.h
+++ b/Source/cmLinkItem.h
@@ -24,10 +24,11 @@ class cmLinkItem
public:
cmLinkItem();
- explicit cmLinkItem(std::string const& s);
- explicit cmLinkItem(cmGeneratorTarget const* t);
+ cmLinkItem(std::string const& s, cmListFileBacktrace const& bt);
+ cmLinkItem(cmGeneratorTarget const* t, cmListFileBacktrace const& bt);
std::string const& AsStr() const;
cmGeneratorTarget const* Target;
+ cmListFileBacktrace Backtrace;
friend bool operator<(cmLinkItem const& l, cmLinkItem const& r);
friend bool operator==(cmLinkItem const& l, cmLinkItem const& r);
friend std::ostream& operator<<(std::ostream& os, cmLinkItem const& item);
@@ -37,9 +38,7 @@ class cmLinkImplItem : public cmLinkItem
{
public:
cmLinkImplItem();
- cmLinkImplItem(cmLinkItem item, cmListFileBacktrace const& bt,
- bool fromGenex);
- cmListFileBacktrace Backtrace;
+ cmLinkImplItem(cmLinkItem item, bool fromGenex);
bool FromGenex;
};