r244024 - [Parse] ArrayRefize PragmaLoopHintInfo. No functionality change.

Benjamin Kramer benny.kra at googlemail.com
Wed Aug 5 02:39:57 PDT 2015


Author: d0k
Date: Wed Aug  5 04:39:57 2015
New Revision: 244024

URL: http://llvm.org/viewvc/llvm-project?rev=244024&view=rev
Log:
[Parse] ArrayRefize PragmaLoopHintInfo. No functionality change.

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=244024&r1=244023&r2=244024&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParsePragma.cpp (original)
+++ cfe/trunk/lib/Parse/ParsePragma.cpp Wed Aug  5 04:39:57 2015
@@ -745,9 +745,7 @@ bool Parser::HandlePragmaMSInitSeg(Strin
 struct PragmaLoopHintInfo {
   Token PragmaName;
   Token Option;
-  Token *Toks;
-  size_t TokSize;
-  PragmaLoopHintInfo() : Toks(nullptr), TokSize(0) {}
+  ArrayRef<Token> Toks;
 };
 
 static std::string PragmaLoopHintString(Token PragmaName, Token Option) {
@@ -780,8 +778,8 @@ bool Parser::HandlePragmaLoopHint(LoopHi
   Hint.OptionLoc = IdentifierLoc::create(
       Actions.Context, Info->Option.getLocation(), OptionInfo);
 
-  Token *Toks = Info->Toks;
-  size_t TokSize = Info->TokSize;
+  const Token *Toks = Info->Toks.data();
+  size_t TokSize = Info->Toks.size();
 
   // Return a valid hint if pragma unroll or nounroll were specified
   // without an argument.
@@ -1928,11 +1926,7 @@ static bool ParseLoopHintValue(Preproces
   EOFTok.setLocation(Tok.getLocation());
   ValueList.push_back(EOFTok); // Terminates expression for parsing.
 
-  Token *TokenArray = (Token *)PP.getPreprocessorAllocator().Allocate(
-      ValueList.size() * sizeof(Token), llvm::alignOf<Token>());
-  std::copy(ValueList.begin(), ValueList.end(), TokenArray);
-  Info.Toks = TokenArray;
-  Info.TokSize = ValueList.size();
+  Info.Toks = llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
 
   Info.PragmaName = PragmaName;
   Info.Option = Option;




More information about the cfe-commits mailing list