aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/IR/Module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/IR/Module.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/IR/Module.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/contrib/llvm-project/llvm/lib/IR/Module.cpp b/contrib/llvm-project/llvm/lib/IR/Module.cpp
index b51ea45f651a..49fadc9ed7e6 100644
--- a/contrib/llvm-project/llvm/lib/IR/Module.cpp
+++ b/contrib/llvm-project/llvm/lib/IR/Module.cpp
@@ -12,7 +12,6 @@
#include "llvm/IR/Module.h"
#include "SymbolTableListTraitsImpl.h"
-#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
@@ -49,6 +48,7 @@
#include <cassert>
#include <cstdint>
#include <memory>
+#include <optional>
#include <utility>
#include <vector>
@@ -596,7 +596,9 @@ PICLevel::Level Module::getPICLevel() const {
}
void Module::setPICLevel(PICLevel::Level PL) {
- addModuleFlag(ModFlagBehavior::Max, "PIC Level", PL);
+ // The merge result of a non-PIC object and a PIC object can only be reliably
+ // used as a non-PIC object, so use the Min merge behavior.
+ addModuleFlag(ModFlagBehavior::Min, "PIC Level", PL);
}
PIELevel::Level Module::getPIELevel() const {
@@ -613,11 +615,11 @@ void Module::setPIELevel(PIELevel::Level PL) {
addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL);
}
-Optional<CodeModel::Model> Module::getCodeModel() const {
+std::optional<CodeModel::Model> Module::getCodeModel() const {
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Code Model"));
if (!Val)
- return None;
+ return std::nullopt;
return static_cast<CodeModel::Model>(
cast<ConstantInt>(Val->getValue())->getZExtValue());
@@ -773,9 +775,9 @@ static VersionTuple getSDKVersionMD(Metadata *MD) {
auto *Arr = dyn_cast_or_null<ConstantDataArray>(CM->getValue());
if (!Arr)
return {};
- auto getVersionComponent = [&](unsigned Index) -> Optional<unsigned> {
+ auto getVersionComponent = [&](unsigned Index) -> std::optional<unsigned> {
if (Index >= Arr->getNumElements())
- return None;
+ return std::nullopt;
return (unsigned)Arr->getElementAsInteger(Index);
};
auto Major = getVersionComponent(0);