clang 22.0.0git
TrapReasonBuilder.cpp
Go to the documentation of this file.
1/===----------------------------------------------------------------------===/
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/ \file
10/ This file implements TrapReasonBuilder and related classes.
11/
12/===----------------------------------------------------------------------===/
13#include "TrapReasonBuilder.h"
14
15namespace clang {
16namespace CodeGen {
17
19 unsigned DiagID, TrapReason &TR)
20 : DiagnosticBuilder(DiagObj, SourceLocation(), DiagID), TR(TR) {
21 assert(DiagObj->getDiagnosticIDs()->isTrapDiag(DiagID));
22}
23
25 / Store the trap message and category into the TrapReason object.
26 getMessage(TR.Message);
27 TR.Category = getCategory();
28
29 / Make sure that when `DiagnosticBuilder::~DiagnosticBuilder()`
30 / calls `Emit()` that it does nothing.
31 Clear();
32}
33
34void TrapReasonBuilder::getMessage(SmallVectorImpl<char> &Storage) {
35 / Render the Diagnostic
36 Diagnostic Info(getDiagnosticsEngine(), *this);
37 Info.FormatDiagnostic(Storage);
38}
39
40StringRef TrapReasonBuilder::getCategory() {
41 auto CategoryID =
42 getDiagnosticsEngine()->getDiagnosticIDs()->getCategoryNumberForDiag(
43 getDiagID());
44 if (CategoryID == 0)
45 return "";
46 return getDiagnosticsEngine()->getDiagnosticIDs()->getCategoryNameFromID(
47 CategoryID);
48}
49} / namespace CodeGen
50} / namespace clang
This file contains the declaration of TrapReasonBuilder and related classes.
TrapReasonBuilder(DiagnosticsEngine *DiagObj, unsigned DiagID, TrapReason &TR)
void Clear() const
Clear out the current diagnostic.
DiagnosticsEngine * getDiagnosticsEngine() const
friend class DiagnosticsEngine
unsigned getDiagID() const
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine a...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Definition Diagnostic.h:592
Encodes a location in the source.
The JSON file list parser is used to communicate input to InstallAPI.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant