r214446 - Loop hint pragmas sometimes do not contain an identifier option (such as #pragma unroll(4)). Check explicitly that the token we stored was an identifier.

Aaron Ballman aaron at aaronballman.com
Thu Jul 31 14:24:33 PDT 2014


Author: aaronballman
Date: Thu Jul 31 16:24:32 2014
New Revision: 214446

URL: http://llvm.org/viewvc/llvm-project?rev=214446&view=rev
Log:
Loop hint pragmas sometimes do not contain an identifier option (such as #pragma unroll(4)). Check explicitly that the token we stored was an identifier.

Amends r214432

Modified:
    cfe/trunk/lib/Parse/ParsePragma.cpp

Modified: cfe/trunk/lib/Parse/ParsePragma.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParsePragma.cpp?rev=214446&r1=214445&r2=214446&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Thu Jul 31 16:24:32 2014
@@ -733,7 +733,11 @@ bool Parser::HandlePragmaLoopHint(LoopHi
   Hint.PragmaNameLoc = IdentifierLoc::create(
       Actions.Context, Info->PragmaName.getLocation(), PragmaNameInfo);
 
-  IdentifierInfo *OptionInfo = Info->Option.getIdentifierInfo();
+  // It is possible that the loop hint has no option identifier, such as
+  // #pragma unroll(4).
+  IdentifierInfo *OptionInfo = Info->Option.is(tok::identifier)
+                                   ? Info->Option.getIdentifierInfo()
+                                   : nullptr;
   Hint.OptionLoc = IdentifierLoc::create(
       Actions.Context, Info->Option.getLocation(), OptionInfo);
 





More information about the cfe-commits mailing list