libabigail/include/abg-reader.h
Dodji Seketeli 717fd0a460 Separate public types of first binary from those of the second
In abidiff when the user uses --headers-dir{1,2}, she implicitly
indicates the public types of the first and the second binary.  That
means that any type that is defined in a file that is not located
under the directory tree designated by --headers-dir{1,2} is
considered private and any change involving those private types will
be suppressed.

In practice, what happens is that libabigail constructs a suppression
specification which suppress all types that are defined in files that
are not under the directories located by --headers-dir{1,2}.

abidiff has a problem, though.  It uses the same private type
suppressions (derived from --headers-dir1 and --headers-dir2) when
looking at the first binary *and* the second binary.  It should rather
only use the private type suppression specifications derived from
--headers-dir1 when looking at the first binary, and use the private
type suppression specifications derived from --headers-dir2 when
looking at the second binary.

This problem leads to some false positives like the one reported at
https://gitlab.gnome.org/GNOME/pango/issues/343#note_397761.

This patch fixes this issue by using the private type suppression
specifications derived from --headers-dir1 only when looking at the
first binary, and using the private type suppression specifications
derived from --headers-dir2 only when looking at the second binary.

	* include/abg-dwarf-reader.h (read_context_get_path): Declare new
	function.
	* include/abg-reader.h (read_context_get_path): Likewise.
	* src/abg-dwarf-reader.cc (read_context_get_path): Define new function.
	* src/abg-reader.cc (read_context_get_path): Likewise.
	* tools/abidiff.cc (set_suppressions): Set the suppression
	specification derived from the --headers-dir1 option only for the first
	binary, and similarly, from the --headers-dir2 option only for the
	second binary.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2019-01-16 12:27:45 +01:00

110 lines
2.8 KiB
C++

// -*- Mode: C++ -*-
//
// Copyright (C) 2013-2019 Red Hat, Inc.
//
// This file is part of the GNU Application Binary Interface Generic
// Analysis and Instrumentation Library (libabigail). This library is
// free software; you can redistribute it and/or modify it under the
// terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3, or (at your option) any
// later version.
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details.
// You should have received a copy of the GNU Lesser General Public
// License along with this program; see the file COPYING-LGPLV3. If
// not, see <http://www.gnu.org/licenses/>.
//
// Author: Dodji Seketeli
/// @file
///
/// This file contains the declarations of the entry points to
/// de-serialize an instance of @ref abigail::translation_unit from an
/// ABI Instrumentation file in libabigail native XML format.
#ifndef __ABG_READER_H__
#define __ABG_READER_H__
#include <istream>
#include "abg-corpus.h"
#include "abg-suppression.h"
namespace abigail
{
namespace xml_reader
{
using namespace abigail::ir;
translation_unit_sptr
read_translation_unit_from_file(const std::string& file_path,
environment* env);
translation_unit_sptr
read_translation_unit_from_buffer(const std::string& file_path,
environment* env);
translation_unit_sptr
read_translation_unit_from_istream(std::istream* in,
environment* env);
class read_context;
/// A convenience typedef for a shared pointer to read_context.
typedef shared_ptr<read_context> read_context_sptr;
read_context_sptr
create_native_xml_read_context(const string& path, environment *env);
read_context_sptr
create_native_xml_read_context(std::istream* in, environment* env);
const string&
read_context_get_path(const read_context&);
abigail::corpus_sptr
read_corpus_from_file(const string& path);
int
read_corpus_from_file(corpus_sptr& corp,
const string& path);
int
read_corpus_from_file(corpus_sptr& corp);
corpus_sptr
read_corpus_from_native_xml(std::istream* in,
environment* env);
corpus_sptr
read_corpus_from_native_xml_file(const string& path,
environment* env);
corpus_sptr
read_corpus_from_input(read_context& ctxt);
corpus_group_sptr
read_corpus_group_from_input(read_context& ctxt);
corpus_group_sptr
read_corpus_group_from_native_xml(std::istream* in,
environment* env);
corpus_group_sptr
read_corpus_group_from_native_xml_file(const string& path,
environment* env);
void
add_read_context_suppressions(read_context& ctxt,
const suppr::suppressions_type& supprs);
}//end xml_reader
}//end namespace abigail
#endif // __ABG_READER_H__