GCC主要数据结构之diagnostic_context

2024-02-17 14:08

本文主要是介绍GCC主要数据结构之diagnostic_context,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

GCC:gcc/diagnostic.h
这是一个用于描述对源程序进行诊断控制的结构,一般每种语言对应一个这种结构对象。
相关全局对象定义如下:
/* A diagnostic_context surrogate for stderr.  */
static diagnostic_context global_diagnostic_context;
diagnostic_context *global_dc = &global_diagnostic_context;
当然,对诊断对象初始化的是函数diagnostic_initialize().
 
先看相关结构定义:

/*  Forward declarations.  */ typedef void (*diagnostic_starter_fn) (diagnostic_context *,diagnostic_info *);

typedef void (*diagnostic_start_span_fn) (diagnostic_context *,expanded_location);

typedef diagnostic_starter_fn diagnostic_finalizer_fn;

 

/* This data structure bundles altogether any information relevant tothe context of a diagnostic message.  */ struct diagnostic_context {/* Where most of the diagnostic formatting work is done.  */   pretty_printer *printer;

  /* The number of times we have issued diagnostics.  */   int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];

  /* True if it has been requested that warnings be treated as errors.  */   bool warning_as_error_requested;

  /* The number of option indexes that can be passed to warning() etal.  */int n_opts;

  /* For each option index that can be passed to warning() et al(OPT_* from options.h when using this code with the core GCCoptions), this array may contain a new kind that the diagnosticshould be changed to before reporting, or DK_UNSPECIFIED to leaveit as the reported kind, or DK_IGNORED to not report it atall.  */diagnostic_t *classify_diagnostic;

  /* History of all changes to the classifications above.  This listis stored in location-order, so we can search it, eitherbinary-wise or end-to-front, to find the most recentclassification for a given diagnostic, given the location of thediagnostic.  */diagnostic_classification_change_t *classification_history;

  /* The size of the above array.  */int n_classification_history;

  /* For pragma push/pop.  */int *push_list;int n_push;

  /* True if we should print the source line with a caret indicatingthe location.  */bool show_caret;

  /* Maximum width of the source line printed.  */int caret_max_width;

  /* Character used for caret diagnostics.  */char caret_chars[rich_location::MAX_RANGES];

  /* True if we should print the command line option which controlseach diagnostic, if known.  */bool show_option_requested;

  /* True if we should raise a SIGABRT on errors.  */bool abort_on_error;

  /* True if we should show the column number on diagnostics.  */bool show_column;

  /* True if pedwarns are errors.  */bool pedantic_errors;

  /* True if permerrors are warnings.  */bool permissive;

  /* The index of the option to associate with turning permerrors intowarnings.  */int opt_permissive;

  /* True if errors are fatal.  */bool fatal_errors;

  /* True if all warnings should be disabled.  */bool dc_inhibit_warnings;

  /* True if warnings should be given in system headers.  */bool dc_warn_system_headers;

  /* Maximum number of errors to report.  */unsigned int max_errors;

  /* This function is called before any message is printed out.  It isresponsible for preparing message prefix and such.  For example, itmight say:In file included from "/usr/local/include/curses.h:5:from "/home/gdr/src/nifty_printer.h:56:...*/diagnostic_starter_fn begin_diagnostic;

  /* This function is called by diagnostic_show_locus in betweendisjoint spans of source code, so that the context can printsomething to indicate that a new span of source code has begun.  */diagnostic_start_span_fn start_span;

  /* This function is called after the diagnostic message is printed.  */diagnostic_finalizer_fn end_diagnostic;

  /* Client hook to report an internal error.  */void (*internal_error) (diagnostic_context *, const char *, va_list *);

  /* Client hook to say whether the option controlling a diagnostic isenabled.  Returns nonzero if enabled, zero if disabled.  */int (*option_enabled) (int, void *);

  /* Client information to pass as second argument tooption_enabled.  */void *option_state;

  /* Client hook to return the name of an option that controls adiagnostic.  Returns malloced memory.  The first diagnostic_targument is the kind of diagnostic before any reclassification(of warnings as errors, etc.); the second is the kind after anyreclassification.  May return NULL if no name is to be printed.May be passed 0 as well as the index of a particular option.  */char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t);

  /* Auxiliary data for client.  */void *x_data;

  /* Used to detect that the last caret was printed at the same location.  */location_t last_location;

  /* Used to detect when the input file stack has changed since lastdescribed.  */const struct line_map *last_module;

  int lock;

  bool inhibit_notes_p;

  /* When printing source code, should the characters at carets and rangesbe colorized? (assuming colorization is on at all).This should be true for frontends that generate range information(so that the ranges of code are colorized),and false for frontends that merely specify points within thesource code (to avoid e.g. colorizing just the first character ina token, which would look strange).  */bool colorize_source_p; };

general_init-> diagnostic_initialize

 

这篇关于GCC主要数据结构之diagnostic_context的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/718010

相关文章

便携式气象仪器的主要特点

TH-BQX9】便携式气象仪器,也称为便携式气象仪或便携式自动气象站,是一款高度集成、低功耗、可快速安装、便于野外监测使用的高精度自动气象观测设备。以下是关于便携式气象仪器的详细介绍:   主要特点   高精度与多功能:便携式气象仪器能够采集多种气象参数,包括但不限于风速、风向、温度、湿度、气压等,部分高级型号还能监测雨量和辐射等。数据采集与存储:配备微电脑气象数据采集仪,具有实时时钟、数据存

【数据结构】——原来排序算法搞懂这些就行,轻松拿捏

前言:快速排序的实现最重要的是找基准值,下面让我们来了解如何实现找基准值 基准值的注释:在快排的过程中,每一次我们要取一个元素作为枢纽值,以这个数字来将序列划分为两部分。 在此我们采用三数取中法,也就是取左端、中间、右端三个数,然后进行排序,将中间数作为枢纽值。 快速排序实现主框架: //快速排序 void QuickSort(int* arr, int left, int rig

Kubernetes PodSecurityPolicy:PSP能实现的5种主要安全策略

Kubernetes PodSecurityPolicy:PSP能实现的5种主要安全策略 1. 特权模式限制2. 宿主机资源隔离3. 用户和组管理4. 权限提升控制5. SELinux配置 💖The Begin💖点点关注,收藏不迷路💖 Kubernetes的PodSecurityPolicy(PSP)是一个关键的安全特性,它在Pod创建之前实施安全策略,确保P

6.1.数据结构-c/c++堆详解下篇(堆排序,TopK问题)

上篇:6.1.数据结构-c/c++模拟实现堆上篇(向下,上调整算法,建堆,增删数据)-CSDN博客 本章重点 1.使用堆来完成堆排序 2.使用堆解决TopK问题 目录 一.堆排序 1.1 思路 1.2 代码 1.3 简单测试 二.TopK问题 2.1 思路(求最小): 2.2 C语言代码(手写堆) 2.3 C++代码(使用优先级队列 priority_queue)

《数据结构(C语言版)第二版》第八章-排序(8.3-交换排序、8.4-选择排序)

8.3 交换排序 8.3.1 冒泡排序 【算法特点】 (1) 稳定排序。 (2) 可用于链式存储结构。 (3) 移动记录次数较多,算法平均时间性能比直接插入排序差。当初始记录无序,n较大时, 此算法不宜采用。 #include <stdio.h>#include <stdlib.h>#define MAXSIZE 26typedef int KeyType;typedef char In

分布式系统的主要考虑

异构性:分布式系统由于基于不同的网路、操作系统、计算机硬件和编程语言来构造,必须要考虑一种通用的网络通讯协议来屏蔽异构系统之间的禅意。一般交由中间件来处理这些差异。缺乏全球时钟:在程序需要协作时,它们通过交换消息来协调它们的动作。紧密的协调经常依赖于对程序动作发生时间的共识,但是,实际上网络上计算机同步时钟的准确性受到极大的限制,即没有一个正确时间的全局概念。这是通过网络发送消息作为唯一的通信方式

【408数据结构】散列 (哈希)知识点集合复习考点题目

苏泽  “弃工从研”的路上很孤独,于是我记下了些许笔记相伴,希望能够帮助到大家    知识点 1. 散列查找 散列查找是一种高效的查找方法,它通过散列函数将关键字映射到数组的一个位置,从而实现快速查找。这种方法的时间复杂度平均为(

浙大数据结构:树的定义与操作

四种遍历 #include<iostream>#include<queue>using namespace std;typedef struct treenode *BinTree;typedef BinTree position;typedef int ElementType;struct treenode{ElementType data;BinTree left;BinTre

Python 内置的一些数据结构

文章目录 1. 列表 (List)2. 元组 (Tuple)3. 字典 (Dictionary)4. 集合 (Set)5. 字符串 (String) Python 提供了几种内置的数据结构来存储和操作数据,每种都有其独特的特点和用途。下面是一些常用的数据结构及其简要说明: 1. 列表 (List) 列表是一种可变的有序集合,可以存放任意类型的数据。列表中的元素可以通过索

浙大数据结构:04-树7 二叉搜索树的操作集

这道题答案都在PPT上,所以先学会再写的话并不难。 1、BinTree Insert( BinTree BST, ElementType X ) 递归实现,小就进左子树,大就进右子树。 为空就新建结点插入。 BinTree Insert( BinTree BST, ElementType X ){if(!BST){BST=(BinTree)malloc(sizeof(struct TNo