Make isValidMCLOHType take unsigned instead of enum to avoid loading invalid enum...
authorAlexey Samsonov <vonosmas@gmail.com>
Fri, 29 Aug 2014 22:34:28 +0000 (22:34 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Fri, 29 Aug 2014 22:34:28 +0000 (22:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216797 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCLinkerOptimizationHint.h
lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp

index 50fd527ffe2a5219cd7afbd7e199f6e82cb06bdb..1f91b0de36479b3b47490b79894eb6c2cb692d28 100644 (file)
@@ -45,7 +45,7 @@ static inline StringRef MCLOHDirectiveName() {
   return StringRef(".loh");
 }
 
-static inline bool isValidMCLOHType(MCLOHType Kind) {
+static inline bool isValidMCLOHType(unsigned Kind) {
   return Kind >= MCLOH_AdrpAdrp && Kind <= MCLOH_AdrpLdrGot;
 }
 
index 057a502757245a326fe9f6c7ced0a5719c55e68e..c4f5449d8694bd1d83d7481a5e2d3454e0fcb856 100644 (file)
@@ -3985,10 +3985,9 @@ bool AArch64AsmParser::parseDirectiveLOH(StringRef IDVal, SMLoc Loc) {
     // 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.