llvm/clang/test/Templight/templight-default-arg-inst.cpp
Gabor Horvath 207e7b1fa1 [Templight] Template Instantiation Observer
This patch adds a base-class called TemplateInstantiationObserver which gets
notified whenever a template instantiation is entered or exited during
semantic analysis. This is a base class used to implement the template
profiling and debugging tool called
Templight (https://github.com/mikael-s-persson/templight).

The patch also makes a few more changes:

* ActiveTemplateInstantiation class is moved out of the Sema class (so it can be used with inclusion of Sema.h).
* CreateFrontendAction function in front-end utilities is given external linkage (not longer a hidden static function).
* TemplateInstObserverChain data member added to Sema class to hold the list of template-inst observers.
* Notifications to the template-inst observer are added at the key places where templates are instantiated.

Patch by: Abel Sinkovics!

Differential Revision: https://reviews.llvm.org/D5767

llvm-svn: 324808
2018-02-10 14:04:45 +00:00

83 lines
3.3 KiB
C++

// RUN: %clang_cc1 -templight-dump %s 2>&1 | FileCheck %s
template<class T, class U = T>
class A {};
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A::U'$}}
// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:2:25'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:1'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A::U'$}}
// CHECK: {{^kind:[ ]+DefaultTemplateArgumentInstantiation$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:2:25'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:1'$}}
//
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A::U'$}}
// CHECK: {{^kind:[ ]+DefaultTemplateArgumentChecking$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:2:25'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:6'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A::U'$}}
// CHECK: {{^kind:[ ]+DefaultTemplateArgumentChecking$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:2:25'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:6'$}}
//
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
//
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+TemplateInstantiation$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
//
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+Memoization$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+Memoization$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
//
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+Memoization$}}
// CHECK: {{^event:[ ]+Begin$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
// CHECK-LABEL: {{^---$}}
// CHECK: {{^name:[ ]+'A<int, int>'$}}
// CHECK: {{^kind:[ ]+Memoization$}}
// CHECK: {{^event:[ ]+End$}}
// CHECK: {{^orig:[ ]+'.*templight-default-arg-inst.cpp:3:7'}}
// CHECK: {{^poi:[ ]+'.*templight-default-arg-inst.cpp:82:8'$}}
A<int> a;