15f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===--- PPCallbacks.h - Callbacks for Preprocessor actions -----*- C++ -*-===// 25f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 35f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// The LLVM Compiler Infrastructure 45f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 50bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// This file is distributed under the University of Illinois Open Source 60bc735ffcfb223c0186419547abaa5c84482663eChris Lattner// License. See LICENSE.TXT for details. 75f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer// 85f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// 1027289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// \file 1127289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// \brief Defines the PPCallbacks interface. 1227289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// 135f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer//===----------------------------------------------------------------------===// 145f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 155f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#ifndef LLVM_CLANG_LEX_PPCALLBACKS_H 165f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#define LLVM_CLANG_LEX_PPCALLBACKS_H 175f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 1830a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/DiagnosticIDs.h" 1930a2e16f6c27f888dd11eba6bbbae1e980078fcbChandler Carruth#include "clang/Basic/SourceLocation.h" 205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include "clang/Lex/DirectoryLookup.h" 21f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis#include "clang/Lex/ModuleLoader.h" 220189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella#include "clang/Lex/Pragma.h" 23abfe094ce71c42656dcb84a3bdc3e79cb3c16fc3Chris Lattner#include "llvm/ADT/StringRef.h" 245f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#include <string> 255f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 265f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencernamespace clang { 275f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer class SourceLocation; 287633ab80454147ab4892b8de5fd16582a1f221e8Douglas Gregor class Token; 29a9d9145741ef77db45890911674705b81605b10bChris Lattner class IdentifierInfo; 30c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis class MacroDirective; 31dd08a0c178329ec16cb9e494e6880f3991708b93Argyrios Kyrtzidis class MacroArgs; 321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// \brief This interface provides a way to observe the actions of the 3427289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// preprocessor as it does its thing. 3527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// 3627289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// Clients can define their hooks here to implement preprocessor level tools. 375f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerclass PPCallbacks { 385f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencerpublic: 395f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual ~PPCallbacks(); 401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 415f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer enum FileChangeReason { 425f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer EnterFile, ExitFile, SystemHeaderPragma, RenameFile 435f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer }; 441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked whenever a source file is entered or exited. 46c892c5fa92db137ff68d95afb13fe969d17f4fb2Argyrios Kyrtzidis /// 4727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param Loc Indicates the new location. 4827289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param PrevFID the file that was exited if \p Reason is ExitFile. 495f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, 50c892c5fa92db137ff68d95afb13fe969d17f4fb2Argyrios Kyrtzidis SrcMgr::CharacteristicKind FileType, 51c892c5fa92db137ff68d95afb13fe969d17f4fb2Argyrios Kyrtzidis FileID PrevFID = FileID()) { 525f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5427289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked whenever a source file is skipped as the result 5527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// of header guard optimization. 5627289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// 5727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param ParentFile The file that \#included the skipped file. 5827289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// 5927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param FilenameTok The token in ParentFile that indicates the 6027289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// skipped file. 616fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner virtual void FileSkipped(const FileEntry &ParentFile, 626fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner const Token &FilenameTok, 636fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner SrcMgr::CharacteristicKind FileType) { 646fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner } 65dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar 6627289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked whenever an inclusion directive results in a 6727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// file-not-found error. 681c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// 691c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// \param FileName The name of the file being included, as written in the 701c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// source code. 711c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// 721c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// \param RecoveryPath If this client indicates that it can recover from 731c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// this missing file, the client should set this as an additional header 741c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// search patch. 751c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// 761c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// \returns true to indicate that the preprocessor should attempt to recover 771c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor /// by adding \p RecoveryPath as a header search path. 781c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor virtual bool FileNotFound(StringRef FileName, 791c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor SmallVectorImpl<char> &RecoveryPath) { 801c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor return false; 811c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor } 821c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor 8327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked whenever an inclusion directive of 84809d1be9820039b4cf6efa48246a0d70ffa13394James Dennett /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless 85ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// of whether the inclusion will actually result in an inclusion. 86ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 87ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// \param HashLoc The location of the '#' that starts the inclusion 88ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// directive. 89ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 90ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// \param IncludeTok The token that indicates the kind of inclusion 91ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// directive, e.g., 'include' or 'import'. 92ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 93ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// \param FileName The name of the file being included, as written in the 94ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// source code. 95ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 96ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// \param IsAngled Whether the file name was enclosed in angle brackets; 97ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// otherwise, it was enclosed in quotes. 98ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 99da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis /// \param FilenameRange The character range of the quotes or angle brackets 100da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis /// for the written file name. 101da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis /// 102ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// \param File The actual file that may be included by this inclusion 103ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// directive. 104ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor /// 1057412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// \param SearchPath Contains the search path which was used to find the file 1067412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// in the file system. If the file was found via an absolute include path, 1077412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// SearchPath will be empty. For framework includes, the SearchPath and 1087412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// RelativePath will be split up. For example, if an include of "Some/Some.h" 1097412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// is found via the framework path 1107412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// "path/to/Frameworks/Some.framework/Headers/Some.h", SearchPath will be 1117412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// "path/to/Frameworks/Some.framework/Headers" and RelativePath will be 1127412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// "Some.h". 1137412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// 1147412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// \param RelativePath The path relative to SearchPath, at which the include 1157412494982c8b50c90961302c3a718633b2c3ab7Manuel Klimek /// file was found. This is equal to FileName except for framework includes. 116f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 117f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// \param Imported The module, whenever an inclusion directive was 118f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// automatically turned into a module import or null otherwise. 119f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 120ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor virtual void InclusionDirective(SourceLocation HashLoc, 121ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor const Token &IncludeTok, 122686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef FileName, 123ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor bool IsAngled, 124da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis CharSourceRange FilenameRange, 125ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor const FileEntry *File, 126686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef SearchPath, 127f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis StringRef RelativePath, 128f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis const Module *Imported) { 129f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis } 130f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis 131f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// \brief Callback invoked whenever there was an explicit module-import 132f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// syntax. 133f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 134f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// \param ImportLoc The location of import directive token. 135f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 136f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// \param Path The identifiers (and their locations) of the module 137f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// "path", e.g., "std.vector" would be split into "std" and "vector". 138f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 139f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// \param Imported The imported module; can be null if importing failed. 140f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis /// 141f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis virtual void moduleImport(SourceLocation ImportLoc, 142f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis ModuleIdPath Path, 143f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis const Module *Imported) { 144ecdcb883cbc6bb4a2445dc6f02d58d9bdb54a0edDouglas Gregor } 14508985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 14627289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when the end of the main file is reached. 14727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// 14827289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// No subsequent callbacks will be made. 149dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar virtual void EndOfMainFile() { 150dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar } 151dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar 15227289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#ident or \#sccs directive is read. 15308985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein /// \param Loc The location of the directive. 15408985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein /// \param str The text of the directive. 1555f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer /// 1565f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer virtual void Ident(SourceLocation Loc, const std::string &str) { 1575f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer } 1581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1590189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella /// \brief Callback invoked when start reading any pragma directive. 1600189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella virtual void PragmaDirective(SourceLocation Loc, 1610189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella PragmaIntroducerKind Introducer) { 1620189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella } 1630189fd61ec72d86e008aa5615be80581f84cf703Enea Zaffanella 16427289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#pragma comment directive is read. 1651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump virtual void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, 166a9d9145741ef77db45890911674705b81605b10bChris Lattner const std::string &Str) { 167a9d9145741ef77db45890911674705b81605b10bChris Lattner } 1681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 169a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman /// \brief Callback invoked when a \#pragma detect_mismatch directive is 170a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman /// read. 171a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman virtual void PragmaDetectMismatch(SourceLocation Loc, 172a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman const std::string &Name, 173a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman const std::string &Value) { 174a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman } 175a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman 17685192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj /// \brief Callback invoked when a \#pragma clang __debug directive is read. 17785192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj /// \param Loc The location of the debug directive. 17885192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj /// \param DebugType The identifier following __debug. 17985192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj virtual void PragmaDebug(SourceLocation Loc, StringRef DebugType) { 18085192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj } 18185192c7fe187d5486e12dbc6960af28f16a558a0Tareq A. Siraj 182076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \brief Determines the kind of \#pragma invoking a call to PragmaMessage. 183076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs enum PragmaMessageKind { 184076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \brief \#pragma message has been invoked. 185076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs PMK_Message, 186076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs 187076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \brief \#pragma GCC warning has been invoked. 188076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs PMK_Warning, 189076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs 190076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \brief \#pragma GCC error has been invoked. 191076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs PMK_Error 192076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs }; 193076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs 19427289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#pragma message directive is read. 19508985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein /// \param Loc The location of the message directive. 196076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \param Namespace The namespace of the message directive. 197076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs /// \param Kind The type of the message directive. 198efce31f51d6e7e31e125f96c20f6cdab3ead0a47James Dennett /// \param Str The text of the message directive. 199076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs virtual void PragmaMessage(SourceLocation Loc, StringRef Namespace, 200076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs PragmaMessageKind Kind, StringRef Str) { 201abfe094ce71c42656dcb84a3bdc3e79cb3c16fc3Chris Lattner } 202abfe094ce71c42656dcb84a3bdc3e79cb3c16fc3Chris Lattner 20327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#pragma gcc dianostic push directive 20427289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// is read. 205c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor virtual void PragmaDiagnosticPush(SourceLocation Loc, 206686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Namespace) { 207c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor } 208c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 20927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#pragma gcc dianostic pop directive 21027289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// is read. 211c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor virtual void PragmaDiagnosticPop(SourceLocation Loc, 212686775deca8b8685eb90801495880e3abdd844c2Chris Lattner StringRef Namespace) { 213c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor } 214c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 21527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Callback invoked when a \#pragma gcc dianostic directive is read. 216686775deca8b8685eb90801495880e3abdd844c2Chris Lattner virtual void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, 217ef8225444452a1486bd721f3285301fe84643b00Stephen Hines diag::Severity mapping, StringRef Str) {} 218c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 219a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen /// \brief Called when an OpenCL extension is either disabled or 220a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen /// enabled with a pragma. 221a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen virtual void PragmaOpenCLExtension(SourceLocation NameLoc, 222a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen const IdentifierInfo *Name, 223a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen SourceLocation StateLoc, unsigned State) { 224a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen } 225a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen 2262ee042dee9f7693665e28463955401905474a284Reid Kleckner /// \brief Callback invoked when a \#pragma warning directive is read. 2272ee042dee9f7693665e28463955401905474a284Reid Kleckner virtual void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, 2282ee042dee9f7693665e28463955401905474a284Reid Kleckner ArrayRef<int> Ids) { 2292ee042dee9f7693665e28463955401905474a284Reid Kleckner } 2302ee042dee9f7693665e28463955401905474a284Reid Kleckner 2312ee042dee9f7693665e28463955401905474a284Reid Kleckner /// \brief Callback invoked when a \#pragma warning(push) directive is read. 2322ee042dee9f7693665e28463955401905474a284Reid Kleckner virtual void PragmaWarningPush(SourceLocation Loc, int Level) { 2332ee042dee9f7693665e28463955401905474a284Reid Kleckner } 2342ee042dee9f7693665e28463955401905474a284Reid Kleckner 2352ee042dee9f7693665e28463955401905474a284Reid Kleckner /// \brief Callback invoked when a \#pragma warning(pop) directive is read. 2362ee042dee9f7693665e28463955401905474a284Reid Kleckner virtual void PragmaWarningPop(SourceLocation Loc) { 2372ee042dee9f7693665e28463955401905474a284Reid Kleckner } 2382ee042dee9f7693665e28463955401905474a284Reid Kleckner 23927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Called by Preprocessor::HandleMacroExpandedIdentifier when a 24027289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// macro invocation is found. 241c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis virtual void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD, 242dd08a0c178329ec16cb9e494e6880f3991708b93Argyrios Kyrtzidis SourceRange Range, const MacroArgs *Args) { 243ba9eee326434ba62b180271d3cc2999d94ee0de4Chris Lattner } 2441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever a macro definition is seen. 246c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis virtual void MacroDefined(const Token &MacroNameTok, 247c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis const MacroDirective *MD) { 248f4a72b07747cd6ae1a9f6974e148ae504c879349Chris Lattner } 24941c17473e3ece9e60d97c5d9397866b7730cf7eeChris Lattner 25027289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever a macro \#undef is seen. 25127289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// 252c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis /// MD is released immediately following this callback. 253c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis virtual void MacroUndefined(const Token &MacroNameTok, 254c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis const MacroDirective *MD) { 25541c17473e3ece9e60d97c5d9397866b7730cf7eeChris Lattner } 2566b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis 257efce31f51d6e7e31e125f96c20f6cdab3ead0a47James Dennett /// \brief Hook called whenever the 'defined' operator is seen. 258c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis /// \param MD The MacroDirective if the name was a macro, null otherwise. 2596fb63ab0c74bb777772a3c3ecec09799e275599aJohn Thompson virtual void Defined(const Token &MacroNameTok, const MacroDirective *MD, 2606fb63ab0c74bb777772a3c3ecec09799e275599aJohn Thompson SourceRange Range) { 2613d5f955855cab5a831cc6b9339dc77a7d46f1a30Douglas Gregor } 2623d5f955855cab5a831cc6b9339dc77a7d46f1a30Douglas Gregor 26327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called when a source range is skipped. 2646b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis /// \param Range The SourceRange that was skipped. The range begins at the 26527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \#if/\#else directive and ends after the \#endif/\#else directive. 2666b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis virtual void SourceRangeSkipped(SourceRange Range) { 2676b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis } 26808985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 269651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines enum ConditionValueKind { 270651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CVK_NotEvaluated, CVK_False, CVK_True 271651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines }; 272651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 27327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#if is seen. 2743ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 2753ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param ConditionRange The SourceRange of the expression being tested. 2766a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson /// \param ConditionValue The evaluated value of the condition. 27727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// 27808985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein // FIXME: better to pass in a list (or tree!) of Tokens. 2796a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson virtual void If(SourceLocation Loc, SourceRange ConditionRange, 280651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ConditionValueKind ConditionValue) { 28108985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 28208985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 28327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#elif is seen. 2843ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 2853ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param ConditionRange The SourceRange of the expression being tested. 2866a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson /// \param ConditionValue The evaluated value of the condition. 28727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. 28808985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein // FIXME: better to pass in a list (or tree!) of Tokens. 289bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis virtual void Elif(SourceLocation Loc, SourceRange ConditionRange, 290651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ConditionValueKind ConditionValue, SourceLocation IfLoc) { 29108985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 29208985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 29327289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#ifdef is seen. 2943ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 295efce31f51d6e7e31e125f96c20f6cdab3ead0a47James Dennett /// \param MacroNameTok Information on the token being tested. 296c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis /// \param MD The MacroDirective if the name was a macro, null otherwise. 29761c1c8ee3fa1bd1f4866d246c72af854be834634Argyrios Kyrtzidis virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok, 298c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis const MacroDirective *MD) { 29908985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 30008985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 30127289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#ifndef is seen. 3023ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 303efce31f51d6e7e31e125f96c20f6cdab3ead0a47James Dennett /// \param MacroNameTok Information on the token being tested. 304c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis /// \param MD The MacroDirective if the name was a macro, null otherwise. 30561c1c8ee3fa1bd1f4866d246c72af854be834634Argyrios Kyrtzidis virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok, 306c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis const MacroDirective *MD) { 30708985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 30808985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 30927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#else is seen. 3103ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 31127289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. 312bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis virtual void Else(SourceLocation Loc, SourceLocation IfLoc) { 31308985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 31408985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 31527289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#endif is seen. 3163ebdd8548f97dc5b77172122ab7d6b65de8d4609Argyrios Kyrtzidis /// \param Loc the source location of the directive. 31727289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \param IfLoc the source location of the \#if/\#ifdef/\#ifndef directive. 318bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis virtual void Endif(SourceLocation Loc, SourceLocation IfLoc) { 31908985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 3205f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer}; 3215f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 32227289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett/// \brief Simple wrapper class for chaining callbacks. 323e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbarclass PPChainedCallbacks : public PPCallbacks { 32499ba9e3bd70671f3441fb974895f226a83ce0e66David Blaikie virtual void anchor(); 325e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar PPCallbacks *First, *Second; 326e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar 3271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic: 328e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar PPChainedCallbacks(PPCallbacks *_First, PPCallbacks *_Second) 329e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar : First(_First), Second(_Second) {} 330e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar ~PPChainedCallbacks() { 331e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar delete Second; 332e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar delete First; 333e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 334e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar 335651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FileChanged(SourceLocation Loc, FileChangeReason Reason, 336651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SrcMgr::CharacteristicKind FileType, 337651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines FileID PrevFID) override { 338c892c5fa92db137ff68d95afb13fe969d17f4fb2Argyrios Kyrtzidis First->FileChanged(Loc, Reason, FileType, PrevFID); 339c892c5fa92db137ff68d95afb13fe969d17f4fb2Argyrios Kyrtzidis Second->FileChanged(Loc, Reason, FileType, PrevFID); 340e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 3411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 342651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void FileSkipped(const FileEntry &ParentFile, 343651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const Token &FilenameTok, 344651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SrcMgr::CharacteristicKind FileType) override { 3456fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner First->FileSkipped(ParentFile, FilenameTok, FileType); 3466fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner Second->FileSkipped(ParentFile, FilenameTok, FileType); 3476fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner } 3486fbe3ebeaef08665a37423f8425314c90b8b5bcfChris Lattner 349651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool FileNotFound(StringRef FileName, 350651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SmallVectorImpl<char> &RecoveryPath) override { 3511c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor return First->FileNotFound(FileName, RecoveryPath) || 3521c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor Second->FileNotFound(FileName, RecoveryPath); 3531c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor } 3541c2e9332fa69727425a3a2b912e36e2ab62083f8Douglas Gregor 355651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok, 356651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines StringRef FileName, bool IsAngled, 357651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CharSourceRange FilenameRange, const FileEntry *File, 358651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines StringRef SearchPath, StringRef RelativePath, 359651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const Module *Imported) override { 360da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis First->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, 361f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis FilenameRange, File, SearchPath, RelativePath, 362f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis Imported); 363da313592441db36cf4b06be97c4bcc238ee6fa9cArgyrios Kyrtzidis Second->InclusionDirective(HashLoc, IncludeTok, FileName, IsAngled, 364f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis FilenameRange, File, SearchPath, RelativePath, 365f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis Imported); 366f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis } 367f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis 368651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void moduleImport(SourceLocation ImportLoc, ModuleIdPath Path, 369651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const Module *Imported) override { 370f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis First->moduleImport(ImportLoc, Path, Imported); 371f8afcffe6a0213760b64c211812b1750e1e1e967Argyrios Kyrtzidis Second->moduleImport(ImportLoc, Path, Imported); 3729c97ca091200311229ce3cb070f0ed8846687edaDouglas Gregor } 3739c97ca091200311229ce3cb070f0ed8846687edaDouglas Gregor 374651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void EndOfMainFile() override { 375dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar First->EndOfMainFile(); 376dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar Second->EndOfMainFile(); 377dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar } 378dbd8209b33e6c9f151e4913a9c095d64a95439c4Daniel Dunbar 379651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Ident(SourceLocation Loc, const std::string &str) override { 380e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar First->Ident(Loc, str); 381e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar Second->Ident(Loc, str); 382e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 3831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 384651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaComment(SourceLocation Loc, const IdentifierInfo *Kind, 385651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const std::string &Str) override { 386e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar First->PragmaComment(Loc, Kind, Str); 387e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar Second->PragmaComment(Loc, Kind, Str); 388e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 3891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 390651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaDetectMismatch(SourceLocation Loc, const std::string &Name, 391651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const std::string &Value) override { 392a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman First->PragmaDetectMismatch(Loc, Name, Value); 393a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman Second->PragmaDetectMismatch(Loc, Name, Value); 394a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman } 395a7ff62f9443efa3b13a28a1e566d4625b15b8553Aaron Ballman 396651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaMessage(SourceLocation Loc, StringRef Namespace, 397651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines PragmaMessageKind Kind, StringRef Str) override { 398076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs First->PragmaMessage(Loc, Namespace, Kind, Str); 399076eea20b80024fc63bbd71fb019375983680ea6Andy Gibbs Second->PragmaMessage(Loc, Namespace, Kind, Str); 400abfe094ce71c42656dcb84a3bdc3e79cb3c16fc3Chris Lattner } 401abfe094ce71c42656dcb84a3bdc3e79cb3c16fc3Chris Lattner 402651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaDiagnosticPush(SourceLocation Loc, StringRef Namespace) override { 403c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor First->PragmaDiagnosticPush(Loc, Namespace); 404c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor Second->PragmaDiagnosticPush(Loc, Namespace); 405c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor } 406c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 407651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaDiagnosticPop(SourceLocation Loc, StringRef Namespace) override { 408c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor First->PragmaDiagnosticPop(Loc, Namespace); 409c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor Second->PragmaDiagnosticPop(Loc, Namespace); 410c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor } 411c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 412651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaDiagnostic(SourceLocation Loc, StringRef Namespace, 413ef8225444452a1486bd721f3285301fe84643b00Stephen Hines diag::Severity mapping, StringRef Str) override { 414c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor First->PragmaDiagnostic(Loc, Namespace, mapping, Str); 415c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor Second->PragmaDiagnostic(Loc, Namespace, mapping, Str); 416c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor } 417c09ce1224dedc470fce9747e5936ff83cc6762ebDouglas Gregor 418651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaOpenCLExtension(SourceLocation NameLoc, const IdentifierInfo *Name, 419651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceLocation StateLoc, unsigned State) override { 420a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen First->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State); 421a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen Second->PragmaOpenCLExtension(NameLoc, Name, StateLoc, State); 422a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen } 423a0950e83cae5df77c00d02d7f77a166979cd2b8bPekka Jaaskelainen 424651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaWarning(SourceLocation Loc, StringRef WarningSpec, 425651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ArrayRef<int> Ids) override { 4262ee042dee9f7693665e28463955401905474a284Reid Kleckner First->PragmaWarning(Loc, WarningSpec, Ids); 4272ee042dee9f7693665e28463955401905474a284Reid Kleckner Second->PragmaWarning(Loc, WarningSpec, Ids); 4282ee042dee9f7693665e28463955401905474a284Reid Kleckner } 4292ee042dee9f7693665e28463955401905474a284Reid Kleckner 430651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaWarningPush(SourceLocation Loc, int Level) override { 4312ee042dee9f7693665e28463955401905474a284Reid Kleckner First->PragmaWarningPush(Loc, Level); 4322ee042dee9f7693665e28463955401905474a284Reid Kleckner Second->PragmaWarningPush(Loc, Level); 4332ee042dee9f7693665e28463955401905474a284Reid Kleckner } 4342ee042dee9f7693665e28463955401905474a284Reid Kleckner 435651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void PragmaWarningPop(SourceLocation Loc) override { 4362ee042dee9f7693665e28463955401905474a284Reid Kleckner First->PragmaWarningPop(Loc); 4372ee042dee9f7693665e28463955401905474a284Reid Kleckner Second->PragmaWarningPop(Loc); 4382ee042dee9f7693665e28463955401905474a284Reid Kleckner } 4392ee042dee9f7693665e28463955401905474a284Reid Kleckner 440651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void MacroExpands(const Token &MacroNameTok, const MacroDirective *MD, 441651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceRange Range, const MacroArgs *Args) override { 442dd08a0c178329ec16cb9e494e6880f3991708b93Argyrios Kyrtzidis First->MacroExpands(MacroNameTok, MD, Range, Args); 443dd08a0c178329ec16cb9e494e6880f3991708b93Argyrios Kyrtzidis Second->MacroExpands(MacroNameTok, MD, Range, Args); 444e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 4451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 446651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void MacroDefined(const Token &MacroNameTok, const MacroDirective *MD) override { 447c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis First->MacroDefined(MacroNameTok, MD); 448c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis Second->MacroDefined(MacroNameTok, MD); 449e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 450e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar 451651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void MacroUndefined(const Token &MacroNameTok, 452651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const MacroDirective *MD) override { 453c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis First->MacroUndefined(MacroNameTok, MD); 454c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis Second->MacroUndefined(MacroNameTok, MD); 455e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar } 45608985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 457651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Defined(const Token &MacroNameTok, const MacroDirective *MD, 458651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines SourceRange Range) override { 4596fb63ab0c74bb777772a3c3ecec09799e275599aJohn Thompson First->Defined(MacroNameTok, MD, Range); 4606fb63ab0c74bb777772a3c3ecec09799e275599aJohn Thompson Second->Defined(MacroNameTok, MD, Range); 4613d5f955855cab5a831cc6b9339dc77a7d46f1a30Douglas Gregor } 4623d5f955855cab5a831cc6b9339dc77a7d46f1a30Douglas Gregor 463651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void SourceRangeSkipped(SourceRange Range) override { 4646b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis First->SourceRangeSkipped(Range); 4656b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis Second->SourceRangeSkipped(Range); 4666b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis } 4676b4ff04dd22e7159887ea6c1bb8b1c01fc9c70a9Argyrios Kyrtzidis 46827289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#if is seen. 469651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void If(SourceLocation Loc, SourceRange ConditionRange, 470651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ConditionValueKind ConditionValue) override { 4716a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson First->If(Loc, ConditionRange, ConditionValue); 4726a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson Second->If(Loc, ConditionRange, ConditionValue); 47308985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 47408985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 4756a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson /// \brief Hook called whenever an \#elif is seen. 476651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Elif(SourceLocation Loc, SourceRange ConditionRange, 477651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines ConditionValueKind ConditionValue, SourceLocation IfLoc) override { 4786a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson First->Elif(Loc, ConditionRange, ConditionValue, IfLoc); 4796a04b5e8c4f15c724b8b89a9c0ea702586ad1852John Thompson Second->Elif(Loc, ConditionRange, ConditionValue, IfLoc); 48008985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 48108985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 48227289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#ifdef is seen. 483651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Ifdef(SourceLocation Loc, const Token &MacroNameTok, 484651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const MacroDirective *MD) override { 485c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis First->Ifdef(Loc, MacroNameTok, MD); 486c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis Second->Ifdef(Loc, MacroNameTok, MD); 48708985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 48808985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 48927289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#ifndef is seen. 490651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Ifndef(SourceLocation Loc, const Token &MacroNameTok, 491651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const MacroDirective *MD) override { 492c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis First->Ifndef(Loc, MacroNameTok, MD); 493c515978bd3a703aa733f846a0094ffa84d149074Argyrios Kyrtzidis Second->Ifndef(Loc, MacroNameTok, MD); 49408985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 49508985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 49627289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#else is seen. 497651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Else(SourceLocation Loc, SourceLocation IfLoc) override { 498bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis First->Else(Loc, IfLoc); 499bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis Second->Else(Loc, IfLoc); 50008985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 50108985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein 50227289b1b8f249bd5bea46b215b5f2e72bbe1c6d4James Dennett /// \brief Hook called whenever an \#endif is seen. 503651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void Endif(SourceLocation Loc, SourceLocation IfLoc) override { 504bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis First->Endif(Loc, IfLoc); 505bb660666883de8b32999c1e5fbe3c32e2cafbdf6Argyrios Kyrtzidis Second->Endif(Loc, IfLoc); 50608985b91e5a87e7731ba24c675f2dc9f9cb645d4Craig Silverstein } 507e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar}; 508e5393fb93eb879d9ebbef102ae9311fa77e023ccDaniel Dunbar 5095f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer} // end namespace clang 5105f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer 5115f016e2cb5d11daeb237544de1c5d59f20fe1a6eReid Spencer#endif 512