void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) { // Read the 'namespace' that the directive is in, e.g. STDC. Do not macro // expand it, the user can have a STDC #define, that should not affect this. PP.LexUnexpandedToken(Tok); // Get the handler for this token. If there is no handler, ignore the pragma. PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false); if (Handler == 0) { PP.Diag(Tok, diag::warn_pragma_ignored); return; } // Otherwise, pass it down. Handler->HandlePragma(PP, Tok); }
/// RemovePragmaHandler - Remove the specific pragma handler from the /// preprocessor. If \arg Namespace is non-null, then it should be the /// namespace that \arg Handler was added to. It is an error to remove /// a handler that has not been registered. void Preprocessor::RemovePragmaHandler(const char *Namespace, PragmaHandler *Handler) { PragmaNamespace *NS = PragmaHandlers; // If this is specified to be in a namespace, step down into it. if (Namespace) { IdentifierInfo *NSID = getIdentifierInfo(Namespace); PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID); assert(Existing && "Namespace containing handler does not exist!"); NS = Existing->getIfNamespace(); assert(NS && "Invalid namespace, registered as a regular pragma handler!"); } NS->RemovePragmaHandler(Handler); // If this is a non-default namespace and it is now empty, remove // it. if (NS != PragmaHandlers && NS->IsEmpty()) PragmaHandlers->RemovePragmaHandler(NS); }
/// RemovePragmaHandler - Remove the specific pragma handler from the /// preprocessor. If \arg Namespace is non-null, then it should be the /// namespace that \arg Handler was added to. It is an error to remove /// a handler that has not been registered. void Preprocessor::RemovePragmaHandler(StringRef Namespace, PragmaHandler *Handler) { PragmaNamespace *NS = PragmaHandlers.get(); // If this is specified to be in a namespace, step down into it. if (!Namespace.empty()) { PragmaHandler *Existing = PragmaHandlers->FindHandler(Namespace); assert(Existing && "Namespace containing handler does not exist!"); NS = Existing->getIfNamespace(); assert(NS && "Invalid namespace, registered as a regular pragma handler!"); } NS->RemovePragmaHandler(Handler); // If this is a non-default namespace and it is now empty, remove it. if (NS != PragmaHandlers.get() && NS->IsEmpty()) { PragmaHandlers->RemovePragmaHandler(NS); delete NS; } }