Rename "libdiagnostics" to "libgdiagnostics"

"libdiagnostics" clashes with an existing soname in Debian, as
per:
  https://gcc.gnu.org/pipermail/gcc/2024-November/245175.html

Rename it to "libgdiagnostics" for uniqueness.

I am being deliberately vague about what the "g" stands for:
it could be "gnu", "gcc", or "gpl-licensed" as the reader desires.

ChangeLog:
	* configure.ac: Rename "libdiagnostics" to "libgdiagnostics".
	* configure: Regenerate.

gcc/ChangeLog:
	* Makefile.in: Rename "libdiagnostics" to "libgdiagnostics".
	* configure.ac: Likewise.
	* configure: Regenerate.
	* doc/install.texi: Rename "libdiagnostics" to
	"libgdiagnostics".
	* doc/libdiagnostics/*: Rename to doc/libgdiagnostics, renaming
	"libdiagnostics" to "libgdiagnostics" throughout.
	* libdiagnostics++.h: Rename to...
	* libgdiagnostics++.h: ...this, renaming "libdiagnostics" to
	"libgdiagnostics" throughout.
	* libdiagnostics.cc: Rename to...
	* libgdiagnostics.cc: ...this, renaming "libdiagnostics" to
	"libgdiagnostics" throughout.
	* libdiagnostics.h: Rename to...
	* libgdiagnostics.h: ...this, renaming "libdiagnostics" to
	"libgdiagnostics" throughout.
	* libdiagnostics.map: Rename to...
	* libgdiagnostics.map: ...this, renaming "libdiagnostics" to
	"libgdiagnostics" throughout.
	* libsarifreplay.cc: Update for renaming of "libdiagnostics"
	to "libgdiagnostics".
	* libsarifreplay.h: Likewise.
	* sarif-replay.cc: Likewise.

gcc/testsuite/ChangeLog:
	* libdiagnostics.dg/*: Rename to libgdiagnostics.dg, renaming
	"libdiagnostics" to "libgdiagnostics" throughout.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
David Malcolm 2024-11-29 18:13:22 -05:00
parent b02b9e8df6
commit bc3597635a
77 changed files with 453 additions and 451 deletions

33
configure vendored
View file

@ -691,7 +691,7 @@ extra_host_libiberty_configure_flags
stage1_languages
host_libs_picflag
CRAB1_LIBS
enable_libdiagnostics
enable_libgdiagnostics
PICFLAG
host_shared
gcc_host_pie
@ -845,7 +845,7 @@ enable_linker_plugin_configure_flags
enable_linker_plugin_flags
enable_host_pie
enable_host_shared
enable_libdiagnostics
enable_libgdiagnostics
enable_stage1_languages
enable_objc_gc
with_target_bdw_gc
@ -1580,7 +1580,8 @@ Optional Features:
plugins [none]
--enable-host-pie build position independent host executables
--enable-host-shared build host code as shared libraries
--enable-libdiagnostics build libdiagnostics shared library
--enable-libgdiagnostics
build libgdiagnostics shared library
--enable-stage1-languages[=all]
choose additional languages to build during stage1.
Mostly useful for compiler development
@ -9621,19 +9622,19 @@ fi
# Check for libdiagnostics support.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libdiagnostics" >&5
$as_echo_n "checking whether to enable libdiagnostics... " >&6; }
# Check whether --enable-libdiagnostics was given.
if test "${enable_libdiagnostics+set}" = set; then :
enableval=$enable_libdiagnostics; enable_libdiagnostics=$enableval
# Check for libgdiagnostics support.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable libgdiagnostics" >&5
$as_echo_n "checking whether to enable libgdiagnostics... " >&6; }
# Check whether --enable-libgdiagnostics was given.
if test "${enable_libgdiagnostics+set}" = set; then :
enableval=$enable_libgdiagnostics; enable_libgdiagnostics=$enableval
else
enable_libdiagnostics=no
enable_libgdiagnostics=no
fi
if test x$enable_libdiagnostics = xyes; then
# Disable libdiagnostics if -enable-host-shared not specified
if test x$enable_libgdiagnostics = xyes; then
# Disable libgdiagnostics if -enable-host-shared not specified
# but not if building for Mingw. All code in Windows
# is position independent code (PIC).
case $target in
@ -9641,12 +9642,12 @@ if test x$enable_libdiagnostics = xyes; then
*)
if test x$host_shared != xyes; then
as_fn_error $? "
Enabling libdiagnostics requires --enable-host-shared.
Enabling libgdiagnostics requires --enable-host-shared.
--enable-host-shared typically slows the rest of the compiler down by
a few %, so you must explicitly enable it.
If you want to build both libdiagnostics and the regular compiler, it is often
If you want to build both libgdiagnostics and the regular compiler, it is often
best to do this via two separate configure/builds, in separate
directories, to avoid imposing the performance cost of
--enable-host-shared on the regular compiler." "$LINENO" 5
@ -9654,8 +9655,8 @@ directories, to avoid imposing the performance cost of
;;
esac
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_libdiagnostics" >&5
$as_echo "$enable_libdiagnostics" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_libgdiagnostics" >&5
$as_echo "$enable_libgdiagnostics" >&6; }

View file

@ -2058,16 +2058,16 @@ fi
AC_SUBST(PICFLAG)
# Check for libdiagnostics support.
AC_MSG_CHECKING([whether to enable libdiagnostics])
AC_ARG_ENABLE(libdiagnostics,
[AS_HELP_STRING([--enable-libdiagnostics],
[build libdiagnostics shared library])],
enable_libdiagnostics=$enableval,
enable_libdiagnostics=no)
# Check for libgdiagnostics support.
AC_MSG_CHECKING([whether to enable libgdiagnostics])
AC_ARG_ENABLE(libgdiagnostics,
[AS_HELP_STRING([--enable-libgdiagnostics],
[build libgdiagnostics shared library])],
enable_libgdiagnostics=$enableval,
enable_libgdiagnostics=no)
if test x$enable_libdiagnostics = xyes; then
# Disable libdiagnostics if -enable-host-shared not specified
if test x$enable_libgdiagnostics = xyes; then
# Disable libgdiagnostics if -enable-host-shared not specified
# but not if building for Mingw. All code in Windows
# is position independent code (PIC).
case $target in
@ -2075,12 +2075,12 @@ if test x$enable_libdiagnostics = xyes; then
*)
if test x$host_shared != xyes; then
AC_MSG_ERROR([
Enabling libdiagnostics requires --enable-host-shared.
Enabling libgdiagnostics requires --enable-host-shared.
--enable-host-shared typically slows the rest of the compiler down by
a few %, so you must explicitly enable it.
If you want to build both libdiagnostics and the regular compiler, it is often
If you want to build both libgdiagnostics and the regular compiler, it is often
best to do this via two separate configure/builds, in separate
directories, to avoid imposing the performance cost of
--enable-host-shared on the regular compiler.])
@ -2088,8 +2088,8 @@ directories, to avoid imposing the performance cost of
;;
esac
fi
AC_MSG_RESULT($enable_libdiagnostics)
AC_SUBST(enable_libdiagnostics)
AC_MSG_RESULT($enable_libgdiagnostics)
AC_SUBST(enable_libgdiagnostics)
# Rust requires -ldl and -lpthread if you are using an old glibc that does not include them by

View file

@ -436,7 +436,7 @@ endif
enable_host_shared = @enable_host_shared@
enable_libdiagnostics = @enable_libdiagnostics@
enable_libgdiagnostics = @enable_libgdiagnostics@
enable_as_accelerator = @enable_as_accelerator@
@ -620,8 +620,8 @@ xm_include_list=@xm_include_list@
xm_defines=@xm_defines@
lang_checks=
lang_checks_parallelized=
ifeq (@enable_libdiagnostics@,yes)
lang_checks += check-libdiagnostics check-sarif-replay
ifeq (@enable_libgdiagnostics@,yes)
lang_checks += check-libgdiagnostics check-sarif-replay
endif
lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt $(srcdir)/params.opt $(srcdir)/analyzer/analyzer.opt
lang_specs_files=@lang_specs_files@
@ -1888,8 +1888,8 @@ endif
# compilation or not.
ALL_HOST_OBJS = $(ALL_HOST_FRONTEND_OBJS) $(ALL_HOST_BACKEND_OBJS)
ifeq (@enable_libdiagnostics@,yes)
ALL_HOST_OBJS += $(libdiagnostics_OBJS) $(SARIF_REPLAY_OBJS)
ifeq (@enable_libgdiagnostics@,yes)
ALL_HOST_OBJS += $(libgdiagnostics_OBJS) $(SARIF_REPLAY_OBJS)
endif
BACKEND = libbackend.a main.o libcommon-target.a libcommon.a \
@ -2198,7 +2198,7 @@ all.cross: native gcc-cross$(exeext) cpp$(exeext) specs \
libgcc-support lang.all.cross doc selftest @GENINSRC@ srcextra
# This is what must be made before installing GCC and converting libraries.
start.encap: native xgcc$(exeext) cpp$(exeext) specs \
libgcc-support lang.start.encap @LIBDIAGNOSTICS@ @GENINSRC@ srcextra
libgcc-support lang.start.encap @LIBGDIAGNOSTICS@ @GENINSRC@ srcextra
# These can't be made until after GCC can run.
rest.encap: lang.rest.encap
# This is what is made with the host's compiler
@ -2288,133 +2288,133 @@ cpp$(exeext): $(GCC_OBJS) c-family/cppspec.o libcommon-target.a $(LIBDEPS) \
$(EXTRA_GCC_LIBS) $(LIBS)
libdiagnostics_OBJS = libdiagnostics.o \
libgdiagnostics_OBJS = libgdiagnostics.o \
libcommon.a
# libdiagnostics
# libgdiagnostics
LIBDIAGNOSTICS_VERSION_NUM = 0
LIBDIAGNOSTICS_MINOR_NUM = 0
LIBDIAGNOSTICS_RELEASE_NUM = 1
LIBGDIAGNOSTICS_VERSION_NUM = 0
LIBGDIAGNOSTICS_MINOR_NUM = 0
LIBGDIAGNOSTICS_RELEASE_NUM = 1
ifneq (,$(findstring mingw,$(target)))
LIBDIAGNOSTICS_FILENAME = libdiagnostics-$(LIBDIAGNOSTICS_VERSION_NUM).dll
LIBDIAGNOSTICS_IMPORT_LIB = libdiagnostics.dll.a
LIBGDIAGNOSTICS_FILENAME = libgdiagnostics-$(LIBGDIAGNOSTICS_VERSION_NUM).dll
LIBGDIAGNOSTICS_IMPORT_LIB = libgdiagnostics.dll.a
libdiagnostics: $(LIBDIAGNOSTICS_FILENAME)
libgdiagnostics: $(LIBGDIAGNOSTICS_FILENAME)
else
ifneq (,$(findstring darwin,$(host)))
LIBDIAGNOSTICS_AGE = 1
LIBDIAGNOSTICS_BASENAME = libdiagnostics
LIBGDIAGNOSTICS_AGE = 1
LIBGDIAGNOSTICS_BASENAME = libgdiagnostics
LIBDIAGNOSTICS_SONAME = \
${libdir}/$(LIBDIAGNOSTICS_BASENAME).$(LIBDIAGNOSTICS_VERSION_NUM).dylib
LIBDIAGNOSTICS_FILENAME = $(LIBDIAGNOSTICS_BASENAME).$(LIBDIAGNOSTICS_VERSION_NUM).dylib
LIBDIAGNOSTICS_LINKER_NAME = $(LIBDIAGNOSTICS_BASENAME).dylib
LIBGDIAGNOSTICS_SONAME = \
${libdir}/$(LIBGDIAGNOSTICS_BASENAME).$(LIBGDIAGNOSTICS_VERSION_NUM).dylib
LIBGDIAGNOSTICS_FILENAME = $(LIBGDIAGNOSTICS_BASENAME).$(LIBGDIAGNOSTICS_VERSION_NUM).dylib
LIBGDIAGNOSTICS_LINKER_NAME = $(LIBGDIAGNOSTICS_BASENAME).dylib
# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
# LD_SONAME_OPTION depending if configure found them, using $(if)
# We have to define a LIBDIAGNOSTICS_COMMA here, otherwise the commas in the "true"
# We have to define a LIBGDIAGNOSTICS_COMMA here, otherwise the commas in the "true"
# result are treated as separators by the $(if).
LIBDIAGNOSTICS_COMMA := ,
LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION = \
LIBGDIAGNOSTICS_COMMA := ,
LIBGDIAGNOSTICS_VERSION_SCRIPT_OPTION = \
$(if $(LD_VERSION_SCRIPT_OPTION),\
-Wl$(LIBDIAGNOSTICS_COMMA)$(LD_VERSION_SCRIPT_OPTION)$(LIBDIAGNOSTICS_COMMA)$(srcdir)/libdiagnostics.map)
-Wl$(LIBGDIAGNOSTICS_COMMA)$(LD_VERSION_SCRIPT_OPTION)$(LIBGDIAGNOSTICS_COMMA)$(srcdir)/libgdiagnostics.map)
LIBDIAGNOSTICS_SONAME_OPTION = \
LIBGDIAGNOSTICS_SONAME_OPTION = \
$(if $(LD_SONAME_OPTION), \
-Wl$(LIBDIAGNOSTICS_COMMA)$(LD_SONAME_OPTION)$(LIBDIAGNOSTICS_COMMA)$(LIBDIAGNOSTICS_SONAME))
-Wl$(LIBGDIAGNOSTICS_COMMA)$(LD_SONAME_OPTION)$(LIBGDIAGNOSTICS_COMMA)$(LIBGDIAGNOSTICS_SONAME))
LIBDIAGNOSTICS_SONAME_SYMLINK = $(LIBDIAGNOSTICS_FILENAME)
LIBDIAGNOSTICS_LINKER_NAME_SYMLINK = $(LIBDIAGNOSTICS_LINKER_NAME)
LIBGDIAGNOSTICS_SONAME_SYMLINK = $(LIBGDIAGNOSTICS_FILENAME)
LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK = $(LIBGDIAGNOSTICS_LINKER_NAME)
libdiagnostics: $(LIBDIAGNOSTICS_FILENAME) \
$(LIBDIAGNOSTICS_SYMLINK) \
$(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
libgdiagnostics: $(LIBGDIAGNOSTICS_FILENAME) \
$(LIBGDIAGNOSTICS_SYMLINK) \
$(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK)
else
LIBDIAGNOSTICS_LINKER_NAME = libdiagnostics.so
LIBDIAGNOSTICS_SONAME = $(LIBDIAGNOSTICS_LINKER_NAME).$(LIBDIAGNOSTICS_VERSION_NUM)
LIBDIAGNOSTICS_FILENAME = \
$(LIBDIAGNOSTICS_SONAME).$(LIBDIAGNOSTICS_MINOR_NUM).$(LIBDIAGNOSTICS_RELEASE_NUM)
LIBGDIAGNOSTICS_LINKER_NAME = libgdiagnostics.so
LIBGDIAGNOSTICS_SONAME = $(LIBGDIAGNOSTICS_LINKER_NAME).$(LIBGDIAGNOSTICS_VERSION_NUM)
LIBGDIAGNOSTICS_FILENAME = \
$(LIBGDIAGNOSTICS_SONAME).$(LIBGDIAGNOSTICS_MINOR_NUM).$(LIBGDIAGNOSTICS_RELEASE_NUM)
LIBDIAGNOSTICS_LINKER_NAME_SYMLINK = $(LIBDIAGNOSTICS_LINKER_NAME)
LIBDIAGNOSTICS_SONAME_SYMLINK = $(LIBDIAGNOSTICS_SONAME)
LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK = $(LIBGDIAGNOSTICS_LINKER_NAME)
LIBGDIAGNOSTICS_SONAME_SYMLINK = $(LIBGDIAGNOSTICS_SONAME)
# Conditionalize the use of the LD_VERSION_SCRIPT_OPTION and
# LD_SONAME_OPTION depending if configure found them, using $(if)
# We have to define a LIBDIAGNOSTICS_COMMA here, otherwise the commas in the "true"
# We have to define a LIBGDIAGNOSTICS_COMMA here, otherwise the commas in the "true"
# result are treated as separators by the $(if).
LIBDIAGNOSTICS_COMMA := ,
LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION = \
LIBGDIAGNOSTICS_COMMA := ,
LIBGDIAGNOSTICS_VERSION_SCRIPT_OPTION = \
$(if $(LD_VERSION_SCRIPT_OPTION),\
-Wl$(LIBDIAGNOSTICS_COMMA)$(LD_VERSION_SCRIPT_OPTION)$(LIBDIAGNOSTICS_COMMA)$(srcdir)/libdiagnostics.map)
-Wl$(LIBGDIAGNOSTICS_COMMA)$(LD_VERSION_SCRIPT_OPTION)$(LIBGDIAGNOSTICS_COMMA)$(srcdir)/libgdiagnostics.map)
LIBDIAGNOSTICS_SONAME_OPTION = \
LIBGDIAGNOSTICS_SONAME_OPTION = \
$(if $(LD_SONAME_OPTION), \
-Wl$(LIBDIAGNOSTICS_COMMA)$(LD_SONAME_OPTION)$(LIBDIAGNOSTICS_COMMA)$(LIBDIAGNOSTICS_SONAME))
-Wl$(LIBGDIAGNOSTICS_COMMA)$(LD_SONAME_OPTION)$(LIBGDIAGNOSTICS_COMMA)$(LIBGDIAGNOSTICS_SONAME))
libdiagnostics: $(LIBDIAGNOSTICS_FILENAME) \
$(LIBDIAGNOSTICS_SYMLINK) \
$(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
libgdiagnostics: $(LIBGDIAGNOSTICS_FILENAME) \
$(LIBGDIAGNOSTICS_SYMLINK) \
$(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK)
endif
endif
libdiagnostics.serial = $(LIBDIAGNOSTICS_FILENAME)
libgdiagnostics.serial = $(LIBGDIAGNOSTICS_FILENAME)
# Tell GNU make to ignore these if they exist.
.PHONY: libdiagnostics
.PHONY: libgdiagnostics
ifneq (,$(findstring mingw,$(target)))
# Create import library
LIBDIAGNOSTICS_EXTRA_OPTS = -Wl,--out-implib,$(LIBDIAGNOSTICS_IMPORT_LIB)
LIBGDIAGNOSTICS_EXTRA_OPTS = -Wl,--out-implib,$(LIBGDIAGNOSTICS_IMPORT_LIB)
else
ifneq (,$(findstring darwin,$(host)))
# TODO : Construct a Darwin-style symbol export file.
LIBDIAGNOSTICS_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBDIAGNOSTICS_VERSION_NUM) \
-Wl,-current_version,$(LIBDIAGNOSTICS_VERSION_NUM).$(LIBDIAGNOSTICS_MINOR_NUM).$(LIBDIAGNOSTICS_AGE) \
$(LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION) \
$(LIBDIAGNOSTICS_SONAME_OPTION)
LIBGDIAGNOSTICS_EXTRA_OPTS = -Wl,-compatibility_version,$(LIBGDIAGNOSTICS_VERSION_NUM) \
-Wl,-current_version,$(LIBGDIAGNOSTICS_VERSION_NUM).$(LIBGDIAGNOSTICS_MINOR_NUM).$(LIBGDIAGNOSTICS_AGE) \
$(LIBGDIAGNOSTICS_VERSION_SCRIPT_OPTION) \
$(LIBGDIAGNOSTICS_SONAME_OPTION)
else
LIBDIAGNOSTICS_EXTRA_OPTS = $(LIBDIAGNOSTICS_VERSION_SCRIPT_OPTION) \
$(LIBDIAGNOSTICS_SONAME_OPTION)
LIBGDIAGNOSTICS_EXTRA_OPTS = $(LIBGDIAGNOSTICS_VERSION_SCRIPT_OPTION) \
$(LIBGDIAGNOSTICS_SONAME_OPTION)
endif
endif
$(LIBDIAGNOSTICS_FILENAME): $(libdiagnostics_OBJS) $(CPPLIB) $(EXTRA_GCC_LIBS) $(LIBS) \
$(LIBDEPS) $(srcdir)/libdiagnostics.map
@$(call LINK_PROGRESS,$(INDEX.libdiagnostics),start)
$(LIBGDIAGNOSTICS_FILENAME): $(libgdiagnostics_OBJS) $(CPPLIB) $(EXTRA_GCC_LIBS) $(LIBS) \
$(LIBDEPS) $(srcdir)/libgdiagnostics.map
@$(call LINK_PROGRESS,$(INDEX.libgdiagnostics),start)
+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ -shared \
$(libdiagnostics_OBJS) \
$(libgdiagnostics_OBJS) \
$(CPPLIB) $(EXTRA_GCC_LIBS) $(LIBS) \
$(LIBDIAGNOSTICS_EXTRA_OPTS)
@$(call LINK_PROGRESS,$(INDEX.libdiagnostics),end)
$(LIBGDIAGNOSTICS_EXTRA_OPTS)
@$(call LINK_PROGRESS,$(INDEX.libgdiagnostics),end)
# Create symlinks when not building for Windows
ifeq (,$(findstring mingw,$(target)))
ifeq (,$(findstring darwin,$(host)))
# but only one level for Darwin, version info is embedded.
$(LIBDIAGNOSTICS_SONAME_SYMLINK): $(LIBDIAGNOSTICS_FILENAME)
ln -sf $(LIBDIAGNOSTICS_FILENAME) $(LIBDIAGNOSTICS_SONAME_SYMLINK)
$(LIBGDIAGNOSTICS_SONAME_SYMLINK): $(LIBGDIAGNOSTICS_FILENAME)
ln -sf $(LIBGDIAGNOSTICS_FILENAME) $(LIBGDIAGNOSTICS_SONAME_SYMLINK)
endif
$(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK): $(LIBDIAGNOSTICS_SONAME_SYMLINK)
ln -sf $(LIBDIAGNOSTICS_SONAME_SYMLINK) $(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
$(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK): $(LIBGDIAGNOSTICS_SONAME_SYMLINK)
ln -sf $(LIBGDIAGNOSTICS_SONAME_SYMLINK) $(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK)
endif
# sarif-replay: a command-line tool that uses libdiagnostics to
# sarif-replay: a command-line tool that uses libgdiagnostics to
# replay SARIF files
sarif-replay: $(SARIF_REPLAY_OBJS) $(LIBDIAGNOSTICS_FILENAME)
sarif-replay: $(SARIF_REPLAY_OBJS) $(LIBGDIAGNOSTICS_FILENAME)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(SARIF_REPLAY_OBJS) $(LIBDIAGNOSTICS_FILENAME) $(LIBS)
$(SARIF_REPLAY_OBJS) $(LIBGDIAGNOSTICS_FILENAME) $(LIBS)
# Dump a specs file to make -B./ read these specs over installed ones.
$(SPECS): xgcc$(exeext)
@ -3957,8 +3957,8 @@ ifeq ($(enable_plugin),yes)
install: install-plugin
endif
ifeq ($(enable_libdiagnostics),yes)
install: install-libdiagnostics
ifeq ($(enable_libgdiagnostics),yes)
install: install-libgdiagnostics
endif
install-strip: override INSTALL_PROGRAM = $(INSTALL_STRIP_PROGRAM)
@ -4137,46 +4137,46 @@ install-driver: installdirs xgcc$(exeext)
fi; \
fi
libdiagnostics.install-headers: installdirs
$(INSTALL_DATA) $(srcdir)/libdiagnostics.h \
$(DESTDIR)$(includedir)/libdiagnostics.h
$(INSTALL_DATA) $(srcdir)/libdiagnostics++.h \
$(DESTDIR)$(includedir)/libdiagnostics++.h
libgdiagnostics.install-headers: installdirs
$(INSTALL_DATA) $(srcdir)/libgdiagnostics.h \
$(DESTDIR)$(includedir)/libgdiagnostics.h
$(INSTALL_DATA) $(srcdir)/libgdiagnostics++.h \
$(DESTDIR)$(includedir)/libgdiagnostics++.h
ifneq (,$(findstring mingw,$(target)))
libdiagnostics.install-common: installdirs libdiagnostics.install-headers
libgdiagnostics.install-common: installdirs libgdiagnostics.install-headers
# Install import library
$(INSTALL_PROGRAM) $(LIBDIAGNOSTICS_IMPORT_LIB) \
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_IMPORT_LIB)
$(INSTALL_PROGRAM) $(LIBGDIAGNOSTICS_IMPORT_LIB) \
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_IMPORT_LIB)
# Install DLL file
$(INSTALL_PROGRAM) $(LIBDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(bindir)/$(LIBDIAGNOSTICS_FILENAME)
$(INSTALL_PROGRAM) $(LIBGDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(bindir)/$(LIBGDIAGNOSTICS_FILENAME)
else
ifneq (,$(findstring darwin,$(host)))
# but only one level for Darwin
libdiagnostics.install-common: installdirs libdiagnostics.install-headers
$(INSTALL_PROGRAM) $(LIBDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_FILENAME)
libgdiagnostics.install-common: installdirs libgdiagnostics.install-headers
$(INSTALL_PROGRAM) $(LIBGDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_FILENAME)
ln -sf \
$(LIBDIAGNOSTICS_SONAME_SYMLINK)\
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
$(LIBGDIAGNOSTICS_SONAME_SYMLINK)\
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK)
else
libdiagnostics.install-common: installdirs libdiagnostics.install-headers
$(INSTALL_PROGRAM) $(LIBDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_FILENAME)
libgdiagnostics.install-common: installdirs libgdiagnostics.install-headers
$(INSTALL_PROGRAM) $(LIBGDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_FILENAME)
ln -sf \
$(LIBDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_SONAME_SYMLINK)
$(LIBGDIAGNOSTICS_FILENAME) \
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_SONAME_SYMLINK)
ln -sf \
$(LIBDIAGNOSTICS_SONAME_SYMLINK)\
$(DESTDIR)$(libdir)/$(LIBDIAGNOSTICS_LINKER_NAME_SYMLINK)
$(LIBGDIAGNOSTICS_SONAME_SYMLINK)\
$(DESTDIR)$(libdir)/$(LIBGDIAGNOSTICS_LINKER_NAME_SYMLINK)
endif
endif
install-libdiagnostics: libdiagnostics.install-common sarif-replay
install-libgdiagnostics: libgdiagnostics.install-common sarif-replay
-rm -f $(DESTDIR)$(bindir)/sarif-replay
-$(INSTALL_PROGRAM) sarif-replay $(DESTDIR)$(bindir)/sarif-replay

29
gcc/configure vendored
View file

@ -637,8 +637,8 @@ LD_PICFLAG
PICFLAG
enable_default_pie
enable_host_bind_now
LIBDIAGNOSTICS
enable_libdiagnostics
LIBGDIAGNOSTICS
enable_libgdiagnostics
enable_host_pie
enable_host_shared
enable_plugin
@ -1053,7 +1053,7 @@ enable_version_specific_runtime_libs
enable_plugin
enable_host_shared
enable_host_pie
enable_libdiagnostics
enable_libgdiagnostics
enable_host_bind_now
enable_libquadmath_support
with_linker_hash_style
@ -1829,7 +1829,8 @@ Optional Features:
--enable-plugin enable plugin support
--enable-host-shared build host code as shared libraries
--enable-host-pie build host code as PIE
--enable-libdiagnostics build libdiagnostics shared library
--enable-libgdiagnostics
build libgdiagnostics shared library
--enable-host-bind-now link host code as BIND_NOW
--disable-libquadmath-support
disable libquadmath support for Fortran
@ -21460,7 +21461,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 21463 "configure"
#line 21464 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -21566,7 +21567,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 21569 "configure"
#line 21570 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -33800,8 +33801,8 @@ for language in $all_selected_languages
do
check_languages="$check_languages check-$language"
done
if test x$enable_libdiagnostics = xyes; then
check_languages="$check_languages check-libdiagnostics check-sarif-replay"
if test x$enable_libgdiagnostics = xyes; then
check_languages="$check_languages check-libgdiagnostics check-sarif-replay"
fi
selftest_languages=
@ -34241,17 +34242,17 @@ fi
# Check whether --enable-libdiagnostics was given.
if test "${enable_libdiagnostics+set}" = set; then :
enableval=$enable_libdiagnostics;
# Check whether --enable-libgdiagnostics was given.
if test "${enable_libgdiagnostics+set}" = set; then :
enableval=$enable_libgdiagnostics;
fi
if test "$enable_libdiagnostics" = "yes"; then
LIBDIAGNOSTICS='libdiagnostics sarif-replay'
if test "$enable_libgdiagnostics" = "yes"; then
LIBGDIAGNOSTICS='libgdiagnostics sarif-replay'
else
LIBDIAGNOSTICS=''
LIBGDIAGNOSTICS=''
fi

View file

@ -7364,8 +7364,8 @@ for language in $all_selected_languages
do
check_languages="$check_languages check-$language"
done
if test x$enable_libdiagnostics = xyes; then
check_languages="$check_languages check-libdiagnostics check-sarif-replay"
if test x$enable_libgdiagnostics = xyes; then
check_languages="$check_languages check-libgdiagnostics check-sarif-replay"
fi
selftest_languages=
@ -7599,17 +7599,17 @@ AC_ARG_ENABLE(host-pie,
[build host code as PIE])])
AC_SUBST(enable_host_pie)
AC_ARG_ENABLE(libdiagnostics,
[AS_HELP_STRING([--enable-libdiagnostics],
[build libdiagnostics shared library])])
AC_SUBST(enable_libdiagnostics)
AC_ARG_ENABLE(libgdiagnostics,
[AS_HELP_STRING([--enable-libgdiagnostics],
[build libgdiagnostics shared library])])
AC_SUBST(enable_libgdiagnostics)
if test "$enable_libdiagnostics" = "yes"; then
LIBDIAGNOSTICS='libdiagnostics sarif-replay'
if test "$enable_libgdiagnostics" = "yes"; then
LIBGDIAGNOSTICS='libgdiagnostics sarif-replay'
else
LIBDIAGNOSTICS=''
LIBGDIAGNOSTICS=''
fi
AC_SUBST(LIBDIAGNOSTICS)
AC_SUBST(LIBGDIAGNOSTICS)
# Enable --enable-host-bind-now

View file

@ -1231,8 +1231,8 @@ virtual calls in verifiable mode at all. However the libvtv library will
still be built (see @option{--disable-libvtv} to turn off building libvtv).
@option{--disable-vtable-verify} is the default.
@item --enable-libdiagnostics
Specify whether to build @code{libdiagnostics}, a shared library exposing
@item --enable-libgdiagnostics
Specify whether to build @code{libgdiagnostics}, a shared library exposing
GCC's diagnostics capabilities via a C API, and a C++ wrapper API adding
``syntactic sugar''.
@ -1241,7 +1241,7 @@ This option requires @option{--enable-host-shared} on non-Windows hosts.
This option also enables @code{sarif-replay}, a command-line tool for
viewing @uref{https://sarif.info/,,SARIF files}. @code{sarif-replay} takes
one or more @code{.sarif} files as input and attempts to replay any
diagnostics within them to stderr (via @code{libdiagnostics}) in the style
diagnostics within them to stderr (via @code{libgdiagnostics}) in the style
of GCC's diagnostics.
@item --disable-gcov

View file

@ -6,7 +6,7 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'libdiagnostics'
project = 'libgdiagnostics'
copyright = '2024, David Malcolm'
author = 'David Malcolm'

View file

@ -15,10 +15,10 @@
along with this program. If not, see
<https://www.gnu.org/licenses/>.
libdiagnostics
==============
libgdiagnostics
===============
This document describes `libdiagnostics <https://gcc.gnu.org/wiki/libdiagnostics>`_,
This document describes `libgdiagnostics <https://gcc.gnu.org/wiki/libgdiagnostics>`_,
an API for programs to use to emit diagnostics (such as for "lint"-style checker
tools), supporting:
@ -82,9 +82,9 @@ tools), supporting:
There are actually two APIs for the library:
* a pure C API: ``libdiagnostics.h``
* a pure C API: ``libgdiagnostics.h``
* a C++ wrapper API: ``libdiagnostics+.h``. This is a header-only
* a C++ wrapper API: ``libgdiagnostics+.h``. This is a header-only
collection of wrapper classes around the C API to give a less
verbose API.
@ -99,7 +99,7 @@ Contents
tutorial/index.rst
topics/index.rst
libdiagnostics is free software: you can redistribute it and/or modify it
libgdiagnostics is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

View file

@ -23,7 +23,7 @@ Diagnostic Managers
.. type:: diagnostic_manager;
A :type:`diagnostic_manager` is an opaque bundle of state for a client of
libdiagnostics.
libgdiagnostics.
It has zero of more "output sinks" to which diagnostics are emitted.

View file

@ -20,7 +20,7 @@
Message formatting
==================
Various libdiagnostics entrypoints take a format string and
Various libgdiagnostics entrypoints take a format string and
variadic arguments.
The format strings take codes prefixed by ``%``, or ``%q`` to put

View file

@ -78,25 +78,25 @@ locations.
.. type:: diagnostic_line_num_t
A :type:`diagnostic_line_num_t` is used for representing line numbers
within text files. libdiagnostics treats the first line of a text file
within text files. libgdiagnostics treats the first line of a text file
as line 1.
.. type:: diagnostic_column_num_t
A :type:`diagnostic_column_num_t` is used for representing column numbers
within text files. libdiagnostics treats the first column of a text line
within text files. libgdiagnostics treats the first column of a text line
as column 1, **not** column 0.
.. note::
Both libdiagnostics and Emacs number source *lines* starting at 1, but
Both libgdiagnostics and Emacs number source *lines* starting at 1, but
they have differing conventions for *columns*.
libdiagnostics uses a 1-based convention for source columns,
libgdiagnostics uses a 1-based convention for source columns,
whereas Emacs's ``M-x column-number-mode`` uses a 0-based convention.
For example, an error in the initial, left-hand
column of source line 3 is reported by libdiagnostics as::
column of source line 3 is reported by libgdiagnostics as::
some-file.c:3:1: error: ...etc...
@ -107,7 +107,7 @@ as column 1, **not** column 0.
some-file.c 10% (3, 0)
i.e. ``3:1:`` in libdiagnostics corresponds to ``(3, 0)`` in Emacs.
i.e. ``3:1:`` in libgdiagnostics corresponds to ``(3, 0)`` in Emacs.
.. type:: diagnostic_physical_location
@ -267,7 +267,7 @@ This diagnostic has three locations
For example,
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-labelled-ranges.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-labelled-ranges.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */

View file

@ -17,7 +17,7 @@
.. default-domain:: c
Adding libdiagnostics to an existing project
============================================
Adding libgdiagnostics to an existing project
=============================================
TODO

View file

@ -23,17 +23,17 @@ Tutorial part 1: "Hello world"
Before we look at the details of the API, let's look at building and
running programs that use the library.
Here's a toy program that uses libdiagnostics to emit an error message
Here's a toy program that uses libgdiagnostics to emit an error message
to stderr.
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-example-1.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-example-1.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */
Copy the above to `tut01-hello-world.c`.
Assuming you have libdiagnostics installed, build the test program
Assuming you have libgdiagnostics installed, build the test program
using:
.. code-block:: console
@ -61,11 +61,11 @@ Obviously a trivial example like the above could be done using ``fprintf``
on stderr, and it's fairly easy to colorize text at the terminal.
In :doc:`the next part of the tutorial <02-physical-locations>` we'll add
file/location information to our error messages, and libdiagnostics will
file/location information to our error messages, and libgdiagnostics will
quote the pertinent parts of the file, underlining them, which is less trivial
to reimplement. libdiagnostics gives us many other such abilities, such as
to reimplement. libgdiagnostics gives us many other such abilities, such as
fix-it hints and execution paths, which we'll cover in the following
tutorials. Also, once a program's diagnostics are using libdiagnostics,
tutorials. Also, once a program's diagnostics are using libgdiagnostics,
it is trivial to add support for outputting them in
machine-readable form as :doc:`SARIF <../topics/sarif>`.
@ -74,7 +74,7 @@ Structure
*********
The above example shows the typical structure of a program using
libdiagnostics:
libgdiagnostics:
* **initialization**: create a :type:`diagnostic_manager` instance,
and create an output sink for it, and other one-time initialization
@ -91,7 +91,7 @@ libdiagnostics:
For non-trivial examples we'll also want to create location information,
which could happen during initialization, or during a parsing phase of
the program using libdiagnostics. See :doc:`02-physical-locations` for
the program using libgdiagnostics. See :doc:`02-physical-locations` for
more information.
@ -99,7 +99,7 @@ Formatted messages
******************
The above example uses :func:`diagnostic_finish`, which takes a format
string and arguments. libdiagnostics has its own style of format
string and arguments. libgdiagnostics has its own style of format
string arguments used for :func:`diagnostic_finish` and some other
entrypoints.
@ -128,7 +128,7 @@ terminal, and the quotes will be internationalized, so that e.g. with
Note that:
* the string ``error`` has been localized by libdiagnostics to
* the string ``error`` has been localized by libgdiagnostics to
``erreur``,
* locale-specific quoting has been used (``«`` and ``»`` rather than
@ -161,7 +161,7 @@ leading to output like this::
my-awesome-checker: error: can't find foo
There are various other functions for
:doc:`supplying metadata to libdiagnostics <../../topics/metadata>`.
:doc:`supplying metadata to libgdiagnostics <../../topics/metadata>`.
Moving beyond trivial examples

View file

@ -20,7 +20,7 @@
Tutorial part 2: physical locations
===================================
libdiagnostics has two kinds of location:
libgdiagnostics has two kinds of location:
* *physical locations* expressed in terms of a specific file, and line(s)
and perhaps column(s), such as ``some-file.c:3:1``, or a range of
@ -100,9 +100,9 @@ For example, given this example input where the tool can't find the header::
#include <foo.h>
we could complain about it via libdiagnostics via:
we could complain about it via libgdiagnostics via:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-no-column.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-no-column.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */
@ -112,10 +112,10 @@ leading to output like this::
foo.c:17: error: can't find 'foo.h'"
17 | #include <foo.h>
where libdiagnostics will attempt to load the source file and
where libgdiagnostics will attempt to load the source file and
quote the pertinent line.
If libdiagnostics cannot open the file, it will merely print::
If libgdiagnostics cannot open the file, it will merely print::
foo.c:17: error: can't find 'foo.h'
@ -149,7 +149,7 @@ start of the range, another one for the end of the range, and then using
these two to create a :type:`diagnostic_physical_location` for the
range as a whole:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-error.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-error.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */
@ -160,10 +160,10 @@ On compiling and running the program, we should get this output::
17 | #include <foo.h>
| ^~~~~
where libdiagnostics will attempt to load the source file and
where libgdiagnostics will attempt to load the source file and
underling the pertinent part of the given line.
If libdiagnostics cannot open the file, it will merely print::
If libgdiagnostics cannot open the file, it will merely print::
foo.c:17:8: error: can't find 'foo'
@ -208,7 +208,7 @@ the following :type:`diagnostic` has its primary location where the missing
comma should be, and secondary locations for each of the string literals
``"foo"``, ``"bar"``, and ``"baz"``, added via :func:`diagnostic_add_location`:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-multiple-lines.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-multiple-lines.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */
@ -238,7 +238,7 @@ Consider emitting a "type mismatch" diagnostic for::
where the primary location is on the ``+``, with secondary locations on the``42``
and the ``"foo"``:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-labelled-ranges.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-labelled-ranges.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */

View file

@ -30,12 +30,12 @@ We want to generate output like this::
test-with-note.c:17:11: note: have you looked behind the couch?
The "error" and "note" are both instances of :type:`diagnostic`.
We want to let libdiagnostics know that they are grouped together.
We want to let libgdiagnostics know that they are grouped together.
The way to do this is to use :func:`diagnostic_manager_begin_group`
and :func:`diagnostic_manager_end_group` around the "finish" calls
to the diagnostics.
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-error-with-note.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-error-with-note.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */

View file

@ -26,7 +26,7 @@ such as warnings.
We can select different kinds of diagnostic via :enum:`diagnostic_level`
when calling :func:`diagnostic_begin`:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-warning.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-warning.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */

View file

@ -20,13 +20,13 @@
Tutorial part 6: fix-it hints
=============================
libdiagnostics supports adding "fix-it hints" to a :type:`diagnostic`:
libgdiagnostics supports adding "fix-it hints" to a :type:`diagnostic`:
suggestions for the user on how to edit their code to fix a problem. These
can be expressed as insertions, replacements, and removals of text.
For example, here we add a replacement fix-it hint to a diagnostic:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-fix-it-hint.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-fix-it-hint.c
:language: c
:start-after: /* begin quoted source */
:end-before: /* end quoted source */

View file

@ -28,7 +28,7 @@ bugs in `CPython extension code <https://docs.python.org/3/c-api/index.html>`_.
Let's say we're analyzing this code:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-warning-with-path.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-warning-with-path.c
:language: c
:start-after: begin fake source
:end-before: end fake source
@ -82,14 +82,14 @@ pointer (see `§3.10.3 "URIs that use the sarif scheme" <https://docs.oasis-open
Let's add an event between these describing control flow, creating three
events in all:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-warning-with-path.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-warning-with-path.c
:language: c
:start-after: begin path creation
:end-before: end path creation
Assuming we also gave it :type:`diagnostic_logical_location` with:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-warning-with-path.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-warning-with-path.c
:language: c
:start-after: begin create logical locs
:end-before: end create logical locs
@ -128,7 +128,7 @@ and for SARIF sinks the path will be added as a ``codeFlow`` object
Here's the above example in full:
.. literalinclude:: ../../../testsuite/libdiagnostics.dg/test-warning-with-path.c
.. literalinclude:: ../../../testsuite/libgdiagnostics.dg/test-warning-with-path.c
:language: c
:start-after: begin full example
:end-before: end full example
@ -137,5 +137,5 @@ Here's the above example in full:
Moving on
*********
That's the end of the tutorial. For more information on libdiagnostics, see
That's the end of the tutorial. For more information on libgdiagnostics, see
the :doc:`topic guide <../topics/index>`.

View file

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -18,7 +18,7 @@
Tutorial
========
The following tutorial gives an overview of how to use libdiagnostics.
The following tutorial gives an overview of how to use libgdiagnostics.
.. toctree::
:maxdepth: 2

View file

@ -1,4 +1,4 @@
/* A C++ wrapper API around libdiagnostics.h for emitting diagnostics.
/* A C++ wrapper API around libgdiagnostics.h for emitting diagnostics.
Copyright (C) 2023-2024 Free Software Foundation, Inc.
This file is part of GCC.
@ -17,12 +17,12 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef LIBDIAGNOSTICSPP_H
#define LIBDIAGNOSTICSPP_H
#ifndef LIBGDIAGNOSTICSPP_H
#define LIBGDIAGNOSTICSPP_H
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
namespace libdiagnostics {
namespace libgdiagnostics {
typedef diagnostic_line_num_t line_num_t;
typedef diagnostic_column_num_t column_num_t;
@ -155,7 +155,7 @@ public:
logical_location logical_loc,
unsigned stack_depth,
const char *fmt, ...)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 6);
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 6);
diagnostic_event_id
add_event_va (physical_location physical_loc,
@ -163,7 +163,7 @@ public:
unsigned stack_depth,
const char *fmt,
va_list *args)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 0);
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 0);
diagnostic_execution_path *m_inner;
bool m_owned;
@ -221,13 +221,13 @@ public:
void
finish (const char *fmt, ...)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 3);
void
finish_va (const char *fmt, va_list *args)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 0);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 0);
::diagnostic * const m_inner;
};
@ -314,8 +314,8 @@ public:
file
new_file (const char *name,
const char *sarif_source_language)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
void
debug_dump (file f,
@ -590,6 +590,6 @@ manager::begin_diagnostic (enum diagnostic_level level)
return diagnostic (diagnostic_begin (m_inner, level));
}
} // namespace libdiagnostics
} // namespace libgdiagnostics
#endif // #ifndef LIBDIAGNOSTICSPP_H
#endif // #ifndef LIBGDIAGNOSTICSPP_H

View file

@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "logical-location.h"
#include "edit-context.h"
#include "make-unique.h"
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
class owned_nullable_string
{
@ -203,7 +203,7 @@ public:
}
void emit (diagnostic &diag, const char *msgid, va_list *args)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (3, 0);
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (3, 0);
protected:
sink (diagnostic_manager &mgr);
@ -349,7 +349,7 @@ public:
}
void emit (diagnostic &diag, const char *msgid, va_list *args)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING(3, 0);
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING(3, 0);
const diagnostic_file *
new_file (const char *name,
@ -559,14 +559,14 @@ private:
owned_nullable_string m_url;
};
class libdiagnostics_path_event : public diagnostic_event
class libgdiagnostics_path_event : public diagnostic_event
{
public:
libdiagnostics_path_event (const diagnostic_physical_location *physical_loc,
const diagnostic_logical_location *logical_loc,
unsigned stack_depth,
const char *gmsgid,
va_list *args)
libgdiagnostics_path_event (const diagnostic_physical_location *physical_loc,
const diagnostic_logical_location *logical_loc,
unsigned stack_depth,
const char *gmsgid,
va_list *args)
: m_physical_loc (physical_loc),
m_logical_loc (logical_loc),
m_stack_depth (stack_depth)
@ -644,10 +644,10 @@ private:
label_text m_desc_colored;
};
class libdiagnostics_path_thread : public diagnostic_thread
class libgdiagnostics_path_thread : public diagnostic_thread
{
public:
libdiagnostics_path_thread (const char *name) : m_name (name) {}
libgdiagnostics_path_thread (const char *name) : m_name (name) {}
label_text get_name (bool) const final override
{
return label_text::borrow (m_name);
@ -673,11 +673,11 @@ struct diagnostic_execution_path : public diagnostic_path
const char *gmsgid,
va_list *args)
{
m_events.push_back (::make_unique<libdiagnostics_path_event> (physical_loc,
logical_loc,
stack_depth,
gmsgid,
args));
m_events.push_back (::make_unique<libgdiagnostics_path_event> (physical_loc,
logical_loc,
stack_depth,
gmsgid,
args));
return m_events.size () - 1;
}
@ -713,8 +713,8 @@ struct diagnostic_execution_path : public diagnostic_path
}
private:
libdiagnostics_path_thread m_thread;
std::vector<std::unique_ptr<libdiagnostics_path_event>> m_events;
libgdiagnostics_path_thread m_thread;
std::vector<std::unique_ptr<libgdiagnostics_path_event>> m_events;
};
/* This has to be a "struct" as it is exposed in the C API. */

View file

@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef LIBDIAGNOSTICS_H
#define LIBDIAGNOSTICS_H
#ifndef LIBGDIAGNOSTICS_H
#define LIBGDIAGNOSTICS_H
#include <stdarg.h>
#include <stdio.h>
@ -35,29 +35,29 @@ extern "C" {
is of a particular minimum version. (Both major & minor numbers are
significant.) This macro will evaluate to 0 if we are not using
gcc at all. */
#define LIBDIAGNOSTICS_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
#define LIBGDIAGNOSTICS_GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
/**********************************************************************
Macros for attributes.
**********************************************************************/
# if (LIBDIAGNOSTICS_GCC_VERSION >= 3003)
# define LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL(ARG_NUM) __attribute__ ((__nonnull__ (ARG_NUM)))
# if (LIBGDIAGNOSTICS_GCC_VERSION >= 3003)
# define LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL(ARG_NUM) __attribute__ ((__nonnull__ (ARG_NUM)))
# else
# define LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL(ARG_NUM)
# define LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL(ARG_NUM)
# endif /* GNUC >= 3.3 */
#define LIBDIAGNOSTICS_PARAM_CAN_BE_NULL(ARG_NUM)
#define LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL(ARG_NUM)
/* empty; for the human reader */
#define LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING(FMT_ARG_NUM, ARGS_ARG_NUM) \
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (FMT_ARG_NUM)
#define LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING(FMT_ARG_NUM, ARGS_ARG_NUM) \
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (FMT_ARG_NUM)
/* In theory we'd also add
__attribute__ ((__format__ (__gcc_diag__, FMT_ARG_NUM, ARGS_ARG_NUM)))
if LIBDIAGNOSTICS_GCC_VERSION >= 4001
if LIBGDIAGNOSTICS_GCC_VERSION >= 4001
However, doing so leads to warnings from -Wformat-diag, which is part
of -Wall but undocumented, and much fussier than I'd want to inflict
on users of libdiagnostics. */
on users of libgdiagnostics. */
/**********************************************************************
Data structures and types.
@ -125,14 +125,14 @@ typedef struct diagnostic_physical_location diagnostic_physical_location;
/* Types for storing line and column information in text files.
Both libdiagnostics and emacs number source *lines* starting at 1, but
Both libgdiagnostics and emacs number source *lines* starting at 1, but
they have differing conventions for *columns*.
libdiagnostics uses a 1-based convention for source columns,
libgdiagnostics uses a 1-based convention for source columns,
whereas Emacs's M-x column-number-mode uses a 0-based convention.
For example, an error in the initial, left-hand
column of source line 3 is reported by libdiagnostics as:
column of source line 3 is reported by libgdiagnostics as:
some-file.c:3:1: error: ...etc...
@ -143,7 +143,7 @@ typedef struct diagnostic_physical_location diagnostic_physical_location;
some-file.c 10% (3, 0)
i.e. "3:1:" in libdiagnostics corresponds to "(3, 0)" in Emacs. */
i.e. "3:1:" in libgdiagnostics corresponds to "(3, 0)" in Emacs. */
typedef unsigned int diagnostic_line_num_t;
typedef unsigned int diagnostic_column_num_t;
@ -231,7 +231,7 @@ diagnostic_manager_new (void);
extern void
diagnostic_manager_release (diagnostic_manager *)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Optional metadata about the manager. */
@ -241,8 +241,8 @@ diagnostic_manager_release (diagnostic_manager *)
extern void
diagnostic_manager_set_tool_name (diagnostic_manager *diag_mgr,
const char *value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Set a string suitable for use as the value of the SARIF "fullName" property
(SARIF v2.1.0 section 3.19.9). */
@ -250,8 +250,8 @@ diagnostic_manager_set_tool_name (diagnostic_manager *diag_mgr,
extern void
diagnostic_manager_set_full_name (diagnostic_manager *diag_mgr,
const char *value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Set a string suitable for use as the value of the SARIF "version" property
(SARIF v2.1.0 section 3.19.13). */
@ -259,8 +259,8 @@ diagnostic_manager_set_full_name (diagnostic_manager *diag_mgr,
extern void
diagnostic_manager_set_version_string (diagnostic_manager *diag_mgr,
const char *value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Set a string suitable for use as the value of the SARIF "informationUri"
property (SARIF v2.1.0 section 3.19.17). */
@ -268,8 +268,8 @@ diagnostic_manager_set_version_string (diagnostic_manager *diag_mgr,
extern void
diagnostic_manager_set_version_url (diagnostic_manager *diag_mgr,
const char *value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Destinations for diagnostics. */
@ -285,8 +285,8 @@ extern diagnostic_text_sink *
diagnostic_manager_add_text_sink (diagnostic_manager *diag_mgr,
FILE *dst_stream,
enum diagnostic_colorize colorize)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Functions to manipulate text sinks. */
@ -296,14 +296,14 @@ diagnostic_manager_add_text_sink (diagnostic_manager *diag_mgr,
extern void
diagnostic_text_sink_set_source_printing_enabled (diagnostic_text_sink *text_sink,
int value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Update colorization of text sink. */
extern void
diagnostic_text_sink_set_colorize (diagnostic_text_sink *text_sink,
enum diagnostic_colorize colorize)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Enable/disable colorization of the characters of source text
that are underlined.
@ -317,7 +317,7 @@ diagnostic_text_sink_set_colorize (diagnostic_text_sink *text_sink,
extern void
diagnostic_text_sink_set_labelled_source_colorization_enabled (diagnostic_text_sink *text_sink,
int value)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Add a new output sink to DIAG_MGR, which writes SARIF of the given
version to DST_STREAM.
@ -334,9 +334,9 @@ diagnostic_manager_add_sarif_sink (diagnostic_manager *diag_mgr,
FILE *dst_stream,
const diagnostic_file *main_input_file,
enum diagnostic_sarif_version version)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* Write a patch to DST_STREAM consisting of all fix-it hints
on all diagnostics that have been finished on DIAG_MGR. */
@ -344,8 +344,8 @@ diagnostic_manager_add_sarif_sink (diagnostic_manager *diag_mgr,
extern void
diagnostic_manager_write_patch (diagnostic_manager *diag_mgr,
FILE *dst_stream)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Location management. */
@ -363,9 +363,9 @@ extern const diagnostic_file *
diagnostic_manager_new_file (diagnostic_manager *diag_mgr,
const char *name,
const char *sarif_source_language)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
/* Write a representation of FILE to OUT, for debugging. */
@ -373,9 +373,9 @@ extern void
diagnostic_manager_debug_dump_file (diagnostic_manager *diag_mgr,
const diagnostic_file *file,
FILE *out)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* Attempt to create a diagnostic_location representing
FILENAME:LINE_NUM, with no column information
@ -385,8 +385,8 @@ extern const diagnostic_physical_location *
diagnostic_manager_new_location_from_file_and_line (diagnostic_manager *diag_mgr,
const diagnostic_file *file,
diagnostic_line_num_t line_num)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Attempt to create a diagnostic_physical_location representing
FILENAME:LINE_NUM:COLUMN_NUM. */
@ -396,8 +396,8 @@ diagnostic_manager_new_location_from_file_line_column (diagnostic_manager *diag_
const diagnostic_file *file,
diagnostic_line_num_t line_num,
diagnostic_column_num_t column_num)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Attempt to create a diagnostic_physical_location representing a
range within a source file, with a highlighted "caret" location.
@ -424,10 +424,10 @@ diagnostic_manager_new_location_from_range (diagnostic_manager *diag_mgr,
const diagnostic_physical_location *loc_caret,
const diagnostic_physical_location *loc_start,
const diagnostic_physical_location *loc_end)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (4);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (4);
/* Write a representation of LOC to OUT, for debugging. */
@ -435,9 +435,9 @@ extern void
diagnostic_manager_debug_dump_location (const diagnostic_manager *diag_mgr,
const diagnostic_physical_location *loc,
FILE *out)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* A bundle of state describing a logical location in the user's source,
such as "in function 'foo'".
@ -460,11 +460,11 @@ diagnostic_manager_new_logical_location (diagnostic_manager *diag_mgr,
const char *short_name,
const char *fully_qualified_name,
const char *decorated_name)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (4)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (5)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (6);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (4)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (5)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (6);
/* Write a representation of LOC to OUT, for debugging. */
@ -472,9 +472,9 @@ extern void
diagnostic_manager_debug_dump_logical_location (const diagnostic_manager *diag_mgr,
const diagnostic_logical_location *loc,
FILE *out)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* Diagnostic groups. */
@ -484,20 +484,20 @@ diagnostic_manager_debug_dump_logical_location (const diagnostic_manager *diag_m
extern void
diagnostic_manager_begin_group (diagnostic_manager *diag_mgr)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Finish a diagnostic group. */
extern void
diagnostic_manager_end_group (diagnostic_manager *diag_mgr)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Step-by-step creation of a diagnostic. */
extern diagnostic *
diagnostic_begin (diagnostic_manager *diag_mgr,
enum diagnostic_level level)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Associate this diagnostic with the given ID within
the Common Weakness Enumeration. */
@ -505,7 +505,7 @@ diagnostic_begin (diagnostic_manager *diag_mgr,
extern void
diagnostic_set_cwe (diagnostic *diag,
unsigned cwe_id)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Associate this diagnostic with a particular rule that has been violated
(such as in a coding standard, or within a specification).
@ -517,17 +517,17 @@ extern void
diagnostic_add_rule (diagnostic *diag,
const char *title,
const char *url)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3);
/* Set the primary location of DIAG. */
extern void
diagnostic_set_location (diagnostic *diag,
const diagnostic_physical_location * loc)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
/* Set the primary location of DIAG, with a label. */
@ -535,16 +535,16 @@ extern void
diagnostic_set_location_with_label (diagnostic *diag,
const diagnostic_physical_location *loc,
const char *fmt, ...)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* Add a secondary location to DIAG. */
extern void
diagnostic_add_location (diagnostic *diag,
const diagnostic_physical_location * loc)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Add a secondary location to DIAG, with a label. */
@ -552,17 +552,17 @@ extern void
diagnostic_add_location_with_label (diagnostic *diag,
const diagnostic_physical_location *loc,
const char *text)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
/* Set the logical location of DIAG. */
extern void
diagnostic_set_logical_location (diagnostic *diag,
const diagnostic_logical_location *logical_loc)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
/* Fix-it hints. */
@ -570,38 +570,38 @@ extern void
diagnostic_add_fix_it_hint_insert_before (diagnostic *diag,
const diagnostic_physical_location *loc,
const char *addition)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
extern void
diagnostic_add_fix_it_hint_insert_after (diagnostic *diag,
const diagnostic_physical_location *loc,
const char *addition)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
extern void
diagnostic_add_fix_it_hint_replace (diagnostic *diag,
const diagnostic_physical_location *loc,
const char *replacement)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3);
extern void
diagnostic_add_fix_it_hint_delete (diagnostic *diag,
const diagnostic_physical_location *loc)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2);
/* Create and borrow a pointer to an execution path for DIAG.
The path is automatically cleaned up when DIAG is finished. */
extern diagnostic_execution_path *
diagnostic_add_execution_path (diagnostic *diag)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Create a new execution path.
This is owned by the called and must have either
@ -610,22 +610,22 @@ diagnostic_add_execution_path (diagnostic *diag)
extern diagnostic_execution_path *
diagnostic_manager_new_execution_path (diagnostic_manager *manager)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1);
/* Set DIAG to use PATH as its execution path, taking ownership of PATH. */
extern void
diagnostic_take_execution_path (diagnostic *diag,
diagnostic_execution_path *path)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2);
/* Release ownership of PATH, which must not have been taken
by a diagnostic. */
extern void
diagnostic_execution_path_release (diagnostic_execution_path *path)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (1);
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (1);
/* Append an event to the end of PATH. */
@ -635,11 +635,11 @@ diagnostic_execution_path_add_event (diagnostic_execution_path *path,
const diagnostic_logical_location *logical_loc,
unsigned stack_depth,
const char *fmt, ...)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (5)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 6);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (5)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 6);
/* Append an event to the end of PATH. */
@ -650,11 +650,11 @@ diagnostic_execution_path_add_event_va (diagnostic_execution_path *path,
unsigned stack_depth,
const char *fmt,
va_list *args)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (5)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 0);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (2)
LIBGDIAGNOSTICS_PARAM_CAN_BE_NULL (3)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (5)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (5, 0);
/* Emit DIAG to all sinks of its manager, and release DIAG.
Use FMT for the message.
@ -663,17 +663,17 @@ diagnostic_execution_path_add_event_va (diagnostic_execution_path *path,
extern void
diagnostic_finish (diagnostic *diag, const char *fmt, ...)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 3);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 3);
/* As diagnostic_finish, but with a va_list. */
extern void
diagnostic_finish_va (diagnostic *diag, const char *fmt, va_list *args)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 0);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (2, 0);
/* DEFERRED:
- thread-safety
@ -688,4 +688,4 @@ diagnostic_finish_va (diagnostic *diag, const char *fmt, va_list *args)
}
#endif /* __cplusplus */
#endif /* LIBDIAGNOSTICS_H */
#endif /* LIBGDIAGNOSTICS_H */

View file

@ -1,4 +1,4 @@
# Linker script for libdiagnostics.so
# Linker script for libgdiagnostics.so
# Copyright (C) 2023-2024 Free Software Foundation, Inc.
# Contributed by David Malcolm <dmalcolm@redhat.com>.
#
@ -19,7 +19,7 @@
# <http://www.gnu.org/licenses/>. */
# The initial release of the library.
LIBDIAGNOSTICS_ABI_0
LIBGDIAGNOSTICS_ABI_0
{
global:
# Keep this list in order of decls in header file.

View file

@ -1,5 +1,5 @@
/* A library for re-emitting diagnostics saved in SARIF form
via libdiagnostics.
via libgdiagnostics.
Copyright (C) 2022-2024 Free Software Foundation, Inc.
Contributed by David Malcolm <dmalcolm@redhat.com>.
@ -26,7 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "system.h"
#include "coretypes.h"
#include "make-unique.h"
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
#include "json-parsing.h"
#include "intl.h"
#include "sarif-spec-urls.def"
@ -39,7 +39,7 @@ namespace {
Issue an error to MGR and return nullptr if there are any problems. */
static std::unique_ptr<std::vector<char>>
read_file (const char *path, libdiagnostics::manager &mgr)
read_file (const char *path, libgdiagnostics::manager &mgr)
{
FILE *f_in = fopen (path, "r");
if (!f_in)
@ -83,26 +83,26 @@ read_file (const char *path, libdiagnostics::manager &mgr)
return result;
}
static libdiagnostics::physical_location
make_physical_location (libdiagnostics::manager &mgr,
libdiagnostics::file f,
static libgdiagnostics::physical_location
make_physical_location (libgdiagnostics::manager &mgr,
libgdiagnostics::file f,
const json::location_map::point &point)
{
/* json::location_map::point uses 0-based columns,
whereas libdiagnostics uses 1-based columns. */
whereas libgdiagnostics uses 1-based columns. */
return mgr.new_location_from_file_line_column (f,
point.m_line,
point.m_column + 1);
}
static libdiagnostics::physical_location
make_physical_location (libdiagnostics::manager &mgr,
libdiagnostics::file f,
static libgdiagnostics::physical_location
make_physical_location (libgdiagnostics::manager &mgr,
libgdiagnostics::file f,
const json::location_map::range &range)
{
libdiagnostics::physical_location start
libgdiagnostics::physical_location start
= make_physical_location (mgr, f, range.m_start);
libdiagnostics::physical_location end
libgdiagnostics::physical_location end
= make_physical_location (mgr, f, range.m_end);
return mgr.new_location_from_range (start, start, end);
}
@ -202,8 +202,8 @@ struct string_property_value
class sarif_replayer
{
public:
sarif_replayer (libdiagnostics::manager &&output_manager,
libdiagnostics::manager &&control_manager)
sarif_replayer (libgdiagnostics::manager &&output_manager,
libgdiagnostics::manager &&control_manager)
: m_output_mgr (std::move (output_manager)),
m_control_mgr (std::move (control_manager)),
m_driver_obj (nullptr),
@ -249,7 +249,7 @@ private:
// "artifactLocation" object (§3.4)
enum status
handle_artifact_location_object (const json::object &artifact_loc,
libdiagnostics::file &out);
libgdiagnostics::file &out);
// Message string lookup algorithm (§3.11.7)
const char *
@ -280,34 +280,34 @@ private:
// "location" object (§3.28)
enum status
handle_location_object (const json::object &location_obj,
libdiagnostics::physical_location &out_physical_loc,
libdiagnostics::logical_location &out_logical_loc);
libgdiagnostics::physical_location &out_physical_loc,
libgdiagnostics::logical_location &out_logical_loc);
// "physicalLocation" object (§3.29)
enum status
handle_physical_location_object (const json::object &phys_loc_obj,
libdiagnostics::physical_location &out);
libgdiagnostics::physical_location &out);
// "region" object (§3.30)
enum status
handle_region_object (const json::object &region_obj,
libdiagnostics::file file,
libdiagnostics::physical_location &out);
libgdiagnostics::file file,
libgdiagnostics::physical_location &out);
// "logicalLocation" object (§3.33)
enum status
handle_logical_location_object (const json::object &logical_loc_obj,
libdiagnostics::logical_location &out);
libgdiagnostics::logical_location &out);
// "threadFlow" object (§3.37)
enum status
handle_thread_flow_object (const json::object &thread_flow_obj,
libdiagnostics::execution_path &out);
libgdiagnostics::execution_path &out);
// "threadFlowLocation" object (§3.38)
enum status
handle_thread_flow_location_object (const json::object &tflow_loc_obj,
libdiagnostics::execution_path &out);
libgdiagnostics::execution_path &out);
// reportingDescriptor lookup (§3.52.3)
const json::object *
@ -328,7 +328,7 @@ private:
report_invalid_sarif (const json::value &jv,
const spec_ref &ref,
const char *gmsgid, ...)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 5)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 5)
{
va_list ap;
va_start (ap, gmsgid);
@ -344,7 +344,7 @@ private:
report_unhandled_sarif (const json::value &jv,
const spec_ref &ref,
const char *gmsgid, ...)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 5)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 5)
{
va_list ap;
va_start (ap, gmsgid);
@ -359,7 +359,7 @@ private:
const char *gmsgid,
va_list *args,
enum diagnostic_level level)
LIBDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 0)
LIBGDIAGNOSTICS_PARAM_GCC_FORMAT_STRING (4, 0)
{
auto diag (m_control_mgr.begin_diagnostic (level));
@ -535,13 +535,13 @@ private:
size_t num_values);
/* The manager to replay the SARIF files to. */
libdiagnostics::manager m_output_mgr;
libgdiagnostics::manager m_output_mgr;
/* The manager for reporting issues loading SARIF files. */
libdiagnostics::manager m_control_mgr;
libgdiagnostics::manager m_control_mgr;
/* The file within m_control_mgr representing the .sarif file. */
libdiagnostics::file m_loaded_file;
libgdiagnostics::file m_loaded_file;
replayer_location_map m_json_location_map;
@ -946,8 +946,8 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
return status::err_invalid_sarif;
// §3.27.12 "locations" property
libdiagnostics::physical_location physical_loc;
libdiagnostics::logical_location logical_loc;
libgdiagnostics::physical_location physical_loc;
libgdiagnostics::logical_location logical_loc;
const property_spec_ref locations_prop ("result", "locations", "3.27.12");
const json::array *locations_arr
= get_required_property<json::array> (result_obj, locations_prop);
@ -969,7 +969,7 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
}
// §3.27.18 "codeFlows" property
libdiagnostics::execution_path path;
libgdiagnostics::execution_path path;
const property_spec_ref code_flows ("result", "codeFlows", "3.27.18");
if (auto code_flows_arr = get_optional_property<json::array> (result_obj,
code_flows))
@ -1001,7 +1001,7 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
}
}
libdiagnostics::group g (m_output_mgr);
libgdiagnostics::group g (m_output_mgr);
auto err (m_output_mgr.begin_diagnostic (level));
if (rule_id)
err.add_rule (rule_id->get_string (), nullptr);
@ -1020,8 +1020,8 @@ sarif_replayer::handle_result_obj (const json::object &result_obj,
{
for (auto rel_loc : *related_locations_arr)
{
libdiagnostics::physical_location physical_loc;
libdiagnostics::logical_location logical_loc;
libgdiagnostics::physical_location physical_loc;
libgdiagnostics::logical_location logical_loc;
const json::object *location_obj
= require_object_for_element (*rel_loc,
prop_related_locations);
@ -1274,7 +1274,7 @@ lookup_plain_text_within_result_message (const json::object *tool_component_obj,
enum status
sarif_replayer::handle_thread_flow_object (const json::object &thread_flow_obj,
libdiagnostics::execution_path &out)
libgdiagnostics::execution_path &out)
{
const property_spec_ref locations ("threadFlow", "locations", "3.37.6");
const json::array *locations_arr
@ -1302,10 +1302,10 @@ sarif_replayer::handle_thread_flow_object (const json::object &thread_flow_obj,
enum status
sarif_replayer::
handle_thread_flow_location_object (const json::object &tflow_loc_obj,
libdiagnostics::execution_path &path)
libgdiagnostics::execution_path &path)
{
libdiagnostics::physical_location physical_loc;
libdiagnostics::logical_location logical_loc;
libgdiagnostics::physical_location physical_loc;
libgdiagnostics::logical_location logical_loc;
label_text message;
int stack_depth = 0;
@ -1349,7 +1349,7 @@ handle_thread_flow_location_object (const json::object &tflow_loc_obj,
kind_strs.push_back (kind_str->get_string ());
// TODO: handle meaning?
/* TOOD: probably just want to add sarif kinds to
the libdiagnostics event, and have libdiagnostics
the libgdiagnostics event, and have libgdiagnostics
turn that back into a "meaning". */
}
}
@ -1388,8 +1388,8 @@ handle_thread_flow_location_object (const json::object &tflow_loc_obj,
enum status
sarif_replayer::
handle_location_object (const json::object &location_obj,
libdiagnostics::physical_location &out_physical_loc,
libdiagnostics::logical_location &out_logical_loc)
libgdiagnostics::physical_location &out_physical_loc,
libgdiagnostics::logical_location &out_logical_loc)
{
// §3.28.3 "physicalLocation" property
{
@ -1438,9 +1438,9 @@ handle_location_object (const json::object &location_obj,
enum status
sarif_replayer::
handle_physical_location_object (const json::object &phys_loc_obj,
libdiagnostics::physical_location &out)
libgdiagnostics::physical_location &out)
{
libdiagnostics::file artifact_file;
libgdiagnostics::file artifact_file;
// §3.29.3 "artifactLocation" property
const property_spec_ref artifact_location_prop
@ -1487,7 +1487,7 @@ handle_physical_location_object (const json::object &phys_loc_obj,
enum status
sarif_replayer::handle_artifact_location_object (const json::object &artifact_loc,
libdiagnostics::file &out)
libgdiagnostics::file &out)
{
// §3.4.3 "uri" property
const property_spec_ref uri_prop ("artifactLocation", "uri", "3.4.3");
@ -1521,15 +1521,15 @@ sarif_replayer::handle_artifact_location_object (const json::object &artifact_lo
enum status
sarif_replayer::
handle_region_object (const json::object &region_obj,
libdiagnostics::file file,
libdiagnostics::physical_location &out)
libgdiagnostics::file file,
libgdiagnostics::physical_location &out)
{
gcc_assert (file.m_inner);
// §3.30.5 "startLine" property
const property_spec_ref start_line_prop ("region", "startLine", "3.30.5");
libdiagnostics::physical_location start;
libdiagnostics::physical_location end;
libgdiagnostics::physical_location start;
libgdiagnostics::physical_location end;
if (auto start_line_jnum
= get_optional_property<json::integer_number> (region_obj,
start_line_prop))
@ -1586,7 +1586,7 @@ handle_region_object (const json::object &region_obj,
enum status
sarif_replayer::
handle_logical_location_object (const json::object &logical_loc_obj,
libdiagnostics::logical_location &out)
libgdiagnostics::logical_location &out)
{
const property_spec_ref name_prop ("logicalLocation", "name", "3.33.4");
const char *short_name = nullptr;
@ -1643,7 +1643,7 @@ handle_logical_location_object (const json::object &logical_loc_obj,
kind = result.m_val;
}
libdiagnostics::logical_location parent;
libgdiagnostics::logical_location parent;
out = m_output_mgr.new_logical_location (kind,
parent,
short_name,
@ -1740,7 +1740,7 @@ sarif_replay_path (const char *sarif_file,
FAIL_IF_NULL (control_manager);
FAIL_IF_NULL (options);
sarif_replayer r (libdiagnostics::manager (output_manager, false),
libdiagnostics::manager (control_manager, false));
sarif_replayer r (libgdiagnostics::manager (output_manager, false),
libgdiagnostics::manager (control_manager, false));
return (int)r.replay_file (sarif_file, *options);
}

View file

@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
#ifndef LIBSARIFREPLAY_H
#define LIBSARIFREPLAY_H
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#ifdef __cplusplus
extern "C" {
@ -47,10 +47,10 @@ sarif_replay_path (const char *sarif_file,
diagnostic_manager *output_manager,
diagnostic_manager *control_manager,
const replay_options *options)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3)
LIBDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (4);
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (1)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (2)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (3)
LIBGDIAGNOSTICS_PARAM_MUST_BE_NON_NULL (4);
#ifdef __cplusplus
}

View file

@ -24,7 +24,7 @@ along with GCC; see the file COPYING3. If not see
#include "coretypes.h"
#include "version.h"
#include "intl.h"
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
#include "libsarifreplay.h"
static const char *progname;
@ -98,9 +98,9 @@ print_usage ()
static bool
parse_options (int argc, char **argv,
options &opts,
libdiagnostics::text_sink control_text_sink)
libgdiagnostics::text_sink control_text_sink)
{
libdiagnostics::manager options_mgr;
libgdiagnostics::manager options_mgr;
options_mgr.set_tool_name ("sarif-replay");
options_mgr.add_text_sink (stderr, DIAGNOSTIC_COLORIZE_NO/*IF_TTY*/);
@ -196,11 +196,11 @@ main (int argc, char **argv)
progname = get_progname (argv[0]);
xmalloc_set_program_name (progname);
libdiagnostics::manager control_mgr;
libgdiagnostics::manager control_mgr;
control_mgr.set_tool_name (progname);
libdiagnostics::text_sink control_text_sink
libgdiagnostics::text_sink control_text_sink
= control_mgr.add_text_sink (stderr, DIAGNOSTIC_COLORIZE_IF_TTY);
options opts;
@ -218,7 +218,7 @@ main (int argc, char **argv)
auto note = control_mgr.begin_diagnostic (DIAGNOSTIC_LEVEL_NOTE);
note.finish ("about to replay %qs...", filename);
}
libdiagnostics::manager playback_mgr;
libgdiagnostics::manager playback_mgr;
playback_mgr.add_text_sink (stderr,
opts.m_replay_opts.m_diagnostics_colorize);

View file

@ -1,10 +1,10 @@
# Test code for libdiagnostics.so
# Test code for libgdiagnostics.so
#
# We will compile each of libdiagnostics.dg/test-*.{c,cc} into an executable
# dynamically linked against libdiagnostics.so, and then run each
# We will compile each of libgdiagnostics.dg/test-*.{c,cc} into an executable
# dynamically linked against libgdiagnostics.so, and then run each
# such executable.
#
# These executables call into the libdiagnostics.so API to emit diagnostics,
# These executables call into the libgdiagnostics.so API to emit diagnostics,
# sometimes in text form, and other times in SARIF form.
# Kludge alert:
@ -14,12 +14,12 @@
# which normally comes from the definition of
# ${tool}_maybe_build_wrapper within lib/wrapper.exp.
#
# However, for us, ${tool} is "libdiagnostics".
# However, for us, ${tool} is "libgdiagnostics".
# Hence we load wrapper.exp with tool == "g++", so that
# g++_maybe_build_wrapper is defined.
set tool g++
load_lib wrapper.exp
set tool libdiagnostics
set tool libgdiagnostics
load_lib dg.exp
load_lib prune.exp
@ -108,7 +108,7 @@ proc fixed_host_execute {args} {
}
# We don't do prune_gcc_output here, as we want
# to check *exactly* what we get from libdiagnostics
# to check *exactly* what we get from libgdiagnostics
return $exe_output
}
@ -128,7 +128,7 @@ dg-init
# Gather a list of all tests.
# C and C++ tests within the testsuite: gcc/testsuite/libdiagnostics.dg/test-*.{c,c++}
# C and C++ tests within the testsuite: gcc/testsuite/libgdiagnostics.dg/test-*.{c,c++}
set c_tests [find $srcdir/$subdir test-*.c]
set cxx_tests [find $srcdir/$subdir test-*.cc]
set tests [concat $c_tests $cxx_tests]
@ -168,8 +168,8 @@ proc dg-diagnostics-set-exe-params { args } {
}
}
proc libdiagnostics-dg-test { prog do_what extra_tool_flags } {
verbose "within libdiagnostics-dg-test..."
proc libgdiagnostics-dg-test { prog do_what extra_tool_flags } {
verbose "within libgdiagnostics-dg-test..."
verbose " prog: $prog"
verbose " do_what: $do_what"
verbose " extra_tool_flags: $extra_tool_flags"
@ -214,7 +214,7 @@ proc libdiagnostics-dg-test { prog do_what extra_tool_flags } {
set comp_output [$compilation_function $prog $output_file \
"executable" $options]
upvar 1 name name
if ![libdiagnostics_check_compile "$name" "initial compilation" \
if ![libgdiagnostics_check_compile "$name" "initial compilation" \
$output_file $comp_output] then {
return
}
@ -222,7 +222,7 @@ proc libdiagnostics-dg-test { prog do_what extra_tool_flags } {
# Run the test executable.
# We need to set LD_LIBRARY_PATH so that the test files can find
# libdiagnostics.so
# libgdiagnostics.so
# Do this using set_ld_library_path_env_vars from target-libpath.exp
# We will restore the old value later using
# restore_ld_library_path_env_vars.
@ -287,7 +287,7 @@ proc libdiagnostics-dg-test { prog do_what extra_tool_flags } {
return [list $exe_output $output_file]
}
set DEFAULT_CFLAGS "-I$srcdir/.. -ldiagnostics -g -Wall -Werror"
set DEFAULT_CFLAGS "-I$srcdir/.. -lgdiagnostics -g -Wall -Werror"
# Main loop. This will invoke jig-dg-test on each test-*.c file.
dg-runtest $tests "" $DEFAULT_CFLAGS

View file

@ -1,6 +1,6 @@
/* Usage example of dump API. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
const int line_num = 42;

View file

@ -9,7 +9,7 @@ PATH/test-error-with-note.c:18:11: note: have you looked behind the couch?
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -9,7 +9,7 @@ PATH/test-error-with-note.c:17:8: note: have you looked behind the couch?
along with the equivalent in SARIF. */
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
/*
_________111111111122
@ -21,7 +21,7 @@ const int line_num = __LINE__ - 2;
int
main ()
{
libdiagnostics::manager mgr;
libgdiagnostics::manager mgr;
auto file = mgr.new_file (__FILE__, "c");
@ -33,7 +33,7 @@ main ()
loc_start,
loc_end);
libdiagnostics::group g (mgr);
libgdiagnostics::group g (mgr);
auto err (mgr.begin_diagnostic (DIAGNOSTIC_LEVEL_ERROR));
err.set_location (loc_range);

View file

@ -8,7 +8,7 @@ PATH/test-error-with-note.c:6:11: error: can't find 'foo.h'
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -8,7 +8,7 @@ PATH/test-error.cc:16:8: error: can't find 'foo'
along with the equivalent in SARIF. */
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
/*
_________111111111122
@ -20,7 +20,7 @@ const int line_num = __LINE__ - 2;
int
main ()
{
libdiagnostics::manager mgr;
libgdiagnostics::manager mgr;
auto file = mgr.new_file (__FILE__, "c");
@ -32,7 +32,7 @@ main ()
loc_start,
loc_end);
libdiagnostics::diagnostic d (mgr.begin_diagnostic (DIAGNOSTIC_LEVEL_ERROR));
libgdiagnostics::diagnostic d (mgr.begin_diagnostic (DIAGNOSTIC_LEVEL_ERROR));
d.set_location (loc_range);
d.finish ("can't find %qs", "foo");

View file

@ -1,6 +1,6 @@
/* begin quoted source */
/* Minimal usage example. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
static diagnostic_manager *diag_mgr;

View file

@ -10,7 +10,7 @@ PATH/test-fix-it-hint.c:19:13: error: unknown field 'colour'; did you mean 'colo
along with the equivalent in SARIF, and a generated patch (on stderr) to
make the change. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -10,7 +10,7 @@ PATH/test-fix-it-hint.cc:19:13: error: unknown field 'colour'; did you mean 'col
along with the equivalent in SARIF, and a generated patch (on stderr) to
make the change. */
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
#include "test-helpers++.h"
/*
@ -23,7 +23,7 @@ const int line_num = __LINE__ - 2;
int
main ()
{
libdiagnostics::manager mgr;
libgdiagnostics::manager mgr;
auto file = mgr.new_file (__FILE__, "c");

View file

@ -3,7 +3,7 @@
#ifndef TEST_HELPERSPP_H
#define TEST_HELPERSPP_H
namespace libdiagnostics {
namespace libgdiagnostics {
inline physical_location
make_range (manager &mgr,
@ -23,6 +23,6 @@ make_range (manager &mgr,
loc_end);
}
} // namespace libdiagnostics
} // namespace libgdiagnostics
#endif /* #ifndef TEST_HELPERSPP_H */

View file

@ -10,7 +10,7 @@ PATH/test-labelled-ranges.c:9:6: error: mismatching types: 'int' and 'const char
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -10,7 +10,7 @@ PATH/test-labelled-ranges.cc:19:6: error: mismatching types: 'int' and 'const ch
along with the equivalent in SARIF. */
#include "libdiagnostics++.h"
#include "libgdiagnostics++.h"
#include "test-helpers++.h"
/*
@ -24,10 +24,10 @@ int
main ()
{
FILE *sarif_outfile;
libdiagnostics::manager mgr;
libgdiagnostics::manager mgr;
mgr.set_tool_name ("test-labelled-ranges.cc.exe");
libdiagnostics::file file = mgr.new_file (__FILE__, "c");
libgdiagnostics::file file = mgr.new_file (__FILE__, "c");
mgr.add_text_sink (stderr, DIAGNOSTIC_COLORIZE_IF_TTY);
sarif_outfile = fopen ("test-labelled-ranges.cc.sarif", "w");

View file

@ -9,7 +9,7 @@ PATH/test-error-with-note.c:18:8: error: can't find 'foo'
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/* Placeholder source:

View file

@ -9,7 +9,7 @@ PATH/test-metadata.c:21:3: warning: never use 'gets' [CWE-242] [STR34-C]
where the metadata tags are linkified in a sufficiently capable terminal,
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/* Placeholder source:

View file

@ -13,7 +13,7 @@
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/* Placeholder source (missing comma after "bar"):

View file

@ -7,7 +7,7 @@ PATH/test-error-with-note.c:6: error: can't find 'foo'
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -1,6 +1,6 @@
/* Test of the "no diagnostics are emitted" case. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
int

View file

@ -12,7 +12,7 @@
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/* Placeholder source:

View file

@ -2,7 +2,7 @@
with multiple text sinks,
and color output. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
/*
_________111111111122

View file

@ -6,7 +6,7 @@ TODO:
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -8,7 +8,7 @@
along with the equivalent in SARIF. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
#include "test-helpers.h"
/*

View file

@ -1,6 +1,6 @@
/* Example of writing diagnostics as SARIF to a file. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
/*
_________111111111122

View file

@ -1,7 +1,7 @@
/* Example of writing diagnostics in text form, but to a file,
rather than stderr. */
#include "libdiagnostics.h"
#include "libgdiagnostics.h"
/*
_________111111111122