[clang] 42e371b - [NFC][Concepts] Change the Source Range of Concepts ParamMatching

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 26 11:14:45 PST 2023


Author: Erich Keane
Date: 2023-01-26T11:14:40-08:00
New Revision: 42e371b174d4407ec5805010c2ecfef9c086b5c2

URL: https://github.com/llvm/llvm-project/commit/42e371b174d4407ec5805010c2ecfef9c086b5c2
DIFF: https://github.com/llvm/llvm-project/commit/42e371b174d4407ec5805010c2ecfef9c086b5c2.diff

LOG: [NFC][Concepts] Change the Source Range of Concepts ParamMatching

As came up in the discussion on
https://reviews.llvm.org/rG12cb1cb3720de8d164196010123ce1a8901d8122

We were asserting because the attempt to print a note found that our
source range for a immediately declared constraint (as a part of
Parameter Mapping Substitution) wasn't in order.

However, it doesn't really make sense to have the location of this be
the whole list of template arguments, as that would result in the range
being:
bool func(std::thing<char*> auto foo) {}
                     ^^^^^^^^^^^^^^^

Even if done correctly.  Instead, this patch makes the range be just
'foo' in this case (or a pointer right after 'auto' if unnamed).

Added: 
    

Modified: 
    clang/lib/Sema/SemaConcept.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 4d4b2482d046..f163ad294a23 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1132,8 +1132,7 @@ substituteParameterMappings(Sema &S, NormalizedConstraint &N,
   Sema::InstantiatingTemplate Inst(
       S, ArgsAsWritten->arguments().front().getSourceRange().getBegin(),
       Sema::InstantiatingTemplate::ParameterMappingSubstitution{}, Concept,
-      SourceRange(ArgsAsWritten->arguments()[0].getSourceRange().getBegin(),
-                  ArgsAsWritten->arguments().back().getSourceRange().getEnd()));
+      ArgsAsWritten->arguments().front().getSourceRange());
   if (S.SubstTemplateArguments(*Atomic.ParameterMapping, MLTAL, SubstArgs))
     return true;
 


        


More information about the cfe-commits mailing list