[clang] [clang] Fix crash in concept deprecation (PR #98622)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 11:58:44 PDT 2024


================
@@ -7416,10 +7416,11 @@ NamedDecl *Sema::ActOnVariableDeclarator(
     tryToFixVariablyModifiedVarType(TInfo, R, D.getIdentifierLoc(),
                                     /*DiagID=*/0);
 
-  if (const AutoType *AutoT = R->getAs<AutoType>())
-    CheckConstrainedAuto(
-        AutoT,
-        TInfo->getTypeLoc().getContainedAutoTypeLoc().getConceptNameLoc());
+  if (const AutoType *AutoT = R->getAs<AutoType>()) {
+    AutoTypeLoc Loc = TInfo->getTypeLoc().getContainedAutoTypeLoc();
----------------
Endilll wrote:

This makes more sense now.

> A TypeLoc is not just a SourceLocation, it's a QualType with source locations.

I though that `QualType` with source locations is `TypeSourceInfo`. If I correctly understand description of `TypeLoc` correctly, `TypeLoc` is trailing data of `TypeSourceInfo`. Is that correct?

> As an aside, if all you need to do is mark the concepts as used, you might as well do that earlier when the AutoType is formed, for example around the calls to ASTContext::getAutoType in SemaType.cpp / ConvertDeclSpecToType.

Calling `DiagnoseUseOfDecl` there seems too early. It triggers on _declaration_ of deprecated concept.

https://github.com/llvm/llvm-project/pull/98622


More information about the cfe-commits mailing list