PPCallbacks.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- PPCallbacks.h - Callbacks for Preprocessor actions -----*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. ///
  14. /// \file
  15. /// Defines the PPCallbacks interface.
  16. ///
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CLANG_LEX_PPCALLBACKS_H
  19. #define LLVM_CLANG_LEX_PPCALLBACKS_H
  20. #include "clang/Basic/DiagnosticIDs.h"
  21. #include "clang/Basic/SourceLocation.h"
  22. #include "clang/Basic/SourceManager.h"
  23. #include "clang/Lex/ModuleLoader.h"
  24. #include "clang/Lex/Pragma.h"
  25. #include "llvm/ADT/StringRef.h"
  26. namespace clang {
  27. class Token;
  28. class IdentifierInfo;
  29. class MacroDefinition;
  30. class MacroDirective;
  31. class MacroArgs;
  32. /// This interface provides a way to observe the actions of the
  33. /// preprocessor as it does its thing.
  34. ///
  35. /// Clients can define their hooks here to implement preprocessor level tools.
  36. class PPCallbacks {
  37. public:
  38. virtual ~PPCallbacks();
  39. enum FileChangeReason {
  40. EnterFile, ExitFile, SystemHeaderPragma, RenameFile
  41. };
  42. /// Callback invoked whenever a source file is entered or exited.
  43. ///
  44. /// \param Loc Indicates the new location.
  45. /// \param PrevFID the file that was exited if \p Reason is ExitFile or the
  46. /// the file before the new one entered for \p Reason EnterFile.
  47. virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason,
  48. SrcMgr::CharacteristicKind FileType,
  49. FileID PrevFID = FileID()) {
  50. }
  51. enum class LexedFileChangeReason { EnterFile, ExitFile };
  52. /// Callback invoked whenever the \p Lexer moves to a different file for
  53. /// lexing. Unlike \p FileChanged line number directives and other related
  54. /// pragmas do not trigger callbacks to \p LexedFileChanged.
  55. ///
  56. /// \param FID The \p FileID that the \p Lexer moved to.
  57. ///
  58. /// \param Reason Whether the \p Lexer entered a new file or exited one.
  59. ///
  60. /// \param FileType The \p CharacteristicKind of the file the \p Lexer moved
  61. /// to.
  62. ///
  63. /// \param PrevFID The \p FileID the \p Lexer was using before the change.
  64. ///
  65. /// \param Loc The location where the \p Lexer entered a new file from or the
  66. /// location that the \p Lexer moved into after exiting a file.
  67. virtual void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
  68. SrcMgr::CharacteristicKind FileType,
  69. FileID PrevFID, SourceLocation Loc) {}
  70. /// Callback invoked whenever a source file is skipped as the result
  71. /// of header guard optimization.
  72. ///
  73. /// \param SkippedFile The file that is skipped instead of entering \#include
  74. ///
  75. /// \param FilenameTok The file name token in \#include "FileName" directive
  76. /// or macro expanded file name token from \#include MACRO(PARAMS) directive.
  77. /// Note that FilenameTok contains corresponding quotes/angles symbols.
  78. virtual void FileSkipped(const FileEntryRef &SkippedFile,
  79. const Token &FilenameTok,
  80. SrcMgr::CharacteristicKind FileType) {}
  81. /// Callback invoked whenever the preprocessor cannot find a file for an
  82. /// inclusion directive.
  83. ///
  84. /// \param FileName The name of the file being included, as written in the
  85. /// source code.
  86. ///
  87. /// \returns true to indicate that the preprocessor should skip this file
  88. /// and not issue any diagnostic.
  89. virtual bool FileNotFound(StringRef FileName) { return false; }
  90. /// Callback invoked whenever an inclusion directive of
  91. /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
  92. /// of whether the inclusion will actually result in an inclusion.
  93. ///
  94. /// \param HashLoc The location of the '#' that starts the inclusion
  95. /// directive.
  96. ///
  97. /// \param IncludeTok The token that indicates the kind of inclusion
  98. /// directive, e.g., 'include' or 'import'.
  99. ///
  100. /// \param FileName The name of the file being included, as written in the
  101. /// source code.
  102. ///
  103. /// \param IsAngled Whether the file name was enclosed in angle brackets;
  104. /// otherwise, it was enclosed in quotes.
  105. ///
  106. /// \param FilenameRange The character range of the quotes or angle brackets
  107. /// for the written file name.
  108. ///
  109. /// \param File The actual file that may be included by this inclusion
  110. /// directive.
  111. ///
  112. /// \param SearchPath Contains the search path which was used to find the file
  113. /// in the file system. If the file was found via an absolute include path,
  114. /// SearchPath will be empty. For framework includes, the SearchPath and
  115. /// RelativePath will be split up. For example, if an include of "Some/Some.h"
  116. /// is found via the framework path
  117. /// "path/to/Frameworks/Some.framework/Headers/Some.h", SearchPath will be
  118. /// "path/to/Frameworks/Some.framework/Headers" and RelativePath will be
  119. /// "Some.h".
  120. ///
  121. /// \param RelativePath The path relative to SearchPath, at which the include
  122. /// file was found. This is equal to FileName except for framework includes.
  123. ///
  124. /// \param Imported The module, whenever an inclusion directive was
  125. /// automatically turned into a module import or null otherwise.
  126. ///
  127. /// \param FileType The characteristic kind, indicates whether a file or
  128. /// directory holds normal user code, system code, or system code which is
  129. /// implicitly 'extern "C"' in C++ mode.
  130. ///
  131. virtual void InclusionDirective(SourceLocation HashLoc,
  132. const Token &IncludeTok, StringRef FileName,
  133. bool IsAngled, CharSourceRange FilenameRange,
  134. OptionalFileEntryRef File,
  135. StringRef SearchPath, StringRef RelativePath,
  136. const Module *Imported,
  137. SrcMgr::CharacteristicKind FileType) {}
  138. /// Callback invoked whenever a submodule was entered.
  139. ///
  140. /// \param M The submodule we have entered.
  141. ///
  142. /// \param ImportLoc The location of import directive token.
  143. ///
  144. /// \param ForPragma If entering from pragma directive.
  145. ///
  146. virtual void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
  147. bool ForPragma) { }
  148. /// Callback invoked whenever a submodule was left.
  149. ///
  150. /// \param M The submodule we have left.
  151. ///
  152. /// \param ImportLoc The location of import directive token.
  153. ///
  154. /// \param ForPragma If entering from pragma directive.
  155. ///
  156. virtual void LeftSubmodule(Module *M, SourceLocation ImportLoc,
  157. bool ForPragma) { }
  158. /// Callback invoked whenever there was an explicit module-import
  159. /// syntax.
  160. ///
  161. /// \param ImportLoc The location of import directive token.
  162. ///
  163. /// \param Path The identifiers (and their locations) of the module
  164. /// "path", e.g., "std.vector" would be split into "std" and "vector".
  165. ///
  166. /// \param Imported The imported module; can be null if importing failed.
  167. ///
  168. virtual void moduleImport(SourceLocation ImportLoc,
  169. ModuleIdPath Path,
  170. const Module *Imported) {
  171. }
  172. /// Callback invoked when the end of the main file is reached.
  173. ///
  174. /// No subsequent callbacks will be made.
  175. virtual void EndOfMainFile() {
  176. }
  177. /// Callback invoked when a \#ident or \#sccs directive is read.
  178. /// \param Loc The location of the directive.
  179. /// \param str The text of the directive.
  180. ///
  181. virtual void Ident(SourceLocation Loc, StringRef str) {
  182. }
  183. /// Callback invoked when start reading any pragma directive.
  184. virtual void PragmaDirective(SourceLocation Loc,
  185. PragmaIntroducerKind Introducer) {
  186. }
  187. /// Callback invoked when a \#pragma comment directive is read.
  188. virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
  189. StringRef Str) {
  190. }
  191. /// Callback invoked when a \#pragma mark comment is read.
  192. virtual void PragmaMark(SourceLocation Loc, StringRef Trivia) {
  193. }
  194. /// Callback invoked when a \#pragma detect_mismatch directive is
  195. /// read.
  196. virtual void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
  197. StringRef Value) {
  198. }
  199. /// Callback invoked when a \#pragma clang __debug directive is read.
  200. /// \param Loc The location of the debug directive.
  201. /// \param DebugType The identifier following __debug.
  202. virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType) {
  203. }
  204. /// Determines the kind of \#pragma invoking a call to PragmaMessage.
  205. enum PragmaMessageKind {
  206. /// \#pragma message has been invoked.
  207. PMK_Message,
  208. /// \#pragma GCC warning has been invoked.
  209. PMK_Warning,
  210. /// \#pragma GCC error has been invoked.
  211. PMK_Error
  212. };
  213. /// Callback invoked when a \#pragma message directive is read.
  214. /// \param Loc The location of the message directive.
  215. /// \param Namespace The namespace of the message directive.
  216. /// \param Kind The type of the message directive.
  217. /// \param Str The text of the message directive.
  218. virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace,
  219. PragmaMessageKind Kind, StringRef Str) {
  220. }
  221. /// Callback invoked when a \#pragma gcc diagnostic push directive
  222. /// is read.
  223. virtual void PragmaDiagnosticPush(SourceLocation Loc,
  224. StringRef Namespace) {
  225. }
  226. /// Callback invoked when a \#pragma gcc diagnostic pop directive
  227. /// is read.
  228. virtual void PragmaDiagnosticPop(SourceLocation Loc,
  229. StringRef Namespace) {
  230. }
  231. /// Callback invoked when a \#pragma gcc diagnostic directive is read.
  232. virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
  233. diag::Severity mapping, StringRef Str) {}
  234. /// Called when an OpenCL extension is either disabled or
  235. /// enabled with a pragma.
  236. virtual void PragmaOpenCLExtension(SourceLocation NameLoc,
  237. const IdentifierInfo *Name,
  238. SourceLocation StateLoc, unsigned State) {
  239. }
  240. /// Callback invoked when a \#pragma warning directive is read.
  241. enum PragmaWarningSpecifier {
  242. PWS_Default,
  243. PWS_Disable,
  244. PWS_Error,
  245. PWS_Once,
  246. PWS_Suppress,
  247. PWS_Level1,
  248. PWS_Level2,
  249. PWS_Level3,
  250. PWS_Level4,
  251. };
  252. virtual void PragmaWarning(SourceLocation Loc,
  253. PragmaWarningSpecifier WarningSpec,
  254. ArrayRef<int> Ids) {}
  255. /// Callback invoked when a \#pragma warning(push) directive is read.
  256. virtual void PragmaWarningPush(SourceLocation Loc, int Level) {
  257. }
  258. /// Callback invoked when a \#pragma warning(pop) directive is read.
  259. virtual void PragmaWarningPop(SourceLocation Loc) {
  260. }
  261. /// Callback invoked when a \#pragma execution_character_set(push) directive
  262. /// is read.
  263. virtual void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str) {}
  264. /// Callback invoked when a \#pragma execution_character_set(pop) directive
  265. /// is read.
  266. virtual void PragmaExecCharsetPop(SourceLocation Loc) {}
  267. /// Callback invoked when a \#pragma clang assume_nonnull begin directive
  268. /// is read.
  269. virtual void PragmaAssumeNonNullBegin(SourceLocation Loc) {}
  270. /// Callback invoked when a \#pragma clang assume_nonnull end directive
  271. /// is read.
  272. virtual void PragmaAssumeNonNullEnd(SourceLocation Loc) {}
  273. /// Called by Preprocessor::HandleMacroExpandedIdentifier when a
  274. /// macro invocation is found.
  275. virtual void MacroExpands(const Token &MacroNameTok,
  276. const MacroDefinition &MD, SourceRange Range,
  277. const MacroArgs *Args) {}
  278. /// Hook called whenever a macro definition is seen.
  279. virtual void MacroDefined(const Token &MacroNameTok,
  280. const MacroDirective *MD) {
  281. }
  282. /// Hook called whenever a macro \#undef is seen.
  283. /// \param MacroNameTok The active Token
  284. /// \param MD A MacroDefinition for the named macro.
  285. /// \param Undef New MacroDirective if the macro was defined, null otherwise.
  286. ///
  287. /// MD is released immediately following this callback.
  288. virtual void MacroUndefined(const Token &MacroNameTok,
  289. const MacroDefinition &MD,
  290. const MacroDirective *Undef) {
  291. }
  292. /// Hook called whenever the 'defined' operator is seen.
  293. /// \param MD The MacroDirective if the name was a macro, null otherwise.
  294. virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
  295. SourceRange Range) {
  296. }
  297. /// Hook called when a '__has_include' or '__has_include_next' directive is
  298. /// read.
  299. virtual void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled,
  300. OptionalFileEntryRef File,
  301. SrcMgr::CharacteristicKind FileType);
  302. /// Hook called when a source range is skipped.
  303. /// \param Range The SourceRange that was skipped. The range begins at the
  304. /// \#if/\#else directive and ends after the \#endif/\#else directive.
  305. /// \param EndifLoc The end location of the 'endif' token, which may precede
  306. /// the range skipped by the directive (e.g excluding comments after an
  307. /// 'endif').
  308. virtual void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) {
  309. }
  310. enum ConditionValueKind {
  311. CVK_NotEvaluated, CVK_False, CVK_True
  312. };
  313. /// Hook called whenever an \#if is seen.
  314. /// \param Loc the source location of the directive.
  315. /// \param ConditionRange The SourceRange of the expression being tested.
  316. /// \param ConditionValue The evaluated value of the condition.
  317. ///
  318. // FIXME: better to pass in a list (or tree!) of Tokens.
  319. virtual void If(SourceLocation Loc, SourceRange ConditionRange,
  320. ConditionValueKind ConditionValue) {
  321. }
  322. /// Hook called whenever an \#elif is seen.
  323. /// \param Loc the source location of the directive.
  324. /// \param ConditionRange The SourceRange of the expression being tested.
  325. /// \param ConditionValue The evaluated value of the condition.
  326. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
  327. // FIXME: better to pass in a list (or tree!) of Tokens.
  328. virtual void Elif(SourceLocation Loc, SourceRange ConditionRange,
  329. ConditionValueKind ConditionValue, SourceLocation IfLoc) {
  330. }
  331. /// Hook called whenever an \#ifdef is seen.
  332. /// \param Loc the source location of the directive.
  333. /// \param MacroNameTok Information on the token being tested.
  334. /// \param MD The MacroDefinition if the name was a macro, null otherwise.
  335. virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
  336. const MacroDefinition &MD) {
  337. }
  338. /// Hook called whenever an \#elifdef branch is taken.
  339. /// \param Loc the source location of the directive.
  340. /// \param MacroNameTok Information on the token being tested.
  341. /// \param MD The MacroDefinition if the name was a macro, null otherwise.
  342. virtual void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
  343. const MacroDefinition &MD) {
  344. }
  345. /// Hook called whenever an \#elifdef is skipped.
  346. /// \param Loc the source location of the directive.
  347. /// \param ConditionRange The SourceRange of the expression being tested.
  348. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
  349. // FIXME: better to pass in a list (or tree!) of Tokens.
  350. virtual void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
  351. SourceLocation IfLoc) {
  352. }
  353. /// Hook called whenever an \#ifndef is seen.
  354. /// \param Loc the source location of the directive.
  355. /// \param MacroNameTok Information on the token being tested.
  356. /// \param MD The MacroDefiniton if the name was a macro, null otherwise.
  357. virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
  358. const MacroDefinition &MD) {
  359. }
  360. /// Hook called whenever an \#elifndef branch is taken.
  361. /// \param Loc the source location of the directive.
  362. /// \param MacroNameTok Information on the token being tested.
  363. /// \param MD The MacroDefinition if the name was a macro, null otherwise.
  364. virtual void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
  365. const MacroDefinition &MD) {
  366. }
  367. /// Hook called whenever an \#elifndef is skipped.
  368. /// \param Loc the source location of the directive.
  369. /// \param ConditionRange The SourceRange of the expression being tested.
  370. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
  371. // FIXME: better to pass in a list (or tree!) of Tokens.
  372. virtual void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
  373. SourceLocation IfLoc) {
  374. }
  375. /// Hook called whenever an \#else is seen.
  376. /// \param Loc the source location of the directive.
  377. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
  378. virtual void Else(SourceLocation Loc, SourceLocation IfLoc) {
  379. }
  380. /// Hook called whenever an \#endif is seen.
  381. /// \param Loc the source location of the directive.
  382. /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive.
  383. virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) {
  384. }
  385. };
  386. /// Simple wrapper class for chaining callbacks.
  387. class PPChainedCallbacks : public PPCallbacks {
  388. std::unique_ptr<PPCallbacks> First, Second;
  389. public:
  390. PPChainedCallbacks(std::unique_ptr<PPCallbacks> _First,
  391. std::unique_ptr<PPCallbacks> _Second)
  392. : First(std::move(_First)), Second(std::move(_Second)) {}
  393. ~PPChainedCallbacks() override;
  394. void FileChanged(SourceLocation Loc, FileChangeReason Reason,
  395. SrcMgr::CharacteristicKind FileType,
  396. FileID PrevFID) override {
  397. First->FileChanged(Loc, Reason, FileType, PrevFID);
  398. Second->FileChanged(Loc, Reason, FileType, PrevFID);
  399. }
  400. void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
  401. SrcMgr::CharacteristicKind FileType, FileID PrevFID,
  402. SourceLocation Loc) override {
  403. First->LexedFileChanged(FID, Reason, FileType, PrevFID, Loc);
  404. Second->LexedFileChanged(FID, Reason, FileType, PrevFID, Loc);
  405. }
  406. void FileSkipped(const FileEntryRef &SkippedFile, const Token &FilenameTok,
  407. SrcMgr::CharacteristicKind FileType) override {
  408. First->FileSkipped(SkippedFile, FilenameTok, FileType);
  409. Second->FileSkipped(SkippedFile, FilenameTok, FileType);
  410. }
  411. bool FileNotFound(StringRef FileName) override {
  412. bool Skip = First->FileNotFound(FileName);
  413. // Make sure to invoke the second callback, no matter if the first already
  414. // returned true to skip the file.
  415. Skip |= Second->FileNotFound(FileName);
  416. return Skip;
  417. }
  418. void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
  419. StringRef FileName, bool IsAngled,
  420. CharSourceRange FilenameRange,
  421. OptionalFileEntryRef File, StringRef SearchPath,
  422. StringRef RelativePath, const Module *Imported,
  423. SrcMgr::CharacteristicKind FileType) override {
  424. First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
  425. FilenameRange, File, SearchPath, RelativePath,
  426. Imported, FileType);
  427. Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled,
  428. FilenameRange, File, SearchPath, RelativePath,
  429. Imported, FileType);
  430. }
  431. void EnteredSubmodule(Module *M, SourceLocation ImportLoc,
  432. bool ForPragma) override {
  433. First->EnteredSubmodule(M, ImportLoc, ForPragma);
  434. Second->EnteredSubmodule(M, ImportLoc, ForPragma);
  435. }
  436. void LeftSubmodule(Module *M, SourceLocation ImportLoc,
  437. bool ForPragma) override {
  438. First->LeftSubmodule(M, ImportLoc, ForPragma);
  439. Second->LeftSubmodule(M, ImportLoc, ForPragma);
  440. }
  441. void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path,
  442. const Module *Imported) override {
  443. First->moduleImport(ImportLoc, Path, Imported);
  444. Second->moduleImport(ImportLoc, Path, Imported);
  445. }
  446. void EndOfMainFile() override {
  447. First->EndOfMainFile();
  448. Second->EndOfMainFile();
  449. }
  450. void Ident(SourceLocation Loc, StringRef str) override {
  451. First->Ident(Loc, str);
  452. Second->Ident(Loc, str);
  453. }
  454. void PragmaDirective(SourceLocation Loc,
  455. PragmaIntroducerKind Introducer) override {
  456. First->PragmaDirective(Loc, Introducer);
  457. Second->PragmaDirective(Loc, Introducer);
  458. }
  459. void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind,
  460. StringRef Str) override {
  461. First->PragmaComment(Loc, Kind, Str);
  462. Second->PragmaComment(Loc, Kind, Str);
  463. }
  464. void PragmaMark(SourceLocation Loc, StringRef Trivia) override {
  465. First->PragmaMark(Loc, Trivia);
  466. Second->PragmaMark(Loc, Trivia);
  467. }
  468. void PragmaDetectMismatch(SourceLocation Loc, StringRef Name,
  469. StringRef Value) override {
  470. First->PragmaDetectMismatch(Loc, Name, Value);
  471. Second->PragmaDetectMismatch(Loc, Name, Value);
  472. }
  473. void PragmaDebug(SourceLocation Loc, StringRef DebugType) override {
  474. First->PragmaDebug(Loc, DebugType);
  475. Second->PragmaDebug(Loc, DebugType);
  476. }
  477. void PragmaMessage(SourceLocation Loc, StringRef Namespace,
  478. PragmaMessageKind Kind, StringRef Str) override {
  479. First->PragmaMessage(Loc, Namespace, Kind, Str);
  480. Second->PragmaMessage(Loc, Namespace, Kind, Str);
  481. }
  482. void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override {
  483. First->PragmaDiagnosticPush(Loc, Namespace);
  484. Second->PragmaDiagnosticPush(Loc, Namespace);
  485. }
  486. void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override {
  487. First->PragmaDiagnosticPop(Loc, Namespace);
  488. Second->PragmaDiagnosticPop(Loc, Namespace);
  489. }
  490. void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace,
  491. diag::Severity mapping, StringRef Str) override {
  492. First->PragmaDiagnostic(Loc, Namespace, mapping, Str);
  493. Second->PragmaDiagnostic(Loc, Namespace, mapping, Str);
  494. }
  495. void HasInclude(SourceLocation Loc, StringRef FileName, bool IsAngled,
  496. OptionalFileEntryRef File,
  497. SrcMgr::CharacteristicKind FileType) override;
  498. void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name,
  499. SourceLocation StateLoc, unsigned State) override {
  500. First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
  501. Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State);
  502. }
  503. void PragmaWarning(SourceLocation Loc, PragmaWarningSpecifier WarningSpec,
  504. ArrayRef<int> Ids) override {
  505. First->PragmaWarning(Loc, WarningSpec, Ids);
  506. Second->PragmaWarning(Loc, WarningSpec, Ids);
  507. }
  508. void PragmaWarningPush(SourceLocation Loc, int Level) override {
  509. First->PragmaWarningPush(Loc, Level);
  510. Second->PragmaWarningPush(Loc, Level);
  511. }
  512. void PragmaWarningPop(SourceLocation Loc) override {
  513. First->PragmaWarningPop(Loc);
  514. Second->PragmaWarningPop(Loc);
  515. }
  516. void PragmaExecCharsetPush(SourceLocation Loc, StringRef Str) override {
  517. First->PragmaExecCharsetPush(Loc, Str);
  518. Second->PragmaExecCharsetPush(Loc, Str);
  519. }
  520. void PragmaExecCharsetPop(SourceLocation Loc) override {
  521. First->PragmaExecCharsetPop(Loc);
  522. Second->PragmaExecCharsetPop(Loc);
  523. }
  524. void PragmaAssumeNonNullBegin(SourceLocation Loc) override {
  525. First->PragmaAssumeNonNullBegin(Loc);
  526. Second->PragmaAssumeNonNullBegin(Loc);
  527. }
  528. void PragmaAssumeNonNullEnd(SourceLocation Loc) override {
  529. First->PragmaAssumeNonNullEnd(Loc);
  530. Second->PragmaAssumeNonNullEnd(Loc);
  531. }
  532. void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
  533. SourceRange Range, const MacroArgs *Args) override {
  534. First->MacroExpands(MacroNameTok, MD, Range, Args);
  535. Second->MacroExpands(MacroNameTok, MD, Range, Args);
  536. }
  537. void MacroDefined(const Token &MacroNameTok,
  538. const MacroDirective *MD) override {
  539. First->MacroDefined(MacroNameTok, MD);
  540. Second->MacroDefined(MacroNameTok, MD);
  541. }
  542. void MacroUndefined(const Token &MacroNameTok,
  543. const MacroDefinition &MD,
  544. const MacroDirective *Undef) override {
  545. First->MacroUndefined(MacroNameTok, MD, Undef);
  546. Second->MacroUndefined(MacroNameTok, MD, Undef);
  547. }
  548. void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
  549. SourceRange Range) override {
  550. First->Defined(MacroNameTok, MD, Range);
  551. Second->Defined(MacroNameTok, MD, Range);
  552. }
  553. void SourceRangeSkipped(SourceRange Range, SourceLocation EndifLoc) override {
  554. First->SourceRangeSkipped(Range, EndifLoc);
  555. Second->SourceRangeSkipped(Range, EndifLoc);
  556. }
  557. /// Hook called whenever an \#if is seen.
  558. void If(SourceLocation Loc, SourceRange ConditionRange,
  559. ConditionValueKind ConditionValue) override {
  560. First->If(Loc, ConditionRange, ConditionValue);
  561. Second->If(Loc, ConditionRange, ConditionValue);
  562. }
  563. /// Hook called whenever an \#elif is seen.
  564. void Elif(SourceLocation Loc, SourceRange ConditionRange,
  565. ConditionValueKind ConditionValue, SourceLocation IfLoc) override {
  566. First->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
  567. Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc);
  568. }
  569. /// Hook called whenever an \#ifdef is seen.
  570. void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
  571. const MacroDefinition &MD) override {
  572. First->Ifdef(Loc, MacroNameTok, MD);
  573. Second->Ifdef(Loc, MacroNameTok, MD);
  574. }
  575. /// Hook called whenever an \#elifdef is taken.
  576. void Elifdef(SourceLocation Loc, const Token &MacroNameTok,
  577. const MacroDefinition &MD) override {
  578. First->Elifdef(Loc, MacroNameTok, MD);
  579. Second->Elifdef(Loc, MacroNameTok, MD);
  580. }
  581. /// Hook called whenever an \#elifdef is skipped.
  582. void Elifdef(SourceLocation Loc, SourceRange ConditionRange,
  583. SourceLocation IfLoc) override {
  584. First->Elifdef(Loc, ConditionRange, IfLoc);
  585. Second->Elifdef(Loc, ConditionRange, IfLoc);
  586. }
  587. /// Hook called whenever an \#ifndef is seen.
  588. void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
  589. const MacroDefinition &MD) override {
  590. First->Ifndef(Loc, MacroNameTok, MD);
  591. Second->Ifndef(Loc, MacroNameTok, MD);
  592. }
  593. /// Hook called whenever an \#elifndef is taken.
  594. void Elifndef(SourceLocation Loc, const Token &MacroNameTok,
  595. const MacroDefinition &MD) override {
  596. First->Elifndef(Loc, MacroNameTok, MD);
  597. Second->Elifndef(Loc, MacroNameTok, MD);
  598. }
  599. /// Hook called whenever an \#elifndef is skipped.
  600. void Elifndef(SourceLocation Loc, SourceRange ConditionRange,
  601. SourceLocation IfLoc) override {
  602. First->Elifndef(Loc, ConditionRange, IfLoc);
  603. Second->Elifndef(Loc, ConditionRange, IfLoc);
  604. }
  605. /// Hook called whenever an \#else is seen.
  606. void Else(SourceLocation Loc, SourceLocation IfLoc) override {
  607. First->Else(Loc, IfLoc);
  608. Second->Else(Loc, IfLoc);
  609. }
  610. /// Hook called whenever an \#endif is seen.
  611. void Endif(SourceLocation Loc, SourceLocation IfLoc) override {
  612. First->Endif(Loc, IfLoc);
  613. Second->Endif(Loc, IfLoc);
  614. }
  615. };
  616. } // end namespace clang
  617. #endif
  618. #ifdef __GNUC__
  619. #pragma GCC diagnostic pop
  620. #endif