Modify the pragma handlers to accept and use StringRefs instead of IdentifierInfos.

When loading the PCH, IdentifierInfos that are associated with pragmas cause declarations that use these identifiers to be deserialized (e.g. the "clang" pragma causes the "clang" namespace to be loaded).
We can avoid this if we just use StringRefs for the pragmas.

As a bonus, since we don't have to create and pass IdentifierInfos, the pragma interfaces get a bit more simplified.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108237 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Argyrios Kyrtzidis 2010-07-13 09:07:17 +00:00
Родитель de80ec1fa9
Коммит 9b36c3f0de
8 изменённых файлов: 105 добавлений и 117 удалений

Просмотреть файл

@ -14,6 +14,8 @@
#ifndef LLVM_CLANG_PRAGMA_H
#define LLVM_CLANG_PRAGMA_H
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include <cassert>
#include <vector>
@ -33,12 +35,13 @@ namespace clang {
/// we treat "#pragma STDC" and "#pragma GCC" as namespaces that contain other
/// pragmas.
class PragmaHandler {
const IdentifierInfo *Name;
std::string Name;
public:
PragmaHandler(const IdentifierInfo *name) : Name(name) {}
explicit PragmaHandler(llvm::StringRef name) : Name(name) {}
PragmaHandler() {}
virtual ~PragmaHandler();
const IdentifierInfo *getName() const { return Name; }
llvm::StringRef getName() const { return Name; }
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken) = 0;
/// getIfNamespace - If this is a namespace, return it. This is equivalent to
@ -60,25 +63,24 @@ public:
/// are "#pragma GCC", "#pragma STDC", and "#pragma omp", but any namespaces may
/// be (potentially recursively) defined.
class PragmaNamespace : public PragmaHandler {
/// Handlers - This is the list of handlers in this namespace.
/// Handlers - This is a map of the handlers in this namespace with their name
/// as key.
///
std::vector<PragmaHandler*> Handlers;
llvm::StringMap<PragmaHandler*> Handlers;
public:
PragmaNamespace(const IdentifierInfo *Name) : PragmaHandler(Name) {}
explicit PragmaNamespace(llvm::StringRef Name) : PragmaHandler(Name) {}
virtual ~PragmaNamespace();
/// FindHandler - Check to see if there is already a handler for the
/// specified name. If not, return the handler for the null identifier if it
/// specified name. If not, return the handler for the null name if it
/// exists, otherwise return null. If IgnoreNull is true (the default) then
/// the null handler isn't returned on failure to match.
PragmaHandler *FindHandler(const IdentifierInfo *Name,
PragmaHandler *FindHandler(llvm::StringRef Name,
bool IgnoreNull = true) const;
/// AddPragma - Add a pragma to this namespace.
///
void AddPragma(PragmaHandler *Handler) {
Handlers.push_back(Handler);
}
void AddPragma(PragmaHandler *Handler);
/// RemovePragmaHandler - Remove the given handler from the
/// namespace.

Просмотреть файл

@ -340,13 +340,19 @@ public:
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
void AddPragmaHandler(const char *Namespace, PragmaHandler *Handler);
void AddPragmaHandler(llvm::StringRef Namespace, PragmaHandler *Handler);
void AddPragmaHandler(PragmaHandler *Handler) {
AddPragmaHandler(llvm::StringRef(), Handler);
}
/// 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 RemovePragmaHandler(const char *Namespace, PragmaHandler *Handler);
void RemovePragmaHandler(llvm::StringRef Namespace, PragmaHandler *Handler);
void RemovePragmaHandler(PragmaHandler *Handler) {
RemovePragmaHandler(llvm::StringRef(), Handler);
}
/// \brief Add the specified comment handler to the preprocessor.
void AddCommentHandler(CommentHandler *Handler);

Просмотреть файл

@ -159,7 +159,7 @@ void PreprocessOnlyAction::ExecuteAction() {
Preprocessor &PP = getCompilerInstance().getPreprocessor();
// Ignore unknown pragmas.
PP.AddPragmaHandler(0, new EmptyPragmaHandler());
PP.AddPragmaHandler(new EmptyPragmaHandler());
Token Tok;
// Start parsing the specified input file.

Просмотреть файл

@ -391,7 +391,7 @@ struct UnknownPragmaHandler : public PragmaHandler {
PrintPPOutputPPCallbacks *Callbacks;
UnknownPragmaHandler(const char *prefix, PrintPPOutputPPCallbacks *callbacks)
: PragmaHandler(0), Prefix(prefix), Callbacks(callbacks) {}
: Prefix(prefix), Callbacks(callbacks) {}
virtual void HandlePragma(Preprocessor &PP, Token &PragmaTok) {
// Figure out what line we went to and insert the appropriate number of
// newline characters.
@ -475,7 +475,7 @@ static int MacroIDCompare(const void* a, const void* b) {
static void DoPrintMacros(Preprocessor &PP, llvm::raw_ostream *OS) {
// Ignore unknown pragmas.
PP.AddPragmaHandler(0, new EmptyPragmaHandler());
PP.AddPragmaHandler(new EmptyPragmaHandler());
// -dM mode just scans and ignores all tokens in the files, then dumps out
// the macro table at the end.
@ -517,7 +517,7 @@ void clang::DoPrintPreprocessedInput(Preprocessor &PP, llvm::raw_ostream *OS,
PrintPPOutputPPCallbacks *Callbacks =
new PrintPPOutputPPCallbacks(PP, *OS, !Opts.ShowLineMarkers,
Opts.ShowMacros);
PP.AddPragmaHandler(0, new UnknownPragmaHandler("#pragma", Callbacks));
PP.AddPragmaHandler(new UnknownPragmaHandler("#pragma", Callbacks));
PP.AddPragmaHandler("GCC", new UnknownPragmaHandler("#pragma GCC",
Callbacks));

Просмотреть файл

@ -30,7 +30,7 @@ PragmaHandler::~PragmaHandler() {
// EmptyPragmaHandler Implementation.
//===----------------------------------------------------------------------===//
EmptyPragmaHandler::EmptyPragmaHandler() : PragmaHandler(0) {}
EmptyPragmaHandler::EmptyPragmaHandler() {}
void EmptyPragmaHandler::HandlePragma(Preprocessor &PP, Token &FirstToken) {}
@ -40,36 +40,34 @@ void EmptyPragmaHandler::HandlePragma(Preprocessor &PP, Token &FirstToken) {}
PragmaNamespace::~PragmaNamespace() {
for (unsigned i = 0, e = Handlers.size(); i != e; ++i)
delete Handlers[i];
for (llvm::StringMap<PragmaHandler*>::iterator
I = Handlers.begin(), E = Handlers.end(); I != E; ++I)
delete I->second;
}
/// FindHandler - Check to see if there is already a handler for the
/// specified name. If not, return the handler for the null identifier if it
/// exists, otherwise return null. If IgnoreNull is true (the default) then
/// the null handler isn't returned on failure to match.
PragmaHandler *PragmaNamespace::FindHandler(const IdentifierInfo *Name,
PragmaHandler *PragmaNamespace::FindHandler(llvm::StringRef Name,
bool IgnoreNull) const {
PragmaHandler *NullHandler = 0;
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
if (Handlers[i]->getName() == Name)
return Handlers[i];
if (PragmaHandler *Handler = Handlers.lookup(Name))
return Handler;
return IgnoreNull ? 0 : Handlers.lookup(llvm::StringRef());
}
if (Handlers[i]->getName() == 0)
NullHandler = Handlers[i];
}
return IgnoreNull ? 0 : NullHandler;
void PragmaNamespace::AddPragma(PragmaHandler *Handler) {
assert(!Handlers.lookup(Handler->getName()) &&
"A handler with this name is already registered in this namespace");
llvm::StringMapEntry<PragmaHandler *> &Entry =
Handlers.GetOrCreateValue(Handler->getName());
Entry.setValue(Handler);
}
void PragmaNamespace::RemovePragmaHandler(PragmaHandler *Handler) {
for (unsigned i = 0, e = Handlers.size(); i != e; ++i) {
if (Handlers[i] == Handler) {
Handlers[i] = Handlers.back();
Handlers.pop_back();
return;
}
}
assert(0 && "Handler not registered in this namespace");
assert(Handlers.lookup(Handler->getName()) &&
"Handler not registered in this namespace");
Handlers.erase(Handler->getName());
}
void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
@ -78,7 +76,10 @@ void PragmaNamespace::HandlePragma(Preprocessor &PP, Token &Tok) {
PP.LexUnexpandedToken(Tok);
// Get the handler for this token. If there is no handler, ignore the pragma.
PragmaHandler *Handler = FindHandler(Tok.getIdentifierInfo(), false);
PragmaHandler *Handler
= FindHandler(Tok.getIdentifierInfo() ? Tok.getIdentifierInfo()->getName()
: llvm::StringRef(),
/*IgnoreNull=*/false);
if (Handler == 0) {
PP.Diag(Tok, diag::warn_pragma_ignored);
return;
@ -486,25 +487,23 @@ void Preprocessor::HandlePragmaMessage(Token &Tok) {
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
void Preprocessor::AddPragmaHandler(const char *Namespace,
void Preprocessor::AddPragmaHandler(llvm::StringRef Namespace,
PragmaHandler *Handler) {
PragmaNamespace *InsertNS = PragmaHandlers;
// If this is specified to be in a namespace, step down into it.
if (Namespace) {
IdentifierInfo *NSID = getIdentifierInfo(Namespace);
if (!Namespace.empty()) {
// If there is already a pragma handler with the name of this namespace,
// we either have an error (directive with the same name as a namespace) or
// we already have the namespace to insert into.
if (PragmaHandler *Existing = PragmaHandlers->FindHandler(NSID)) {
if (PragmaHandler *Existing = PragmaHandlers->FindHandler(Namespace)) {
InsertNS = Existing->getIfNamespace();
assert(InsertNS != 0 && "Cannot have a pragma namespace and pragma"
" handler with the same name!");
} else {
// Otherwise, this namespace doesn't exist yet, create and insert the
// handler for it.
InsertNS = new PragmaNamespace(NSID);
InsertNS = new PragmaNamespace(Namespace);
PragmaHandlers->AddPragma(InsertNS);
}
}
@ -519,14 +518,13 @@ void Preprocessor::AddPragmaHandler(const char *Namespace,
/// 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,
void Preprocessor::RemovePragmaHandler(llvm::StringRef 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);
if (!Namespace.empty()) {
PragmaHandler *Existing = PragmaHandlers->FindHandler(Namespace);
assert(Existing && "Namespace containing handler does not exist!");
NS = Existing->getIfNamespace();
@ -544,7 +542,7 @@ void Preprocessor::RemovePragmaHandler(const char *Namespace,
namespace {
/// PragmaOnceHandler - "#pragma once" marks the file as atomically included.
struct PragmaOnceHandler : public PragmaHandler {
PragmaOnceHandler(const IdentifierInfo *OnceID) : PragmaHandler(OnceID) {}
PragmaOnceHandler() : PragmaHandler("once") {}
virtual void HandlePragma(Preprocessor &PP, Token &OnceTok) {
PP.CheckEndOfDirective("pragma once");
PP.HandlePragmaOnce(OnceTok);
@ -554,7 +552,7 @@ struct PragmaOnceHandler : public PragmaHandler {
/// PragmaMarkHandler - "#pragma mark ..." is ignored by the compiler, and the
/// rest of the line is not lexed.
struct PragmaMarkHandler : public PragmaHandler {
PragmaMarkHandler(const IdentifierInfo *MarkID) : PragmaHandler(MarkID) {}
PragmaMarkHandler() : PragmaHandler("mark") {}
virtual void HandlePragma(Preprocessor &PP, Token &MarkTok) {
PP.HandlePragmaMark();
}
@ -562,7 +560,7 @@ struct PragmaMarkHandler : public PragmaHandler {
/// PragmaPoisonHandler - "#pragma poison x" marks x as not usable.
struct PragmaPoisonHandler : public PragmaHandler {
PragmaPoisonHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaPoisonHandler() : PragmaHandler("poison") {}
virtual void HandlePragma(Preprocessor &PP, Token &PoisonTok) {
PP.HandlePragmaPoison(PoisonTok);
}
@ -571,14 +569,14 @@ struct PragmaPoisonHandler : public PragmaHandler {
/// PragmaSystemHeaderHandler - "#pragma system_header" marks the current file
/// as a system header, which silences warnings in it.
struct PragmaSystemHeaderHandler : public PragmaHandler {
PragmaSystemHeaderHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaSystemHeaderHandler() : PragmaHandler("system_header") {}
virtual void HandlePragma(Preprocessor &PP, Token &SHToken) {
PP.HandlePragmaSystemHeader(SHToken);
PP.CheckEndOfDirective("pragma");
}
};
struct PragmaDependencyHandler : public PragmaHandler {
PragmaDependencyHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaDependencyHandler() : PragmaHandler("dependency") {}
virtual void HandlePragma(Preprocessor &PP, Token &DepToken) {
PP.HandlePragmaDependency(DepToken);
}
@ -592,9 +590,9 @@ struct PragmaDiagnosticHandler : public PragmaHandler {
private:
const bool ClangMode;
public:
PragmaDiagnosticHandler(const IdentifierInfo *ID,
const bool clangMode) : PragmaHandler(ID),
ClangMode(clangMode) {}
explicit PragmaDiagnosticHandler(const bool clangMode)
: PragmaHandler("diagnostic"), ClangMode(clangMode) {}
virtual void HandlePragma(Preprocessor &PP, Token &DiagToken) {
Token Tok;
PP.LexUnexpandedToken(Tok);
@ -687,7 +685,7 @@ public:
/// PragmaCommentHandler - "#pragma comment ...".
struct PragmaCommentHandler : public PragmaHandler {
PragmaCommentHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaCommentHandler() : PragmaHandler("comment") {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
PP.HandlePragmaComment(CommentTok);
}
@ -695,7 +693,7 @@ struct PragmaCommentHandler : public PragmaHandler {
/// PragmaMessageHandler - "#pragma message("...")".
struct PragmaMessageHandler : public PragmaHandler {
PragmaMessageHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaMessageHandler() : PragmaHandler("message") {}
virtual void HandlePragma(Preprocessor &PP, Token &CommentTok) {
PP.HandlePragmaMessage(CommentTok);
}
@ -737,7 +735,7 @@ static STDCSetting LexOnOffSwitch(Preprocessor &PP) {
/// PragmaSTDC_FP_CONTRACTHandler - "#pragma STDC FP_CONTRACT ...".
struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
PragmaSTDC_FP_CONTRACTHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaSTDC_FP_CONTRACTHandler() : PragmaHandler("FP_CONTRACT") {}
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
// We just ignore the setting of FP_CONTRACT. Since we don't do contractions
// at all, our default is OFF and setting it to ON is an optimization hint
@ -749,7 +747,7 @@ struct PragmaSTDC_FP_CONTRACTHandler : public PragmaHandler {
/// PragmaSTDC_FENV_ACCESSHandler - "#pragma STDC FENV_ACCESS ...".
struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
PragmaSTDC_FENV_ACCESSHandler(const IdentifierInfo *ID) : PragmaHandler(ID) {}
PragmaSTDC_FENV_ACCESSHandler() : PragmaHandler("FENV_ACCESS") {}
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
if (LexOnOffSwitch(PP) == STDC_ON)
PP.Diag(Tok, diag::warn_stdc_fenv_access_not_supported);
@ -758,8 +756,8 @@ struct PragmaSTDC_FENV_ACCESSHandler : public PragmaHandler {
/// PragmaSTDC_CX_LIMITED_RANGEHandler - "#pragma STDC CX_LIMITED_RANGE ...".
struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
PragmaSTDC_CX_LIMITED_RANGEHandler(const IdentifierInfo *ID)
: PragmaHandler(ID) {}
PragmaSTDC_CX_LIMITED_RANGEHandler()
: PragmaHandler("CX_LIMITED_RANGE") {}
virtual void HandlePragma(Preprocessor &PP, Token &Tok) {
LexOnOffSwitch(PP);
}
@ -767,7 +765,7 @@ struct PragmaSTDC_CX_LIMITED_RANGEHandler : public PragmaHandler {
/// PragmaSTDC_UnknownHandler - "#pragma STDC ...".
struct PragmaSTDC_UnknownHandler : public PragmaHandler {
PragmaSTDC_UnknownHandler() : PragmaHandler(0) {}
PragmaSTDC_UnknownHandler() {}
virtual void HandlePragma(Preprocessor &PP, Token &UnknownTok) {
// C99 6.10.6p2, unknown forms are not allowed.
PP.Diag(UnknownTok, diag::ext_stdc_pragma_ignored);
@ -780,40 +778,28 @@ struct PragmaSTDC_UnknownHandler : public PragmaHandler {
/// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
/// #pragma GCC poison/system_header/dependency and #pragma once.
void Preprocessor::RegisterBuiltinPragmas() {
AddPragmaHandler(0, new PragmaOnceHandler(getIdentifierInfo("once")));
AddPragmaHandler(0, new PragmaMarkHandler(getIdentifierInfo("mark")));
AddPragmaHandler(new PragmaOnceHandler());
AddPragmaHandler(new PragmaMarkHandler());
// #pragma GCC ...
AddPragmaHandler("GCC", new PragmaPoisonHandler(getIdentifierInfo("poison")));
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler(
getIdentifierInfo("system_header")));
AddPragmaHandler("GCC", new PragmaDependencyHandler(
getIdentifierInfo("dependency")));
AddPragmaHandler("GCC", new PragmaDiagnosticHandler(
getIdentifierInfo("diagnostic"),
false));
AddPragmaHandler("GCC", new PragmaPoisonHandler());
AddPragmaHandler("GCC", new PragmaSystemHeaderHandler());
AddPragmaHandler("GCC", new PragmaDependencyHandler());
AddPragmaHandler("GCC", new PragmaDiagnosticHandler(false));
// #pragma clang ...
AddPragmaHandler("clang", new PragmaPoisonHandler(
getIdentifierInfo("poison")));
AddPragmaHandler("clang", new PragmaSystemHeaderHandler(
getIdentifierInfo("system_header")));
AddPragmaHandler("clang", new PragmaDependencyHandler(
getIdentifierInfo("dependency")));
AddPragmaHandler("clang", new PragmaDiagnosticHandler(
getIdentifierInfo("diagnostic"),
true));
AddPragmaHandler("clang", new PragmaPoisonHandler());
AddPragmaHandler("clang", new PragmaSystemHeaderHandler());
AddPragmaHandler("clang", new PragmaDependencyHandler());
AddPragmaHandler("clang", new PragmaDiagnosticHandler(true));
AddPragmaHandler("STDC", new PragmaSTDC_FP_CONTRACTHandler(
getIdentifierInfo("FP_CONTRACT")));
AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler(
getIdentifierInfo("FENV_ACCESS")));
AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler(
getIdentifierInfo("CX_LIMITED_RANGE")));
AddPragmaHandler("STDC", new PragmaSTDC_FP_CONTRACTHandler());
AddPragmaHandler("STDC", new PragmaSTDC_FENV_ACCESSHandler());
AddPragmaHandler("STDC", new PragmaSTDC_CX_LIMITED_RANGEHandler());
AddPragmaHandler("STDC", new PragmaSTDC_UnknownHandler());
// MS extensions.
if (Features.Microsoft) {
AddPragmaHandler(0, new PragmaCommentHandler(getIdentifierInfo("comment")));
AddPragmaHandler(0, new PragmaMessageHandler(getIdentifierInfo("message")));
AddPragmaHandler(new PragmaCommentHandler());
AddPragmaHandler(new PragmaMessageHandler());
}
}

Просмотреть файл

@ -87,7 +87,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
(Ident__VA_ARGS__ = getIdentifierInfo("__VA_ARGS__"))->setIsPoisoned();
// Initialize the pragma handlers.
PragmaHandlers = new PragmaNamespace(0);
PragmaHandlers = new PragmaNamespace(llvm::StringRef());
RegisterBuiltinPragmas();
// Initialize builtin macros like __LINE__ and friends.

Просмотреть файл

@ -23,8 +23,8 @@ namespace clang {
class PragmaOptionsHandler : public PragmaHandler {
Action &Actions;
public:
PragmaOptionsHandler(const IdentifierInfo *N, Action &A) : PragmaHandler(N),
Actions(A) {}
explicit PragmaOptionsHandler(Action &A) : PragmaHandler("options"),
Actions(A) {}
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};
@ -32,8 +32,8 @@ public:
class PragmaPackHandler : public PragmaHandler {
Action &Actions;
public:
PragmaPackHandler(const IdentifierInfo *N, Action &A) : PragmaHandler(N),
Actions(A) {}
explicit PragmaPackHandler(Action &A) : PragmaHandler("pack"),
Actions(A) {}
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};
@ -42,8 +42,8 @@ class PragmaUnusedHandler : public PragmaHandler {
Action &Actions;
Parser &parser;
public:
PragmaUnusedHandler(const IdentifierInfo *N, Action &A, Parser& p)
: PragmaHandler(N), Actions(A), parser(p) {}
PragmaUnusedHandler(Action &A, Parser& p)
: PragmaHandler("unused"), Actions(A), parser(p) {}
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};
@ -51,8 +51,8 @@ public:
class PragmaWeakHandler : public PragmaHandler {
Action &Actions;
public:
PragmaWeakHandler(const IdentifierInfo *N, Action &A)
: PragmaHandler(N), Actions(A) {}
explicit PragmaWeakHandler(Action &A)
: PragmaHandler("weak"), Actions(A) {}
virtual void HandlePragma(Preprocessor &PP, Token &FirstToken);
};

Просмотреть файл

@ -33,23 +33,17 @@ Parser::Parser(Preprocessor &pp, Action &actions)
// Add #pragma handlers. These are removed and destroyed in the
// destructor.
OptionsHandler.reset(new
PragmaOptionsHandler(&PP.getIdentifierTable().get("options"),
actions));
PP.AddPragmaHandler(0, OptionsHandler.get());
OptionsHandler.reset(new PragmaOptionsHandler(actions));
PP.AddPragmaHandler(OptionsHandler.get());
PackHandler.reset(new
PragmaPackHandler(&PP.getIdentifierTable().get("pack"), actions));
PP.AddPragmaHandler(0, PackHandler.get());
PackHandler.reset(new PragmaPackHandler(actions));
PP.AddPragmaHandler(PackHandler.get());
UnusedHandler.reset(new
PragmaUnusedHandler(&PP.getIdentifierTable().get("unused"), actions,
*this));
PP.AddPragmaHandler(0, UnusedHandler.get());
UnusedHandler.reset(new PragmaUnusedHandler(actions, *this));
PP.AddPragmaHandler(UnusedHandler.get());
WeakHandler.reset(new
PragmaWeakHandler(&PP.getIdentifierTable().get("weak"), actions));
PP.AddPragmaHandler(0, WeakHandler.get());
WeakHandler.reset(new PragmaWeakHandler(actions));
PP.AddPragmaHandler(WeakHandler.get());
}
/// If a crash happens while the parser is active, print out a line indicating
@ -304,13 +298,13 @@ Parser::~Parser() {
delete ScopeCache[i];
// Remove the pragma handlers we installed.
PP.RemovePragmaHandler(0, OptionsHandler.get());
PP.RemovePragmaHandler(OptionsHandler.get());
OptionsHandler.reset();
PP.RemovePragmaHandler(0, PackHandler.get());
PP.RemovePragmaHandler(PackHandler.get());
PackHandler.reset();
PP.RemovePragmaHandler(0, UnusedHandler.get());
PP.RemovePragmaHandler(UnusedHandler.get());
UnusedHandler.reset();
PP.RemovePragmaHandler(0, WeakHandler.get());
PP.RemovePragmaHandler(WeakHandler.get());
WeakHandler.reset();
}