[llvm] r216797 - Make isValidMCLOHType take unsigned instead of enum to avoid loading invalid enum values
Alexey Samsonov
vonosmas at gmail.com
Fri Aug 29 15:34:28 PDT 2014
Author: samsonov
Date: Fri Aug 29 17:34:28 2014
New Revision: 216797
URL: http://llvm.org/viewvc/llvm-project?rev=216797&view=rev
Log:
Make isValidMCLOHType take unsigned instead of enum to avoid loading invalid enum values
Modified:
llvm/trunk/include/llvm/MC/MCLinkerOptimizationHint.h
llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Modified: llvm/trunk/include/llvm/MC/MCLinkerOptimizationHint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCLinkerOptimizationHint.h?rev=216797&r1=216796&r2=216797&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCLinkerOptimizationHint.h (original)
+++ llvm/trunk/include/llvm/MC/MCLinkerOptimizationHint.h Fri Aug 29 17:34:28 2014
@@ -45,7 +45,7 @@ static inline StringRef MCLOHDirectiveNa
return StringRef(".loh");
}
-static inline bool isValidMCLOHType(MCLOHType Kind) {
+static inline bool isValidMCLOHType(unsigned Kind) {
return Kind >= MCLOH_AdrpAdrp && Kind <= MCLOH_AdrpLdrGot;
}
Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=216797&r1=216796&r2=216797&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Fri Aug 29 17:34:28 2014
@@ -3985,10 +3985,9 @@ bool AArch64AsmParser::parseDirectiveLOH
// We successfully get a numeric value for the identifier.
// Check if it is valid.
int64_t Id = getParser().getTok().getIntVal();
- Kind = (MCLOHType)Id;
- // Check that Id does not overflow MCLOHType.
- if (!isValidMCLOHType(Kind) || Id != Kind)
+ if (Id <= -1U && !isValidMCLOHType(Id))
return TokError("invalid numeric identifier in directive");
+ Kind = (MCLOHType)Id;
} else {
StringRef Name = getTok().getIdentifier();
// We successfully parse an identifier.
More information about the llvm-commits
mailing list