From: Francois Pichet Date: Thu, 28 Apr 2011 04:39:50 +0000 (+0000) Subject: Support &__uuidof(type) as a non type template argument. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a97d24f2ca50f318f62a6cf2a621e7842dd63b4a;p=clang Support &__uuidof(type) as a non type template argument. This idiom is used everywhere in MFC/COM code and as such this patch removes hundreds of errors when parsing MFC code with clang. Example: template class ComTemplate { }; typedef ComTemplate COM_TYPE; Of course this is just parsing support. Trying to use this in CodeGen will generate: error: cannot yet mangle expression type CXXUuidofExpr git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130381 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 3deeedc90d..ae80181d84 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -3093,6 +3093,15 @@ CheckTemplateArgumentAddressOfObjectOrFunction(Sema &S, bool AddressTaken = false; SourceLocation AddrOpLoc; if (UnaryOperator *UnOp = dyn_cast(Arg)) { + + // Support &__uuidof(class_with_uuid) as a non-type template argument. + // Very common in Microsoft COM headers. + if (S.getLangOptions().Microsoft && + isa(UnOp->getSubExpr())) { + Converted = TemplateArgument(ArgIn); + return false; + } + if (UnOp->getOpcode() == UO_AddrOf) { DRE = dyn_cast(UnOp->getSubExpr()); AddressTaken = true; diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index a5d2d513b1..decd57510f 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -95,6 +95,13 @@ void template_uuid() } +template +class COM_CLASS_TEMPLATE { }; + +typedef COM_CLASS_TEMPLATE COM_TYPE_1; +typedef COM_CLASS_TEMPLATE COM_TYPE_2; + + class CtorCall { public: