[PATCH] [ms-cxxabi] Mangle vector types

John McCall rjmccall at apple.com
Mon Mar 25 18:59:53 PDT 2013


On Mar 25, 2013, at 6:25 PM, Reid Kleckner <rnk at google.com> wrote:
> The only vector types a user can pass from MSVC code to clang code are
> the ones from *mmintrin.h, so we only have to match the MSVC mangling
> for these types.  MSVC mangles the __m128 family of types as tag types,
> which we match.  For other vector types, we emit a unique tag type
> mangling that won't match anything produced by MSVC.
> 
> http://llvm-reviews.chandlerc.com/D576
> 
> Files:
>  lib/AST/MicrosoftMangle.cpp
>  test/CodeGenCXX/mangle-ms-vector-types.cpp
> 
> Index: lib/AST/MicrosoftMangle.cpp
> ===================================================================
> --- lib/AST/MicrosoftMangle.cpp
> +++ lib/AST/MicrosoftMangle.cpp
> @@ -1519,12 +1519,45 @@
> 
> void MicrosoftCXXNameMangler::mangleType(const VectorType *T,
>                                          SourceRange Range) {
> -  DiagnosticsEngine &Diags = Context.getDiags();
> -  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
> -    "cannot mangle this vector type yet");
> -  Diags.Report(Range.getBegin(), DiagID)
> -    << Range;
> +  if (!T->getElementType()->isBuiltinType()) {

You do a getAs<BuiltinType>() right below this;  just do that and check for null.

> +    DiagnosticsEngine &Diags = Context.getDiags();
> +    unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
> +      "cannot mangle vectors of non-builtin types");
> +    Diags.Report(Range.getBegin(), DiagID)
> +      << Range;
> +  }

You're not testing this diagnostic.  I can tell because you've forgotten to early-exit,
so you'll actually crash if you're not given a BuiltinType. :)

You'll need to put the diagnostic in a separate file that's expected to fail, but
you should be able to put multiple such tests in such a file.

Otherwise this looks fine.

John.



More information about the cfe-commits mailing list