Skip to content

Commit 4ccceff

Browse files
author
Muiez
committed
Move RegisterBuiltinMacro
1 parent 1ebfc81 commit 4ccceff

File tree

2 files changed

+47
-47
lines changed

2 files changed

+47
-47
lines changed

clang/include/clang/Lex/Preprocessor.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,19 @@ class Preprocessor {
26122612
/// \#pragma GCC poison/system_header/dependency and \#pragma once.
26132613
void RegisterBuiltinPragmas();
26142614

2615+
/// RegisterBuiltinMacro - Register the specified identifier in the identifier
2616+
/// table and mark it as a builtin macro to be expanded.
2617+
IdentifierInfo *RegisterBuiltinMacro(const char *Name){
2618+
// Get the identifier.
2619+
IdentifierInfo *Id = getIdentifierInfo(Name);
2620+
2621+
// Mark it as being a macro that is builtin.
2622+
MacroInfo *MI = AllocateMacroInfo(SourceLocation());
2623+
MI->setIsBuiltinMacro();
2624+
appendDefMacroDirective(Id, MI);
2625+
return Id;
2626+
}
2627+
26152628
/// Register builtin macros such as __LINE__ with the identifier table.
26162629
void RegisterBuiltinMacros();
26172630

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -321,84 +321,71 @@ void Preprocessor::dumpMacroInfo(const IdentifierInfo *II) {
321321
}
322322
}
323323

324-
/// RegisterBuiltinMacro - Register the specified identifier in the identifier
325-
/// table and mark it as a builtin macro to be expanded.
326-
static IdentifierInfo *RegisterBuiltinMacro(Preprocessor &PP, const char *Name){
327-
// Get the identifier.
328-
IdentifierInfo *Id = PP.getIdentifierInfo(Name);
329-
330-
// Mark it as being a macro that is builtin.
331-
MacroInfo *MI = PP.AllocateMacroInfo(SourceLocation());
332-
MI->setIsBuiltinMacro();
333-
PP.appendDefMacroDirective(Id, MI);
334-
return Id;
335-
}
336-
337324
/// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the
338325
/// identifier table.
339326
void Preprocessor::RegisterBuiltinMacros() {
340-
Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__");
341-
Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__");
342-
Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__");
343-
Ident__TIME__ = RegisterBuiltinMacro(*this, "__TIME__");
344-
Ident__COUNTER__ = RegisterBuiltinMacro(*this, "__COUNTER__");
345-
Ident_Pragma = RegisterBuiltinMacro(*this, "_Pragma");
346-
Ident__FLT_EVAL_METHOD__ = RegisterBuiltinMacro(*this, "__FLT_EVAL_METHOD__");
327+
Ident__LINE__ = RegisterBuiltinMacro("__LINE__");
328+
Ident__FILE__ = RegisterBuiltinMacro("__FILE__");
329+
Ident__DATE__ = RegisterBuiltinMacro("__DATE__");
330+
Ident__TIME__ = RegisterBuiltinMacro("__TIME__");
331+
Ident__COUNTER__ = RegisterBuiltinMacro("__COUNTER__");
332+
Ident_Pragma = RegisterBuiltinMacro("_Pragma");
333+
Ident__FLT_EVAL_METHOD__ = RegisterBuiltinMacro("__FLT_EVAL_METHOD__");
347334

348335
// C++ Standing Document Extensions.
349336
if (getLangOpts().CPlusPlus)
350337
Ident__has_cpp_attribute =
351-
RegisterBuiltinMacro(*this, "__has_cpp_attribute");
338+
RegisterBuiltinMacro("__has_cpp_attribute");
352339
else
353340
Ident__has_cpp_attribute = nullptr;
354341

355342
// GCC Extensions.
356-
Ident__BASE_FILE__ = RegisterBuiltinMacro(*this, "__BASE_FILE__");
357-
Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro(*this, "__INCLUDE_LEVEL__");
358-
Ident__TIMESTAMP__ = RegisterBuiltinMacro(*this, "__TIMESTAMP__");
343+
Ident__BASE_FILE__ = RegisterBuiltinMacro("__BASE_FILE__");
344+
Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro("__INCLUDE_LEVEL__");
345+
Ident__TIMESTAMP__ = RegisterBuiltinMacro("__TIMESTAMP__");
359346

360347
// Microsoft Extensions.
361348
if (getLangOpts().MicrosoftExt) {
362-
Ident__identifier = RegisterBuiltinMacro(*this, "__identifier");
363-
Ident__pragma = RegisterBuiltinMacro(*this, "__pragma");
349+
Ident__identifier = RegisterBuiltinMacro("__identifier");
350+
Ident__pragma = RegisterBuiltinMacro("__pragma");
364351
} else {
365352
Ident__identifier = nullptr;
366353
Ident__pragma = nullptr;
367354
}
368355

369356
// Clang Extensions.
370-
Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
371-
Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
372-
Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
373-
Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
357+
Ident__FILE_NAME__ = RegisterBuiltinMacro("__FILE_NAME__");
358+
Ident__has_feature = RegisterBuiltinMacro("__has_feature");
359+
Ident__has_extension = RegisterBuiltinMacro("__has_extension");
360+
Ident__has_builtin = RegisterBuiltinMacro("__has_builtin");
374361
Ident__has_constexpr_builtin =
375-
RegisterBuiltinMacro(*this, "__has_constexpr_builtin");
376-
Ident__has_attribute = RegisterBuiltinMacro(*this, "__has_attribute");
362+
RegisterBuiltinMacro("__has_constexpr_builtin");
363+
Ident__has_attribute = RegisterBuiltinMacro("__has_attribute");
377364
if (!getLangOpts().CPlusPlus)
378-
Ident__has_c_attribute = RegisterBuiltinMacro(*this, "__has_c_attribute");
365+
Ident__has_c_attribute = RegisterBuiltinMacro("__has_c_attribute");
379366
else
380367
Ident__has_c_attribute = nullptr;
381368

382-
Ident__has_declspec = RegisterBuiltinMacro(*this, "__has_declspec_attribute");
383-
Ident__has_embed = RegisterBuiltinMacro(*this, "__has_embed");
384-
Ident__has_include = RegisterBuiltinMacro(*this, "__has_include");
385-
Ident__has_include_next = RegisterBuiltinMacro(*this, "__has_include_next");
386-
Ident__has_warning = RegisterBuiltinMacro(*this, "__has_warning");
387-
Ident__is_identifier = RegisterBuiltinMacro(*this, "__is_identifier");
388-
Ident__is_target_arch = RegisterBuiltinMacro(*this, "__is_target_arch");
389-
Ident__is_target_vendor = RegisterBuiltinMacro(*this, "__is_target_vendor");
390-
Ident__is_target_os = RegisterBuiltinMacro(*this, "__is_target_os");
369+
Ident__has_declspec = RegisterBuiltinMacro("__has_declspec_attribute");
370+
Ident__has_embed = RegisterBuiltinMacro("__has_embed");
371+
Ident__has_include = RegisterBuiltinMacro("__has_include");
372+
Ident__has_include_next = RegisterBuiltinMacro("__has_include_next");
373+
Ident__has_warning = RegisterBuiltinMacro("__has_warning");
374+
Ident__is_identifier = RegisterBuiltinMacro("__is_identifier");
375+
Ident__is_target_arch = RegisterBuiltinMacro("__is_target_arch");
376+
Ident__is_target_vendor = RegisterBuiltinMacro("__is_target_vendor");
377+
Ident__is_target_os = RegisterBuiltinMacro("__is_target_os");
391378
Ident__is_target_environment =
392-
RegisterBuiltinMacro(*this, "__is_target_environment");
379+
RegisterBuiltinMacro("__is_target_environment");
393380
Ident__is_target_variant_os =
394-
RegisterBuiltinMacro(*this, "__is_target_variant_os");
381+
RegisterBuiltinMacro("__is_target_variant_os");
395382
Ident__is_target_variant_environment =
396-
RegisterBuiltinMacro(*this, "__is_target_variant_environment");
383+
RegisterBuiltinMacro("__is_target_variant_environment");
397384

398385
// Modules.
399-
Ident__building_module = RegisterBuiltinMacro(*this, "__building_module");
386+
Ident__building_module = RegisterBuiltinMacro("__building_module");
400387
if (!getLangOpts().CurrentModule.empty())
401-
Ident__MODULE__ = RegisterBuiltinMacro(*this, "__MODULE__");
388+
Ident__MODULE__ = RegisterBuiltinMacro("__MODULE__");
402389
else
403390
Ident__MODULE__ = nullptr;
404391
}

0 commit comments

Comments
 (0)