1 /* Automatic generation of links into GCC's documentation.
2 Copyright (C) 2023-2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
12 GCC is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef GCC_GCC_URLIFIER_H
22 #define GCC_GCC_URLIFIER_H
24 #include "pretty-print-urlifier.h"
25 #include "label-text.h"
27 extern std::unique_ptr
<urlifier
> make_gcc_urlifier (unsigned int lang_mask
);
28 extern char *make_doc_url (const char *doc_url_suffix
);
30 /* RAII class to temporarily override global_dc's urlifier
31 with another one (possibly nullptr). */
33 class auto_override_urlifier
36 auto_override_urlifier (urlifier
*new_urlifier
);
37 ~auto_override_urlifier ();
40 urlifier
* const m_old_urlifier
;
43 /* Subclass of urlifier that attempts to add URLs to quoted strings
44 containing names of attributes. */
46 class attribute_urlifier
: public urlifier
49 attribute_urlifier ();
50 attribute_urlifier (const char *target_docs_name
);
53 get_url_for_quoted_text (const char *p
, size_t sz
) const final override
;
56 get_url_suffix_for_quoted_text (const char *p
, size_t sz
) const;
58 /* We use ATTRIBUTE_UNUSED as this helper is called only from ASSERTs. */
60 get_url_suffix_for_quoted_text (const char *p
) const ATTRIBUTE_UNUSED
;
63 const char *m_target_docs_name
;
66 /* RAII class: during the lifetime of instances, global_dc will attempt
67 to auto-generate documentation links for any attributes mentioned in
68 quotes in diagnostics . */
70 class auto_urlify_attributes
73 auto_urlify_attributes ()
74 : m_override (&m_urlifier
)
79 attribute_urlifier m_urlifier
;
80 auto_override_urlifier m_override
;
83 #endif /* GCC_GCC_URLIFIER_H */