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

相关文章

C#数据结构之字符串(string)详解

《C#数据结构之字符串(string)详解》:本文主要介绍C#数据结构之字符串(string),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录转义字符序列字符串的创建字符串的声明null字符串与空字符串重复单字符字符串的构造字符串的属性和常用方法属性常用方法总结摘

关于@RequestParam的主要用法详解

《关于@RequestParam的主要用法详解》:本文主要介绍关于@RequestParam的主要用法,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1. 基本用法2. 默认值3. 可选参数4. 绑定到对象5. 绑定到集合或数组6. 绑定到 Map7. 处理复杂类

Go语言中三种容器类型的数据结构详解

《Go语言中三种容器类型的数据结构详解》在Go语言中,有三种主要的容器类型用于存储和操作集合数据:本文主要介绍三者的使用与区别,感兴趣的小伙伴可以跟随小编一起学习一下... 目录基本概念1. 数组(Array)2. 切片(Slice)3. 映射(Map)对比总结注意事项基本概念在 Go 语言中,有三种主要

Linux编译器--gcc/g++使用方式

《Linux编译器--gcc/g++使用方式》文章主要介绍了C/C++程序的编译过程,包括预编译、编译、汇编和链接四个阶段,并详细解释了每个阶段的作用和具体操作,同时,还介绍了调试和发布版本的概念... 目录一、预编译指令1.1预处理功能1.2指令1.3问题扩展二、编译(生成汇编)三、汇编(生成二进制机器语

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

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

分布式系统的主要考虑

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