[llvm] 9166157 - [X86] Convert PICStyles::Style to scoped enum class. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 3 09:28:20 PST 2019
Author: Simon Pilgrim
Date: 2019-11-03T17:28:04Z
New Revision: 91661573fdeaf605d7c4e10dbb596be433353739
URL: https://github.com/llvm/llvm-project/commit/91661573fdeaf605d7c4e10dbb596be433353739
DIFF: https://github.com/llvm/llvm-project/commit/91661573fdeaf605d7c4e10dbb596be433353739.diff
LOG: [X86] Convert PICStyles::Style to scoped enum class. NFCI.
Fixes MSVC static analyzer warnings about enum safety, this enum performs no integer math so it'd be better to fix its scope.
Added:
Modified:
llvm/lib/Target/X86/X86Subtarget.cpp
llvm/lib/Target/X86/X86Subtarget.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86Subtarget.cpp b/llvm/lib/Target/X86/X86Subtarget.cpp
index f8f78da52cc2..75c3a70b430a 100644
--- a/llvm/lib/Target/X86/X86Subtarget.cpp
+++ b/llvm/lib/Target/X86/X86Subtarget.cpp
@@ -324,8 +324,8 @@ X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
MaybeAlign StackAlignOverride,
unsigned PreferVectorWidthOverride,
unsigned RequiredVectorWidth)
- : X86GenSubtargetInfo(TT, CPU, FS), PICStyle(PICStyles::None), TM(TM),
- TargetTriple(TT), StackAlignOverride(StackAlignOverride),
+ : X86GenSubtargetInfo(TT, CPU, FS), PICStyle(PICStyles::Style::None),
+ TM(TM), TargetTriple(TT), StackAlignOverride(StackAlignOverride),
PreferVectorWidthOverride(PreferVectorWidthOverride),
RequiredVectorWidth(RequiredVectorWidth),
In64BitMode(TargetTriple.getArch() == Triple::x86_64),
@@ -337,15 +337,15 @@ X86Subtarget::X86Subtarget(const Triple &TT, StringRef CPU, StringRef FS,
FrameLowering(*this, getStackAlignment()) {
// Determine the PICStyle based on the target selected.
if (!isPositionIndependent())
- setPICStyle(PICStyles::None);
+ setPICStyle(PICStyles::Style::None);
else if (is64Bit())
- setPICStyle(PICStyles::RIPRel);
+ setPICStyle(PICStyles::Style::RIPRel);
else if (isTargetCOFF())
- setPICStyle(PICStyles::None);
+ setPICStyle(PICStyles::Style::None);
else if (isTargetDarwin())
- setPICStyle(PICStyles::StubPIC);
+ setPICStyle(PICStyles::Style::StubPIC);
else if (isTargetELF())
- setPICStyle(PICStyles::GOT);
+ setPICStyle(PICStyles::Style::GOT);
CallLoweringInfo.reset(new X86CallLowering(*getTargetLowering()));
Legalizer.reset(new X86LegalizerInfo(*this, TM));
diff --git a/llvm/lib/Target/X86/X86Subtarget.h b/llvm/lib/Target/X86/X86Subtarget.h
index e77b64a743a0..14f831045b38 100644
--- a/llvm/lib/Target/X86/X86Subtarget.h
+++ b/llvm/lib/Target/X86/X86Subtarget.h
@@ -40,7 +40,7 @@ class GlobalValue;
///
namespace PICStyles {
-enum Style {
+enum class Style {
StubPIC, // Used on i386-darwin in pic mode.
GOT, // Used on 32 bit elf on when in pic mode.
RIPRel, // Used on X86-64 when in pic mode.
@@ -805,11 +805,11 @@ class X86Subtarget final : public X86GenSubtargetInfo {
bool isTargetWin32() const { return !In64BitMode && isOSWindows(); }
- bool isPICStyleGOT() const { return PICStyle == PICStyles::GOT; }
- bool isPICStyleRIPRel() const { return PICStyle == PICStyles::RIPRel; }
+ bool isPICStyleGOT() const { return PICStyle == PICStyles::Style::GOT; }
+ bool isPICStyleRIPRel() const { return PICStyle == PICStyles::Style::RIPRel; }
bool isPICStyleStubPIC() const {
- return PICStyle == PICStyles::StubPIC;
+ return PICStyle == PICStyles::Style::StubPIC;
}
bool isPositionIndependent() const { return TM.isPositionIndependent(); }
More information about the llvm-commits
mailing list