[clang] Add test for CWG190 "Layout-compatible POD-struct types" (#121668)
[llvm-project.git] / llvm / lib / TableGen / TGTimer.cpp
blobd95bd2e6be9da80af0d8a9fc2bbd2b069cc6ce5c
1 //===- TGTimer.cpp - TableGen Timer implementation --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Implement the tablegen timer class.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/TableGen/TGTimer.h"
14 using namespace llvm;
16 // These functions implement the phase timing facility. Starting a timer
17 // when one is already running stops the running one.
18 void TGTimer::startTimer(StringRef Name) {
19 if (!TimingGroup)
20 return;
21 if (LastTimer && LastTimer->isRunning()) {
22 LastTimer->stopTimer();
23 if (BackendTimer) {
24 LastTimer->clear();
25 BackendTimer = false;
29 LastTimer = std::make_unique<Timer>("", Name, *TimingGroup);
30 LastTimer->startTimer();
33 void TGTimer::stopTimer() {
34 if (!TimingGroup)
35 return;
37 assert(LastTimer && "No phase timer was started");
38 LastTimer->stopTimer();
41 void TGTimer::startBackendTimer(StringRef Name) {
42 if (!TimingGroup)
43 return;
45 startTimer(Name);
46 BackendTimer = true;
49 void TGTimer::stopBackendTimer() {
50 if (!TimingGroup || !BackendTimer)
51 return;
52 stopTimer();
53 BackendTimer = false;