From: Daniel Dunbar Date: Wed, 29 Feb 2012 01:38:22 +0000 (+0000) Subject: Parse: Change PragmaPackHandler to use the preprocessor allocator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b09395569d7d4d56d5c1f9b5c38ba7ac63cf7545;p=clang Parse: Change PragmaPackHandler to use the preprocessor allocator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151689 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Parse/ParsePragma.cpp b/lib/Parse/ParsePragma.cpp index 96a4f3af76..fef3af249c 100644 --- a/lib/Parse/ParsePragma.cpp +++ b/lib/Parse/ParsePragma.cpp @@ -52,7 +52,6 @@ void Parser::HandlePragmaPack() { SourceLocation PragmaLoc = ConsumeToken(); Actions.ActOnPragmaPack(Info->Kind, Info->Name, Info->Alignment, PragmaLoc, Info->LParenLoc, Info->RParenLoc); - delete Info; } // #pragma GCC visibility comes in two variants: @@ -214,20 +213,26 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, return; } - PragmaPackInfo *Info = new PragmaPackInfo; + PragmaPackInfo *Info = + (PragmaPackInfo*) PP.getPreprocessorAllocator().Allocate( + sizeof(PragmaPackInfo), llvm::alignOf()); + new (Info) PragmaPackInfo(); Info->Kind = Kind; Info->Name = Name; Info->Alignment = Alignment.release(); Info->LParenLoc = LParenLoc; Info->RParenLoc = RParenLoc; - Token *Toks = new Token[1]; + Token *Toks = + (Token*) PP.getPreprocessorAllocator().Allocate( + sizeof(Token) * 1, llvm::alignOf()); + new (Toks) Token(); Toks[0].startToken(); Toks[0].setKind(tok::annot_pragma_pack); Toks[0].setLocation(PackLoc); Toks[0].setAnnotationValue(static_cast(Info)); PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true, - /*OwnsTokens=*/true); + /*OwnsTokens=*/false); } // #pragma ms_struct on @@ -256,7 +261,8 @@ void PragmaMSStructHandler::HandlePragma(Preprocessor &PP, } if (Tok.isNot(tok::eod)) { - PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol) << "ms_struct"; + PP.Diag(Tok.getLocation(), diag::warn_pragma_extra_tokens_at_eol) + << "ms_struct"; return; } Actions.ActOnPragmaMSStruct(Kind); @@ -401,7 +407,9 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, // This allows us to cache a "#pragma unused" that occurs inside an inline // C++ member function. - Token *Toks = new Token[2*Identifiers.size()]; + Token *Toks = + (Token*) PP.getPreprocessorAllocator().Allocate( + sizeof(Token) * 2 * Identifiers.size(), llvm::alignOf()); for (unsigned i=0; i != Identifiers.size(); i++) { Token &pragmaUnusedTok = Toks[2*i], &idTok = Toks[2*i+1]; pragmaUnusedTok.startToken(); @@ -409,7 +417,8 @@ void PragmaUnusedHandler::HandlePragma(Preprocessor &PP, pragmaUnusedTok.setLocation(UnusedLoc); idTok = Identifiers[i]; } - PP.EnterTokenStream(Toks, 2*Identifiers.size(), /*DisableMacroExpansion=*/true, /*OwnsTokens=*/true); + PP.EnterTokenStream(Toks, 2*Identifiers.size(), + /*DisableMacroExpansion=*/true, /*OwnsTokens=*/false); } // #pragma weak identifier