[PM] Stop playing fast and loose with rebinding of references. However

convenient it is to imagine a world where this works, that is not C++ as
was pointed out in review. The standard even goes to some lengths to
preclude any attempt at this, for better or worse. Maybe better. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203775 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2014-03-13 09:50:31 +00:00
parent 2d9f3bf9f9
commit 04239506f1
2 changed files with 19 additions and 19 deletions

View File

@ -799,14 +799,14 @@ public:
static void *ID() { return (void *)&PassID; }
explicit FunctionAnalysisManagerModuleProxy(FunctionAnalysisManager &FAM)
: FAM(FAM) {}
: FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
FunctionAnalysisManagerModuleProxy(
const FunctionAnalysisManagerModuleProxy &Arg)
: FAM(Arg.FAM) {}
FunctionAnalysisManagerModuleProxy(FunctionAnalysisManagerModuleProxy &&Arg)
: FAM(Arg.FAM) {}
: FAM(std::move(Arg.FAM)) {}
FunctionAnalysisManagerModuleProxy &
operator=(FunctionAnalysisManagerModuleProxy RHS) {
std::swap(*this, RHS);
@ -827,7 +827,7 @@ public:
private:
static char PassID;
FunctionAnalysisManager &FAM;
FunctionAnalysisManager *FAM;
};
/// \brief The result proxy object for the
@ -836,11 +836,11 @@ private:
/// See its documentation for more information.
class FunctionAnalysisManagerModuleProxy::Result {
public:
explicit Result(FunctionAnalysisManager &FAM) : FAM(FAM) {}
explicit Result(FunctionAnalysisManager &FAM) : FAM(&FAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
Result(const Result &Arg) : FAM(Arg.FAM) {}
Result(Result &&Arg) : FAM(Arg.FAM) {}
Result(Result &&Arg) : FAM(std::move(Arg.FAM)) {}
Result &operator=(Result RHS) {
std::swap(*this, RHS);
return *this;
@ -848,7 +848,7 @@ public:
~Result();
/// \brief Accessor for the \c FunctionAnalysisManager.
FunctionAnalysisManager &getManager() { return FAM; }
FunctionAnalysisManager &getManager() { return *FAM; }
/// \brief Handler for invalidation of the module.
///
@ -863,7 +863,7 @@ public:
bool invalidate(Module *M, const PreservedAnalyses &PA);
private:
FunctionAnalysisManager &FAM;
FunctionAnalysisManager *FAM;
};
/// \brief A function analysis which acts as a proxy for a module analysis
@ -883,36 +883,36 @@ public:
/// \brief Result proxy object for \c ModuleAnalysisManagerFunctionProxy.
class Result {
public:
explicit Result(const ModuleAnalysisManager &MAM) : MAM(MAM) {}
explicit Result(const ModuleAnalysisManager &MAM) : MAM(&MAM) {}
// We have to explicitly define all the special member functions because
// MSVC refuses to generate them.
Result(const Result &Arg) : MAM(Arg.MAM) {}
Result(Result &&Arg) : MAM(Arg.MAM) {}
Result(Result &&Arg) : MAM(std::move(Arg.MAM)) {}
Result &operator=(Result RHS) {
std::swap(*this, RHS);
return *this;
}
const ModuleAnalysisManager &getManager() const { return MAM; }
const ModuleAnalysisManager &getManager() const { return *MAM; }
/// \brief Handle invalidation by ignoring it, this pass is immutable.
bool invalidate(Function *) { return false; }
private:
const ModuleAnalysisManager &MAM;
const ModuleAnalysisManager *MAM;
};
static void *ID() { return (void *)&PassID; }
ModuleAnalysisManagerFunctionProxy(const ModuleAnalysisManager &MAM)
: MAM(MAM) {}
: MAM(&MAM) {}
// We have to explicitly define all the special member functions because MSVC
// refuses to generate them.
ModuleAnalysisManagerFunctionProxy(
const ModuleAnalysisManagerFunctionProxy &Arg)
: MAM(Arg.MAM) {}
ModuleAnalysisManagerFunctionProxy(ModuleAnalysisManagerFunctionProxy &&Arg)
: MAM(Arg.MAM) {}
: MAM(std::move(Arg.MAM)) {}
ModuleAnalysisManagerFunctionProxy &
operator=(ModuleAnalysisManagerFunctionProxy RHS) {
std::swap(*this, RHS);
@ -922,12 +922,12 @@ public:
/// \brief Run the analysis pass and create our proxy result object.
/// Nothing to see here, it just forwards the \c MAM reference into the
/// result.
Result run(Function *) { return Result(MAM); }
Result run(Function *) { return Result(*MAM); }
private:
static char PassID;
const ModuleAnalysisManager &MAM;
const ModuleAnalysisManager *MAM;
};
/// \brief Trivial adaptor that maps from a module to its functions.

View File

@ -171,14 +171,14 @@ char FunctionAnalysisManagerModuleProxy::PassID;
FunctionAnalysisManagerModuleProxy::Result
FunctionAnalysisManagerModuleProxy::run(Module *M) {
assert(FAM.empty() && "Function analyses ran prior to the module proxy!");
return Result(FAM);
assert(FAM->empty() && "Function analyses ran prior to the module proxy!");
return Result(*FAM);
}
FunctionAnalysisManagerModuleProxy::Result::~Result() {
// Clear out the analysis manager if we're being destroyed -- it means we
// didn't even see an invalidate call when we got invalidated.
FAM.clear();
FAM->clear();
}
bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
@ -188,7 +188,7 @@ bool FunctionAnalysisManagerModuleProxy::Result::invalidate(
// objects in the cache making it impossible to incrementally preserve them.
// Just clear the entire manager.
if (!PA.preserved(ID()))
FAM.clear();
FAM->clear();
// Return false to indicate that this result is still a valid proxy.
return false;