clang/include/clang/Lex/Preprocesser.h
这个文件是包含clang::Preprocesser类的定义的头文件。它是类C语言(C、C++、Object C)的预处理的头文件。也就是说,类C语言的预处理都会用到此处的代码。
00082 /// \brief Context in which macro name is used. 00083 enum MacroUse { 00084 MU_Other = 0, // other than #define or #undef 00085 MU_Define = 1, // macro name specified in #define 00086 MU_Undef = 2 // macro name specified in #undef 00087 };
这个枚举很简单,就是通过枚举值来确定到底使用了哪些宏。除了define和undef之外,其他的都分类到MU_Other类别下边了。
00089 /// \brief Engages in a tight little dance with the lexer to efficiently 00090 /// preprocess tokens. 00091 /// 00092 /// Lexers know only about tokens within a single source file, and don‘t 00093 /// know anything about preprocessor-level issues like the \#include stack, 00094 /// token expansion, etc. 00095 class Preprocessor : public RefCountedBase<Preprocessor> { 00096 IntrusiveRefCntPtr<PreprocessorOptions> PPOpts; 00097 DiagnosticsEngine *Diags; 00098 LangOptions &LangOpts; 00099 const TargetInfo *Target; 00100 FileManager &FileMgr; 00101 SourceManager &SourceMgr; 00102 std::unique_ptr<ScratchBuffer> ScratchBuf; 00103 HeaderSearch &HeaderInfo; 00104 ModuleLoader &TheModuleLoader;
这里可以看到Preprocessor的类的定义,而它是模板类RefCountedBase<Preprocessor>的子类。同时可以看看这几个类的几个成员变量,DiagnosticsEngine-诊断引擎,LangOptions-接收的编译选项,TargetInfo-存储目标信息,FileManager-文件管理器,SourceManager-源码管理器,ModuleLoader-module加载器。
00118 /// Identifiers for builtin macros and other builtins. 00119 IdentifierInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__ 00120 IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ 00121 IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ 00122 IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ 00123 IdentifierInfo *Ident__TIMESTAMP__; // __TIMESTAMP__ 00124 IdentifierInfo *Ident__COUNTER__; // __COUNTER__ 00125 IdentifierInfo *Ident_Pragma, *Ident__pragma; // _Pragma, __pragma 00126 IdentifierInfo *Ident__identifier; // __identifier 00127 IdentifierInfo *Ident__VA_ARGS__; // __VA_ARGS__ 00128 IdentifierInfo *Ident__has_feature; // __has_feature 00129 IdentifierInfo *Ident__has_extension; // __has_extension 00130 IdentifierInfo *Ident__has_builtin; // __has_builtin 00131 IdentifierInfo *Ident__has_attribute; // __has_attribute 00132 IdentifierInfo *Ident__has_include; // __has_include 00133 IdentifierInfo *Ident__has_include_next; // __has_include_next 00134 IdentifierInfo *Ident__has_warning; // __has_warning 00135 IdentifierInfo *Ident__is_identifier; // __is_identifier 00136 IdentifierInfo *Ident__building_module; // __building_module 00137 IdentifierInfo *Ident__MODULE__; // __MODULE__ 00138 IdentifierInfo *Ident__has_cpp_attribute; // __has_cpp_attribute
另外Preprocesser类中包含了使用IdentifierInfo指针所保存的内建宏以及其他的内建的标示符。
时间: 2024-11-03 01:52:28