r332614 - Fix __uuidof handling on non-type template parameter in C++17
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Thu May 17 08:26:37 PDT 2018
Author: nico
Date: Thu May 17 08:26:37 2018
New Revision: 332614
URL: http://llvm.org/viewvc/llvm-project?rev=332614&view=rev
Log:
Fix __uuidof handling on non-type template parameter in C++17
Clang used to pass the base lvalue of a non-type template parameter
to the template instantiation phase when the base part is __uuidof
and it's running in C++17 mode.
However, that drops its LValuePath, and unintentionally transforms
&__uuidof(...) to __uuidof(...).
This CL fixes that by passing whole expr. Fixes PR24986.
https://reviews.llvm.org/D46820?id=146557
Patch from Taiju Tsuiki <tzik at chromium.org>!
Modified:
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/SemaCXX/ms-uuid.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=332614&r1=332613&r2=332614&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Thu May 17 08:26:37 2018
@@ -6245,7 +6245,7 @@ ExprResult Sema::CheckTemplateArgument(N
// -- a predefined __func__ variable
if (auto *E = Value.getLValueBase().dyn_cast<const Expr*>()) {
if (isa<CXXUuidofExpr>(E)) {
- Converted = TemplateArgument(const_cast<Expr*>(E));
+ Converted = TemplateArgument(ArgResult.get());
break;
}
Diag(Arg->getLocStart(), diag::err_template_arg_not_decl_ref)
Modified: cfe/trunk/test/SemaCXX/ms-uuid.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms-uuid.cpp?rev=332614&r1=332613&r2=332614&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/ms-uuid.cpp (original)
+++ cfe/trunk/test/SemaCXX/ms-uuid.cpp Thu May 17 08:26:37 2018
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
+// RUN: %clang_cc1 -fsyntax-only -std=c++17 -verify -fms-extensions %s -Wno-deprecated-declarations
typedef struct _GUID {
unsigned long Data1;
@@ -92,4 +93,16 @@ class __declspec(uuid("000000A0-0000-000
// the previous case).
[uuid("000000A0-0000-0000-C000-000000000049"),
uuid("000000A0-0000-0000-C000-000000000049")] class C10;
+
+template <const GUID* p>
+void F1() {
+ // Regression test for PR24986. The given GUID should just work as a pointer.
+ const GUID* q = p;
+}
+
+void F2() {
+ // The UUID should work for a non-type template parameter.
+ F1<&__uuidof(C1)>();
+}
+
}
More information about the cfe-commits
mailing list