[Clang] Add TimeTraceScope to Sema::CheckConstraintSatisfaction (#170264)

Evaluating concepts can take quite a bit of time and it's not
necessarily obvious what's part of that and what not. This scope makes
it clear which parts are concept evaluation and where they are invoked.
This commit is contained in:
Nikolas Klauser
2025-12-11 15:02:41 +01:00
committed by GitHub
parent 90c340a642
commit ce86d9df1a
2 changed files with 8 additions and 0 deletions

View File

@@ -30,6 +30,7 @@
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/TimeProfiler.h"
using namespace clang;
using namespace sema;
@@ -1182,6 +1183,10 @@ bool Sema::CheckConstraintSatisfaction(
const MultiLevelTemplateArgumentList &TemplateArgsLists,
SourceRange TemplateIDRange, ConstraintSatisfaction &OutSatisfaction,
const ConceptReference *TopLevelConceptId, Expr **ConvertedExpr) {
llvm::TimeTraceScope TimeScope(
"CheckConstraintSatisfaction", [TemplateIDRange, this] {
return TemplateIDRange.printToString(getSourceManager());
});
if (AssociatedConstraints.empty()) {
OutSatisfaction.IsSatisfied = true;
return false;

View File

@@ -272,11 +272,14 @@ TEST(TimeProfilerTest, ClassTemplateInstantiations) {
ASSERT_EQ(R"(
Frontend (test.cc)
| ParseClass (S)
| CheckConstraintSatisfaction (<test.cc:9:21, col:29>)
| InstantiateClass (S<double>, test.cc:9)
| InstantiateFunction (S<double>::foo, test.cc:5)
| ParseDeclarationOrFunctionDefinition (test.cc:11:5)
| | ParseFunctionDefinition (user)
| | | CheckConstraintSatisfaction (<test.cc:12:7, col:12>)
| | | InstantiateClass (S<int>, test.cc:3)
| | | CheckConstraintSatisfaction (<test.cc:13:7, col:14>)
| | | InstantiateClass (S<float>, test.cc:3)
| | | DeferInstantiation (S<float>::foo)
| PerformPendingInstantiations