1 //===- llvm/Support/DiagnosticInfo.cpp - Diagnostic Definitions -*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the different classes involved in low level diagnostics.
12 // Diagnostics reporting is still done as part of the LLVMContext.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/ADT/Twine.h"
16 #include "llvm/IR/Constants.h"
17 #include "llvm/IR/DiagnosticInfo.h"
18 #include "llvm/IR/DiagnosticPrinter.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Instruction.h"
21 #include "llvm/IR/Metadata.h"
22 #include "llvm/Support/Atomic.h"
28 int llvm::getNextAvailablePluginDiagnosticKind() {
29 static sys::cas_flag PluginKindID = DK_FirstPluginKind;
30 return (int)sys::AtomicIncrement(&PluginKindID);
33 DiagnosticInfoInlineAsm::DiagnosticInfoInlineAsm(const Instruction &I,
35 DiagnosticSeverity Severity)
36 : DiagnosticInfo(DK_InlineAsm, Severity), LocCookie(0), MsgStr(MsgStr),
38 if (const MDNode *SrcLoc = I.getMetadata("srcloc")) {
39 if (SrcLoc->getNumOperands() != 0)
40 if (const ConstantInt *CI = dyn_cast<ConstantInt>(SrcLoc->getOperand(0)))
41 LocCookie = CI->getZExtValue();
45 void DiagnosticInfoInlineAsm::print(DiagnosticPrinter &DP) const {
48 DP << " at line " << getLocCookie();
51 void DiagnosticInfoStackSize::print(DiagnosticPrinter &DP) const {
52 DP << "stack size limit exceeded (" << getStackSize() << ") in "