diff options
author | Chris Lattner <sabre@nondot.org> | 2010-08-17 15:55:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-08-17 15:55:45 +0000 |
commit | c0a585d63c6cf700ea01f1fe30c9f4cd51c1e97b (patch) | |
tree | 1b92774145f4e7cf75b6822893a31e08b72060b1 /clang/lib/Lex/PPDirectives.cpp | |
parent | b0ce9b79ba3d42dd303dc661dea932a199170d21 (diff) | |
download | bcm5719-llvm-c0a585d63c6cf700ea01f1fe30c9f4cd51c1e97b.tar.gz bcm5719-llvm-c0a585d63c6cf700ea01f1fe30c9f4cd51c1e97b.zip |
Implement #pragma push_macro, patch by Francois Pichet!
llvm-svn: 111234
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 9cab2d2bfc6..cd24533eb25 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -25,7 +25,7 @@ using namespace clang; // Utility Methods for Preprocessor Directive Handling. //===----------------------------------------------------------------------===// -MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { +MacroInfo *Preprocessor::AllocateMacroInfo() { MacroInfo *MI; if (!MICache.empty()) { @@ -33,10 +33,21 @@ MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { MICache.pop_back(); } else MI = (MacroInfo*) BP.Allocate<MacroInfo>(); + return MI; +} + +MacroInfo *Preprocessor::AllocateMacroInfo(SourceLocation L) { + MacroInfo *MI = AllocateMacroInfo(); new (MI) MacroInfo(L); return MI; } +MacroInfo *Preprocessor::CloneMacroInfo(const MacroInfo &MacroToClone) { + MacroInfo *MI = AllocateMacroInfo(); + new (MI) MacroInfo(MacroToClone, BP); + return MI; +} + /// ReleaseMacroInfo - Release the specified MacroInfo. This memory will /// be reused for allocating new MacroInfo objects. void Preprocessor::ReleaseMacroInfo(MacroInfo* MI) { @@ -1446,15 +1457,15 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { if (!OtherMI->isUsed()) Diag(OtherMI->getDefinitionLoc(), diag::pp_macro_not_used); - // Macros must be identical. This means all tokes and whitespace + // Macros must be identical. This means all tokens and whitespace // separation must be the same. C99 6.10.3.2. - if (!MI->isIdenticalTo(*OtherMI, *this)) { + if (!OtherMI->isAllowRedefinitionsWithoutWarning() && + !MI->isIdenticalTo(*OtherMI, *this)) { Diag(MI->getDefinitionLoc(), diag::ext_pp_macro_redef) << MacroNameTok.getIdentifierInfo(); Diag(OtherMI->getDefinitionLoc(), diag::note_previous_definition); } } - ReleaseMacroInfo(OtherMI); } |