[PATCH] Pragma optimize on/off

Aaron Ballman aaron at aaronballman.com
Fri May 9 08:02:47 PDT 2014


One minor nit below, otherwise LGTM. I'll let Richard sign off on the
serialization stuff though.

> Index: include/clang/Sema/Sema.h
> ===================================================================
> --- include/clang/Sema/Sema.h (revision 208334)
> +++ include/clang/Sema/Sema.h (working copy)
> @@ -333,6 +333,11 @@
>    /// VisContext - Manages the stack for \#pragma GCC visibility.
>    void *VisContext; // Really a "PragmaVisStack*"
>
> +  /// \brief This represents the last location of a "#pragma clang optimize off"
> +  /// directive if such a directive has not been closed by an "on" yet. If
> +  /// optimizations are currently "on", this is set to an invalid location.
> +  SourceLocation OptimizeOffPragmaLocation;
> +
>    /// \brief Flag indicating if Sema is building a recovery call expression.
>    ///
>    /// This flag is used to avoid building recovery call expressions
> @@ -7228,6 +7233,23 @@
>    /// the appropriate attribute.
>    void AddCFAuditedAttribute(Decl *D);
>
> +  /// \brief Called on well formed \#pragma clang optimize.
> +  void ActOnPragmaOptimize(bool On, SourceLocation PragmaLoc);
> +
> +  /// \brief Get the location for the currently active "\#pragma clang optimize
> +  /// off". If this location is invalid, then the state of the pragma is "on".
> +  SourceLocation getOptimizeOffPragmaLocation();

This function can be const and implemented inline.

~Aaro

On Thu, May 8, 2014 at 12:43 PM, Dario Domizioli
<dario.domizioli at gmail.com> wrote:
> Hello again!
>
> I have now extended the patch with support for serialization of the state of
> the pragma (for PCHs). I have followed a similar pattern to the one used for
> the floating point pragmas and the diagnostic pragmas.
> I have added a PCH test that verifies that if a "#pragma clang optimize off"
> is still active at the end of a PCH then a source file compiled including
> the PCH will behave as if the pragma was specified in the source (as it
> happens with normal headers). The test is modeled after the pragma
> diagnostics test.
>
> I hope the new attached patch covers the issue that was raised by Richard...
> but I welcome any feedback. I might have missed something.
>
> Cheers,
>     Dario Domizioli
>     SN Systems - Sony Computer Entertainment Group
>
>
>
>
>
>
>
>
> On 7 May 2014 18:41, Dario Domizioli <dario.domizioli at gmail.com> wrote:
>>
>>
>> Thanks Aaron!
>>
>>> Patch LGTM, modulo Richard's comments about serialization (I worried
>>> about the same thing, and my preference is for the patch to be
>>> all-inclusive when feasible, but Richard is welcome to weigh in). I
>>> have no strong opinions on whether it should be one diagnostic or two.
>>
>>
>> I will wait for Richard's comments then; meanwhile I'll keep working on
>> the serialization issue.
>>
>> As for the diagnostics, I think that having two might make it easier to
>> extend the "unexpected" case if the pragma gains new functionality in the
>> future, while the "missing" case is unlikely to change... although the
>> %select is quite powerful so I haven't got a strong preference either.
>>
>> Cheers,
>>     Dario Domizioli
>>     SN Systems - Sony Computer Entertainment Group
>>
>>
>



More information about the cfe-commits mailing list