[llvm-branch-commits] [clang] 66785ff - [𝘀𝗽𝗿] initial version

Justin Bogner via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Nov 3 19:03:07 PDT 2023


Author: Justin Bogner
Date: 2023-11-03T19:03:00-07:00
New Revision: 66785ff779f22a7ae5414961972e6ff36709ad08

URL: https://github.com/llvm/llvm-project/commit/66785ff779f22a7ae5414961972e6ff36709ad08
DIFF: https://github.com/llvm/llvm-project/commit/66785ff779f22a7ae5414961972e6ff36709ad08.diff

LOG: [𝘀𝗽𝗿] initial version

Created using spr 1.3.5

Added: 
    

Modified: 
    clang/lib/Sema/HLSLExternalSemaSource.cpp
    clang/lib/Sema/SemaDecl.cpp
    clang/lib/Sema/SemaDeclCXX.cpp
    clang/lib/Sema/SemaInit.cpp
    clang/lib/Sema/SemaLambda.cpp
    clang/lib/Sema/SemaTemplate.cpp
    clang/lib/Sema/SemaType.cpp
    clang/test/AST/HLSL/RWBuffer-AST.hlsl
    clang/test/AST/HLSL/pch.hlsl
    clang/test/AST/HLSL/pch_with_buf.hlsl
    clang/test/AST/HLSL/resource_binding_attr.hlsl
    clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
    clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 8de144486c91df6..5057bc6629f046a 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -471,7 +471,7 @@ void HLSLExternalSemaSource::forwardDeclareHLSLTypes() {
   CXXRecordDecl *Decl;
   Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
              .addTemplateArgumentList()
-             .addTypeParameter("element_type", SemaPtr->getASTContext().FloatTy)
+             .addTypeParameter("element_type")
              .finalizeTemplateArgs()
              .Record;
   if (!Decl->isCompleteDefinition())

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 396566a8f10a9b7..a86c428c9121abf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -5929,7 +5929,7 @@ Sema::GetNameFromUnqualifiedId(const UnqualifiedId &Name) {
       Diag(Name.StartLocation,
            diag::err_deduction_guide_name_not_class_template)
         << (int)getTemplateNameKindForDiagnostics(TN) << TN;
-      if (Template)
+      if (Template && Template->getLocation().isValid())
         Diag(Template->getLocation(), diag::note_template_decl_here);
       return DeclarationNameInfo();
     }

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 397b7a00e453126..de5cc07f5d42865 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11462,7 +11462,8 @@ bool Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
           GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
     Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
       << GuidedTemplateDecl;
-    Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+    if (GuidedTemplateDecl->getLocation().isValid())
+      Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
   }
 
   auto &DS = D.getMutableDeclSpec();

diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index ed02d3580f34f9a..0952b065d56b58e 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -10575,7 +10575,8 @@ QualType Sema::DeduceTemplateSpecializationFromInitializer(
          diag::err_deduced_non_class_template_specialization_type)
       << (int)getTemplateNameKindForDiagnostics(TemplateName) << TemplateName;
     if (auto *TD = TemplateName.getAsTemplateDecl())
-      Diag(TD->getLocation(), diag::note_template_decl_here);
+      if (TD->getLocation().isValid())
+        Diag(TD->getLocation(), diag::note_template_decl_here);
     return QualType();
   }
 

diff  --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index ca09b0481bcac76..603b7465323e237 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1444,7 +1444,8 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro,
       for (const auto &Capture : Intro.Captures) {
         if (Capture.Id == TP->getIdentifier()) {
           Diag(Capture.Loc, diag::err_template_param_shadow) << Capture.Id;
-          Diag(TP->getLocation(), diag::note_template_param_here);
+          if (TP->getLocation().isValid())
+            Diag(TP->getLocation(), diag::note_template_param_here);
         }
       }
     }

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index ee354862212803f..1a6eaa196db09be 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -872,7 +872,7 @@ bool Sema::DiagnoseUninstantiableTemplate(SourceLocation PointOfInstantiation,
       Note = diag::note_explicit_instantiation_here;
     }
   }
-  if (Note) // Diagnostics were emitted.
+  if (Note && Pattern->getLocation().isValid()) // Diagnostics were emitted.
     Diag(Pattern->getLocation(), *Note);
 
   // In general, Instantiation isn't marked invalid to get more than one
@@ -899,7 +899,8 @@ void Sema::DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl) {
   unsigned DiagId = getLangOpts().MSVCCompat ? diag::ext_template_param_shadow
                                              : diag::err_template_param_shadow;
   Diag(Loc, DiagId) << cast<NamedDecl>(PrevDecl)->getDeclName();
-  Diag(PrevDecl->getLocation(), diag::note_template_param_here);
+  if (PrevDecl->getLocation().isValid())
+    Diag(PrevDecl->getLocation(), diag::note_template_param_here);
 }
 
 /// AdjustDeclIfTemplate - If the given decl happens to be a template, reset
@@ -4434,7 +4435,8 @@ static void checkMoreSpecializedThanPrimary(Sema &S, PartialSpecDecl *Partial) {
       << SFINAEArgString;
   }
 
-  S.Diag(Template->getLocation(), diag::note_template_decl_here);
+  if (Template->getLocation().isValid())
+    S.Diag(Template->getLocation(), diag::note_template_decl_here);
   SmallVector<const Expr *, 3> PartialAC, TemplateAC;
   Template->getAssociatedConstraints(TemplateAC);
   Partial->getAssociatedConstraints(PartialAC);
@@ -4910,8 +4912,10 @@ void Sema::diagnoseMissingTemplateArguments(TemplateName Name,
   Diag(Loc, diag::err_template_missing_args)
     << (int)getTemplateNameKindForDiagnostics(Name) << Name;
   if (TemplateDecl *TD = Name.getAsTemplateDecl()) {
-    Diag(TD->getLocation(), diag::note_template_decl_here)
-      << TD->getTemplateParameters()->getSourceRange();
+    if (TD->getLocation().isValid()) {
+      Diag(TD->getLocation(), diag::note_template_decl_here)
+          << TD->getTemplateParameters()->getSourceRange();
+    }
   }
 }
 
@@ -5263,7 +5267,8 @@ bool Sema::CheckTemplateTypeArgument(
                       ? diag::ext_ms_template_type_arg_missing_typename
                       : diag::err_template_arg_must_be_type_suggest)
             << FixItHint::CreateInsertion(Loc, "typename ");
-        Diag(Param->getLocation(), diag::note_template_param_here);
+        if (Param->getLocation().isValid())
+          Diag(Param->getLocation(), diag::note_template_param_here);
 
         // Recover by synthesizing a type using the location information that we
         // already have.
@@ -5292,7 +5297,8 @@ bool Sema::CheckTemplateTypeArgument(
     // is not a type.
     SourceRange SR = AL.getSourceRange();
     Diag(SR.getBegin(), diag::err_template_arg_must_be_type) << SR;
-    Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      Diag(Param->getLocation(), diag::note_template_param_here);
 
     return true;
   }
@@ -5739,7 +5745,8 @@ bool Sema::CheckTemplateArgument(
       Diag(Arg.getLocation(), diag::err_template_arg_must_be_expr)
         << Arg.getSourceRange();
 
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
 
     case TemplateArgument::Type: {
@@ -5759,7 +5766,8 @@ bool Sema::CheckTemplateArgument(
         Diag(SR.getBegin(), diag::err_template_arg_nontype_ambig) << SR << T;
       else
         Diag(SR.getBegin(), diag::err_template_arg_must_be_expr) << SR;
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
 
@@ -5880,8 +5888,9 @@ static bool diagnoseMissingArgument(Sema &S, SourceLocation Loc,
     << /*not enough args*/0
     << (int)S.getTemplateNameKindForDiagnostics(TemplateName(TD))
     << TD;
-  S.Diag(TD->getLocation(), diag::note_template_decl_here)
-    << Params->getSourceRange();
+  if (TD->getLocation().isValid())
+    S.Diag(TD->getLocation(), diag::note_template_decl_here)
+        << Params->getSourceRange();
   return true;
 }
 
@@ -5947,8 +5956,9 @@ bool Sema::CheckTemplateArgumentList(
           << /*not enough args*/0
           << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
           << Template;
-        Diag(Template->getLocation(), diag::note_template_decl_here)
-          << Params->getSourceRange();
+        if (Template->getLocation().isValid())
+          Diag(Template->getLocation(), diag::note_template_decl_here)
+              << Params->getSourceRange();
         return true;
       }
     }
@@ -5980,7 +5990,8 @@ bool Sema::CheckTemplateArgumentList(
              diag::err_template_expansion_into_fixed_list)
           << (isa<ConceptDecl>(Template) ? 1 : 0)
           << NewArgs[ArgIdx].getSourceRange();
-        Diag((*Param)->getLocation(), diag::note_template_param_here);
+        if ((*Param)->getLocation().isValid())
+          Diag((*Param)->getLocation(), diag::note_template_param_here);
         return true;
       }
 
@@ -6176,8 +6187,9 @@ bool Sema::CheckTemplateArgumentList(
         << (int)getTemplateNameKindForDiagnostics(TemplateName(Template))
         << Template
         << SourceRange(NewArgs[ArgIdx].getLocation(), NewArgs.getRAngleLoc());
-    Diag(Template->getLocation(), diag::note_template_decl_here)
-        << Params->getSourceRange();
+    if (Template->getLocation().isValid())
+      Diag(Template->getLocation(), diag::note_template_decl_here)
+          << Params->getSourceRange();
     return true;
   }
 
@@ -6589,7 +6601,8 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
     for (unsigned I = 0, N = Notes.size(); I != N; ++I)
       S.Diag(Notes[I].first, Notes[I].second);
 
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return NPV_Error;
   }
 
@@ -6615,7 +6628,8 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
     // then recover as if the types were correct.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_wrongtype_null_constant)
       << Arg->getType() << ParamType << Arg->getSourceRange();
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return NPV_NullPointer;
   }
 
@@ -6625,7 +6639,8 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
     // message with the information we have here.
     S.Diag(Arg->getExprLoc(), diag::err_template_arg_invalid)
       << EvalResult.Val.getAsString(S.Context, ParamType);
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return NPV_Error;
   }
 
@@ -6637,7 +6652,8 @@ isNullPointerValueTemplateArgument(Sema &S, NonTypeTemplateParmDecl *Param,
         << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), Code)
         << FixItHint::CreateInsertion(S.getLocForEndOfToken(Arg->getEndLoc()),
                                       ")");
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return NPV_NullPointer;
   }
 
@@ -6678,7 +6694,8 @@ static bool CheckTemplateArgumentIsCompatibleWithParameter(
           S.Diag(Arg->getBeginLoc(),
                  diag::err_template_arg_ref_bind_ignores_quals)
               << ParamType << Arg->getType() << Arg->getSourceRange();
-          S.Diag(Param->getLocation(), diag::note_template_param_here);
+          if (Param->getLocation().isValid())
+            S.Diag(Param->getLocation(), diag::note_template_param_here);
           return true;
         }
       }
@@ -6696,7 +6713,8 @@ static bool CheckTemplateArgumentIsCompatibleWithParameter(
       else
         S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_convertible)
             << ArgIn->getType() << ParamType << Arg->getSourceRange();
-      S.Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
   }
@@ -6839,7 +6857,8 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
   if (!Entity) {
     S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_decl_ref)
         << Arg->getSourceRange();
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return true;
   }
 
@@ -6847,7 +6866,8 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
   if (isa<FieldDecl>(Entity) || isa<IndirectFieldDecl>(Entity)) {
     S.Diag(Arg->getBeginLoc(), diag::err_template_arg_field)
         << Entity << Arg->getSourceRange();
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return true;
   }
 
@@ -6856,7 +6876,8 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
     if (!Method->isStatic()) {
       S.Diag(Arg->getBeginLoc(), diag::err_template_arg_method)
           << Method << Arg->getSourceRange();
-      S.Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
   }
@@ -6896,7 +6917,8 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
     if (Var->getType()->isReferenceType()) {
       S.Diag(Arg->getBeginLoc(), diag::err_template_arg_reference_var)
           << Var->getType() << Arg->getSourceRange();
-      S.Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
 
@@ -6917,14 +6939,16 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
                                           ParamType.getNonReferenceType())) {
       S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
         << ParamType;
-      S.Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here);
       return true;
     }
 
     S.Diag(AddrOpLoc, diag::err_template_arg_address_of_non_pointer)
       << ParamType
       << FixItHint::CreateRemoval(AddrOpLoc);
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
 
     ArgType = Entity->getType();
   }
@@ -6946,14 +6970,16 @@ static bool CheckTemplateArgumentAddressOfObjectOrFunction(
       if (!S.Context.hasSameUnqualifiedType(ArgType, ParamType)) {
         S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
           << ParamType;
-        S.Diag(Param->getLocation(), diag::note_template_param_here);
+        if (Param->getLocation().isValid())
+          S.Diag(Param->getLocation(), diag::note_template_param_here);
         return true;
       }
 
       S.Diag(Arg->getBeginLoc(), diag::err_template_arg_not_address_of)
         << ParamType << FixItHint::CreateInsertion(Arg->getBeginLoc(), "&");
 
-      S.Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here);
     }
   }
 
@@ -7069,7 +7095,8 @@ CheckTemplateArgumentPointerToMember(Sema &S, NonTypeTemplateParmDecl *Param,
     // We can't perform this conversion.
     S.Diag(ResultArg->getBeginLoc(), diag::err_template_arg_not_convertible)
         << ResultArg->getType() << ParamType << ResultArg->getSourceRange();
-    S.Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      S.Diag(Param->getLocation(), diag::note_template_param_here);
     return true;
   }
 
@@ -7181,7 +7208,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
              diag::err_non_type_template_parm_type_deduction_failure)
             << Param->getDeclName() << Param->getType() << Arg->getType()
             << Arg->getSourceRange();
-        Diag(Param->getLocation(), diag::note_template_param_here);
+        if (Param->getLocation().isValid())
+          Diag(Param->getLocation(), diag::note_template_param_here);
         return ExprError();
       }
     }
@@ -7191,7 +7219,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     // where the parameter type is deduced.
     ParamType = CheckNonTypeTemplateParameterType(ParamType, Arg->getExprLoc());
     if (ParamType.isNull()) {
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return ExprError();
     }
   }
@@ -7227,7 +7256,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     Diag(StartLoc, diag::err_deduced_non_type_template_arg_type_mismatch)
       << Arg->getType()
       << ParamType.getUnqualifiedType();
-    Diag(Param->getLocation(), diag::note_template_param_here);
+    if (Param->getLocation().isValid())
+      Diag(Param->getLocation(), diag::note_template_param_here);
     return ExprError();
   }
 
@@ -7492,7 +7522,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     if (!ArgType->isIntegralOrEnumerationType()) {
       Diag(Arg->getBeginLoc(), diag::err_template_arg_not_integral_or_enumeral)
           << ArgType << Arg->getSourceRange();
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return ExprError();
     } else if (!Arg->isValueDependent()) {
       class TmplArgICEDiagnoser : public VerifyICEDiagnoser {
@@ -7530,7 +7561,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
       // We can't perform this conversion.
       Diag(Arg->getBeginLoc(), diag::err_template_arg_not_convertible)
           << Arg->getType() << ParamType << Arg->getSourceRange();
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return ExprError();
     }
 
@@ -7576,7 +7608,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
         Diag(Arg->getBeginLoc(), diag::warn_template_arg_negative)
             << toString(OldValue, 10) << toString(Value, 10) << Param->getType()
             << Arg->getSourceRange();
-        Diag(Param->getLocation(), diag::note_template_param_here);
+        if (Param->getLocation().isValid())
+          Diag(Param->getLocation(), diag::note_template_param_here);
       }
 
       // Complain if we overflowed the template parameter's type.
@@ -7591,7 +7624,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
         Diag(Arg->getBeginLoc(), diag::warn_template_arg_too_large)
             << toString(OldValue, 10) << toString(Value, 10) << Param->getType()
             << Arg->getSourceRange();
-        Diag(Param->getLocation(), diag::note_template_param_here);
+        if (Param->getLocation().isValid())
+          Diag(Param->getLocation(), diag::note_template_param_here);
       }
     }
 
@@ -7718,7 +7752,8 @@ ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
     case NPV_NotNullPointer:
       Diag(Arg->getExprLoc(), diag::err_template_arg_not_convertible)
         << Arg->getType() << ParamType;
-      Diag(Param->getLocation(), diag::note_template_param_here);
+      if (Param->getLocation().isValid())
+        Diag(Param->getLocation(), diag::note_template_param_here);
       return ExprError();
 
     case NPV_Error:
@@ -8578,9 +8613,10 @@ static bool CheckNonTypeTemplatePartialSpecializationArgs(
       S.Diag(IsDefaultArgument ? TemplateNameLoc : ArgExpr->getBeginLoc(),
              diag::err_dependent_typed_non_type_arg_in_partial_spec)
           << Param->getType();
-      S.Diag(Param->getLocation(), diag::note_template_param_here)
-        << (IsDefaultArgument ? ParamUseRange : SourceRange())
-        << ParamUseRange;
+      if (Param->getLocation().isValid())
+        S.Diag(Param->getLocation(), diag::note_template_param_here)
+            << (IsDefaultArgument ? ParamUseRange : SourceRange())
+            << ParamUseRange;
       return true;
     }
   }
@@ -11158,7 +11194,8 @@ Sema::CheckTypenameType(ElaboratedTypeKeyword Keyword,
           else
             Diag(IILoc, diag::err_deduced_tst)
               << (int)getTemplateNameKindForDiagnostics(TemplateName(TD));
-          Diag(TD->getLocation(), diag::note_template_decl_here);
+          if (TD->getLocation().isValid())
+            Diag(TD->getLocation(), diag::note_template_decl_here);
           return QualType();
         }
         return Context.getElaboratedType(

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 560feafa1857cb3..746e0ad1b3ed724 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -3792,7 +3792,8 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
         << Kind << Error << (int)SemaRef.getTemplateNameKindForDiagnostics(TN)
         << QualType(Deduced, 0) << AutoRange;
       if (auto *TD = TN.getAsTemplateDecl())
-        SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here);
+        if (TD->getLocation().isValid())
+          SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here);
 
       T = SemaRef.Context.IntTy;
       D.setInvalidType(true);

diff  --git a/clang/test/AST/HLSL/RWBuffer-AST.hlsl b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
index 9dd9244b73eedf3..c1613520a146c8c 100644
--- a/clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -13,8 +13,6 @@
 
 // EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
 // EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
-// EMPTY-NEXT: TemplateArgument type 'float'
-// EMPTY-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
 // EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class RWBuffer
 // EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
 
@@ -33,8 +31,6 @@ RWBuffer<float> Buffer;
 
 // CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
 // CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
-// CHECK-NEXT: TemplateArgument type 'float'
-// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
 // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWBuffer definition
 
 // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

diff  --git a/clang/test/AST/HLSL/pch.hlsl b/clang/test/AST/HLSL/pch.hlsl
index 74254fedf27cb5b..27fae8f499daac7 100644
--- a/clang/test/AST/HLSL/pch.hlsl
+++ b/clang/test/AST/HLSL/pch.hlsl
@@ -6,7 +6,7 @@
 
 // Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
 // CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
-// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer<float>':'hlsl::RWBuffer<>'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer<float>'
 hlsl::RWBuffer<float> Buffer;
 
 float2 bar(float2 a, float2 b) {

diff  --git a/clang/test/AST/HLSL/pch_with_buf.hlsl b/clang/test/AST/HLSL/pch_with_buf.hlsl
index 4e657606cbcb124..e8eae533af62940 100644
--- a/clang/test/AST/HLSL/pch_with_buf.hlsl
+++ b/clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -5,9 +5,9 @@
 // Make sure PCH works by using function declared in PCH header.
 // CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
 // Make sure buffer defined in PCH works.
-// CHECK:VarDecl 0x{{[0-9a-f]+}} <line:6:1, col:17> col:17 imported Buf 'RWBuffer<float>':'hlsl::RWBuffer<>'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <line:6:1, col:17> col:17 imported Buf 'RWBuffer<float>'
 // Make sure declare a RWBuffer in current file works.
-// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer<float>':'hlsl::RWBuffer<>'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer<float>'
 hlsl::RWBuffer<float> Buf2;
 
 float2 bar(float2 a, float2 b) {

diff  --git a/clang/test/AST/HLSL/resource_binding_attr.hlsl b/clang/test/AST/HLSL/resource_binding_attr.hlsl
index 6836071971111ea..71900f2dbda5503 100644
--- a/clang/test/AST/HLSL/resource_binding_attr.hlsl
+++ b/clang/test/AST/HLSL/resource_binding_attr.hlsl
@@ -23,15 +23,15 @@ float foo() {
   return a + b;
 }
 
-// CHECK: VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV 'RWBuffer<float>':'hlsl::RWBuffer<>' callinit
-// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:17> 'RWBuffer<float>':'hlsl::RWBuffer<>' 'void ()'
+// CHECK: VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV 'RWBuffer<float>':'hlsl::RWBuffer<float>' callinit
+// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:17> 'RWBuffer<float>':'hlsl::RWBuffer<float>' 'void ()'
 // CHECK-NEXT:-HLSLResourceBindingAttr 0x{{[0-9a-f]+}} <col:23> "u3" "space0"
 RWBuffer<float> UAV : register(u3);
 
-// CHECK: -VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV1 'RWBuffer<float>':'hlsl::RWBuffer<>' callinit
-// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:17> 'RWBuffer<float>':'hlsl::RWBuffer<>' 'void ()'
+// CHECK: -VarDecl 0x{{[0-9a-f]+}} <{{.*}}> col:17 UAV1 'RWBuffer<float>':'hlsl::RWBuffer<float>' callinit
+// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:17> 'RWBuffer<float>':'hlsl::RWBuffer<float>' 'void ()'
 // CHECK-NEXT:-HLSLResourceBindingAttr 0x{{[0-9a-f]+}} <col:24> "u2" "space0"
-// CHECK-NEXT:-VarDecl 0x{{[0-9a-f]+}} <col:1, col:38> col:38 UAV2 'RWBuffer<float>':'hlsl::RWBuffer<>' callinit
-// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:38> 'RWBuffer<float>':'hlsl::RWBuffer<>' 'void ()'
+// CHECK-NEXT:-VarDecl 0x{{[0-9a-f]+}} <col:1, col:38> col:38 UAV2 'RWBuffer<float>':'hlsl::RWBuffer<float>' callinit
+// CHECK-NEXT:-CXXConstructExpr 0x{{[0-9a-f]+}} <col:38> 'RWBuffer<float>':'hlsl::RWBuffer<float>' 'void ()'
 // CHECK-NEXT:-HLSLResourceBindingAttr 0x{{[0-9a-f]+}} <col:45> "u4" "space0"
 RWBuffer<float> UAV1 : register(u2), UAV2 : register(u4);

diff  --git a/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl b/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
index a9f6567aa00b8c3..695dc89662e4e31 100644
--- a/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
@@ -5,6 +5,11 @@ typedef vector<float, 3> float3;
 
 RWBuffer<float3> Buffer;
 
+// expected-error at +1 {{class template 'RWBuffer' requires template arguments}}
+RWBuffer BufferErr1;
+// expected-error at +1 {{too few template arguments for class template 'RWBuffer'}}
+RWBuffer<> BufferErr2;
+
 [numthreads(1,1,1)]
 void main() {
   (void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer<float __attribute__((ext_vector_type(3)))>'}}

diff  --git a/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl b/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl
index d2598a57400b045..5d8842b24c91cd0 100644
--- a/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl
+++ b/clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl
@@ -4,15 +4,10 @@
 hlsl::vector ShouldWorkSomeday; // expected-error{{use of alias template 'hlsl::vector' requires template arguments}}
 
 hlsl::vector<1> BadVec; // expected-error{{template argument for template type parameter must be a type}}
-// expected-note@*:* {{template is declared here}}
-// expected-note@*:* {{template parameter is declared here}}
-
 
 hlsl::vector<int, float> AnotherBadVec; // expected-error{{template argument for non-type template parameter must be an expression}}
-// expected-note@*:* {{template parameter is declared here}}
 
 hlsl::vector<int, 2, 3> YABV; // expected-error{{too many template arguments for alias template 'vector'}}
-// expected-note@*:* {{template is declared here}}
 
 // This code is rejected by clang because clang puts the HLSL built-in types
 // into the HLSL namespace.


        


More information about the llvm-branch-commits mailing list