]> granicus.if.org Git - llvm/commitdiff
[CFLAA] Use raw pointers instead of Optional<Pointer>. NFC.
authorDavide Italiano <davide@freebsd.org>
Tue, 27 Jun 2017 00:33:37 +0000 (00:33 +0000)
committerDavide Italiano <davide@freebsd.org>
Tue, 27 Jun 2017 00:33:37 +0000 (00:33 +0000)
Using Optional<> here doesn't seem to be terribly valuable, but
this is not the main point of this change. The change enables
us to merge the (now) two identical copies of parentFunctionOfValue()
that Steensgaard's and Andersens' provide.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306351 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFLSteensAliasAnalysis.cpp

index 0825111501ad8b8ece71023b4e7043b2fc3ab948..33154ee95886e1e87a0887e31a5fa0a1eed72968 100644 (file)
@@ -90,7 +90,7 @@ const StratifiedIndex StratifiedLink::SetSentinel =
 /// Determines whether it would be pointless to add the given Value to our sets.
 static bool canSkipAddingToSets(Value *Val);
 
-static Optional<Function *> parentFunctionOfValue(Value *Val) {
+static Function *parentFunctionOfValue(Value *Val) {
   if (auto *Inst = dyn_cast<Instruction>(Val)) {
     auto *Bb = Inst->getParent();
     return Bb->getParent();
@@ -98,7 +98,7 @@ static Optional<Function *> parentFunctionOfValue(Value *Val) {
 
   if (auto *Arg = dyn_cast<Argument>(Val))
     return Arg->getParent();
-  return None;
+  return nullptr;
 }
 
 static bool canSkipAddingToSets(Value *Val) {
@@ -281,9 +281,9 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
     return NoAlias;
 
   Function *Fn = nullptr;
-  auto MaybeFnA = parentFunctionOfValue(ValA);
-  auto MaybeFnB = parentFunctionOfValue(ValB);
-  if (!MaybeFnA.hasValue() && !MaybeFnB.hasValue()) {
+  Function *MaybeFnA = parentFunctionOfValue(ValA);
+  Function *MaybeFnB = parentFunctionOfValue(ValB);
+  if (!MaybeFnA && !MaybeFnB) {
     // The only times this is known to happen are when globals + InlineAsm are
     // involved
     DEBUG(dbgs()
@@ -291,12 +291,12 @@ AliasResult CFLSteensAAResult::query(const MemoryLocation &LocA,
     return MayAlias;
   }
 
-  if (MaybeFnA.hasValue()) {
-    Fn = *MaybeFnA;
-    assert((!MaybeFnB.hasValue() || *MaybeFnB == *MaybeFnA) &&
+  if (MaybeFnA) {
+    Fn = MaybeFnA;
+    assert((!MaybeFnB || MaybeFnB == MaybeFnA) &&
            "Interprocedural queries not supported");
   } else {
-    Fn = *MaybeFnB;
+    Fn = MaybeFnB;
   }
 
   assert(Fn != nullptr);