[PATCH] Support for #pragma detect_mismatch
Aaron Ballman
aaron at aaronballman.com
Wed May 29 12:55:26 PDT 2013
On Wed, May 29, 2013 at 3:31 PM, Reid Kleckner <rnk at google.com> wrote:
> --- include/clang/AST/ASTConsumer.h (revision 182601)
> +++ include/clang/AST/ASTConsumer.h (working copy)
> @@ -92,6 +92,12 @@
> /// only exists to support Microsoft's #pragma comment(linker, "/foo").
> virtual void HandleLinkerOptionPragma(llvm::StringRef Opts) {}
>
> + /// \brief Handle a pragma that emits a mismatch identifier and value to
> the
> + /// object file for the linker to work with. Currently, this only exists
> to
> + /// support Microsoft's #pragma detect_mismatch.
> + virtual void HandleDetectMismatch(llvm::StringRef Name,
> + llvm::StringRef Value) {}
> +
>
> Should we avoid broadening the ASTConsumer interface? If we lowered the
> option in Sema, then we could reuse HandleLinkerOptionPragma() without too
> much fuss. But then we're doing codegen-like work in Sema. I'd like a
> second opinion on this. If we can do this in Sema, we can eliminate a lot
> of the plumbing for this and for #pragma comment(lib).
I had originally done it that way, but wasn't overly keen on it. We
could reuse the TargetInfo behavior for getting the proper linker
options, but it seemed like a layering violation.
> +/// \brief Handle the Microsoft \#pragma detect_mismatch extension.
> +///
> +/// The syntax is:
> +/// \code
> +/// #pragma detect_mismatch("name", "value")
> +/// \endcode
> +/// Where 'name' and 'value' are quoted strings. The values are embedded
> in
> +/// the object file and passed along to the linker. If the linker detects
> a
> +/// mismatch in the object file's values for the given name, a LNK2038
> error
> +/// is emitted. See MSDN for more details.
>
> Seems reasonable to link to MSDN here.
I left it out for consistency, but can add it in easily enough.
Thanks!
~Aaron
More information about the cfe-commits
mailing list