[cfe-dev] Pushable #pragma diagnostics

Louis Gerbarg lgerbarg at gmail.com
Mon Jul 6 10:34:48 PDT 2009


Thinking about this a bit more, I think that it would be best to
totally eliminate from the class and make getDiagnostics return the
back() item from the vector.

I also think that supporting setDiagnostics is a difficult interface
to maintain in this situation, but that its only in tree use seems to
be the HTML rewriter saving and maintaining state, which is trivial to
do with the vector in the preprocessor anyway. In other words, I think
that it would make sense to replace:

Diagnostic &getDiagnostics() const { ... }
void setDiagnostics( ... }Diagnostic &D) { ... }

with

Diagnostic &getCurrentDiagnostics() const { ... }
void pushDiagnostics() { ... }
void pushDiagnostics(Diagnostic &D) { ... }
bool popDiagnostics() { ... }

Where the parameterless pushDiagnostics pushes a copy of the current
diagnostics, and the one that takes a parameter allows the caller to
push an explicit Diagnostic. I don't think there are any legitimate
circumstance where it makes sense to replace the entire existing stack
of Diagnostics. This is of course an API change, but in the case of
the HTML rewriter it actually simplifies the code because the caller
no longer has to maintain the state.

Louis




More information about the cfe-dev mailing list