@@ -83,6 +83,47 @@ class PPCallbacks {
8383 const  Token &FilenameTok,
8484 SrcMgr::CharacteristicKind FileType) {}
8585
86+  // / Callback invoked whenever the preprocessor cannot find a file for an
87+  // / embed directive.
88+  // /
89+  // / \param FileName The name of the file being included, as written in the
90+  // / source code.
91+  // /
92+  // / \returns true to indicate that the preprocessor should skip this file
93+  // / and not issue any diagnostic.
94+  virtual  bool  EmbedFileNotFound (StringRef FileName) { return  false ; }
95+ 
96+  // / Callback invoked whenever an embed directive has been processed,
97+  // / regardless of whether the embed will actually find a file.
98+  // /
99+  // / \param HashLoc The location of the '#' that starts the embed directive.
100+  // /
101+  // / \param FileName The name of the file being included, as written in the
102+  // / source code.
103+  // /
104+  // / \param IsAngled Whether the file name was enclosed in angle brackets;
105+  // / otherwise, it was enclosed in quotes.
106+  // /
107+  // / \param FilenameRange The character range of the quotes or angle brackets
108+  // / for the written file name.
109+  // /
110+  // / \param ParametersRange The character range of the embed parameters. An
111+  // / empty range if there were no parameters.
112+  // /
113+  // / \param File The actual file that may be included by this embed directive.
114+  // /
115+  // / \param SearchPath Contains the search path which was used to find the file
116+  // / in the file system. If the file was found via an absolute path,
117+  // / SearchPath will be empty.
118+  // /
119+  // / \param RelativePath The path relative to SearchPath, at which the resource
120+  // / file was found. This is equal to FileName.
121+  virtual  void  EmbedDirective (SourceLocation HashLoc, StringRef FileName,
122+  bool  IsAngled, CharSourceRange FilenameRange,
123+  CharSourceRange ParametersRange,
124+  OptionalFileEntryRef File, StringRef SearchPath,
125+  StringRef RelativePath) {}
126+ 
86127 // / Callback invoked whenever the preprocessor cannot find a file for an
87128 // / inclusion directive.
88129 // /
@@ -330,11 +371,15 @@ class PPCallbacks {
330371 SourceRange Range) {
331372 }
332373
374+  // / Hook called when a '__has_embed' directive is read.
375+  virtual  void  HasEmbed (SourceLocation Loc, StringRef FileName, bool  IsAngled,
376+  OptionalFileEntryRef File) {}
377+ 
333378 // / Hook called when a '__has_include' or '__has_include_next' directive is
334379 // / read.
335380 virtual  void  HasInclude (SourceLocation Loc, StringRef FileName, bool  IsAngled,
336381 OptionalFileEntryRef File,
337-  SrcMgr::CharacteristicKind FileType); 
382+  SrcMgr::CharacteristicKind FileType) {} 
338383
339384 // / Hook called when a source range is skipped.
340385 // / \param Range The SourceRange that was skipped. The range begins at the
@@ -461,6 +506,25 @@ class PPChainedCallbacks : public PPCallbacks {
461506 Second->FileSkipped (SkippedFile, FilenameTok, FileType);
462507 }
463508
509+  bool  EmbedFileNotFound (StringRef FileName) override  {
510+  bool  Skip = First->FileNotFound (FileName);
511+  //  Make sure to invoke the second callback, no matter if the first already
512+  //  returned true to skip the file.
513+  Skip |= Second->FileNotFound (FileName);
514+  return  Skip;
515+  }
516+ 
517+  void  EmbedDirective (SourceLocation HashLoc, StringRef FileName, bool  IsAngled,
518+  CharSourceRange FilenameRange,
519+  CharSourceRange ParametersRange,
520+  OptionalFileEntryRef File, StringRef SearchPath,
521+  StringRef RelativePath) override  {
522+  First->EmbedDirective (HashLoc, FileName, IsAngled, FilenameRange,
523+  ParametersRange, File, SearchPath, RelativePath);
524+  Second->EmbedDirective (HashLoc, FileName, IsAngled, FilenameRange,
525+  ParametersRange, File, SearchPath, RelativePath);
526+  }
527+ 
464528 bool  FileNotFound (StringRef FileName) override  {
465529 bool  Skip = First->FileNotFound (FileName);
466530 //  Make sure to invoke the second callback, no matter if the first already
@@ -561,9 +625,18 @@ class PPChainedCallbacks : public PPCallbacks {
561625 Second->PragmaDiagnostic (Loc, Namespace, mapping, Str);
562626 }
563627
628+  void  HasEmbed (SourceLocation Loc, StringRef FileName, bool  IsAngled,
629+  OptionalFileEntryRef File) override  {
630+  First->HasEmbed (Loc, FileName, IsAngled, File);
631+  Second->HasEmbed (Loc, FileName, IsAngled, File);
632+  }
633+ 
564634 void  HasInclude (SourceLocation Loc, StringRef FileName, bool  IsAngled,
565635 OptionalFileEntryRef File,
566-  SrcMgr::CharacteristicKind FileType) override ;
636+  SrcMgr::CharacteristicKind FileType) override  {
637+  First->HasInclude (Loc, FileName, IsAngled, File, FileType);
638+  Second->HasInclude (Loc, FileName, IsAngled, File, FileType);
639+  }
567640
568641 void  PragmaOpenCLExtension (SourceLocation NameLoc, const  IdentifierInfo *Name,
569642 SourceLocation StateLoc, unsigned  State) override  {
0 commit comments