PPCallbacks.h 26 KB

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