Commit Graph

85 Commits

Author SHA1 Message Date
Michal Gorny 0820041e1d [clang-tools-extra] [cmake] Link against libclang-cpp whenever possible
Use clang_target_link_libraries() in order to support linking against
libclang-cpp instead of static libraries.

Differential Revision: https://reviews.llvm.org/D68448

llvm-svn: 373786
2019-10-04 20:30:02 +00:00
Fangrui Song ff354de294 [clang-doc] sys::fs::F_None -> OF_None. NFC
F_None, F_Text and F_Append are kept for compatibility.

llvm-svn: 371394
2019-09-09 12:42:10 +00:00
Dmitri Gribenko 907452107d Changed FrontendActionFactory::create to return a std::unique_ptr
Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66947

llvm-svn: 370379
2019-08-29 16:38:36 +00:00
Fangrui Song 180380651c [clang-doc] Use llvm::createStringError and canonicalize error messages
"Bad block found.\n" -> "bad block found"

The lower cased form with no full stop or newline is more common in LLVM
tools.

Reviewed By: juliehockett

Differential Revision: https://reviews.llvm.org/D66783

llvm-svn: 370155
2019-08-28 02:56:03 +00:00
Julie Hockett 72e1f7f960 [clang-doc] Switch Generator::CreateResources to use llvm::Error
Differential Revision: https://reviews.llvm.org/D66502

llvm-svn: 369925
2019-08-26 16:39:48 +00:00
Julie Hockett 245154de50 [clang-doc] Bump BitcodeWriter max line number to 32U
PR43039 reports hitting the assert on a very large file, so bumping this
to allow for larger files.

Differential Revision: https://reviews.llvm.org/D66681

llvm-svn: 369811
2019-08-23 21:14:05 +00:00
Benjamin Kramer d5aecb9486 Retire llvm::less/equal in favor of C++14 std::less<>/equal_to<>.
llvm-svn: 369674
2019-08-22 17:31:59 +00:00
Dmitri Gribenko 282dc72c8b Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

  for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done

[This is analogous to LLVM r331272 and CFE r331834]

Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D66578

llvm-svn: 369643
2019-08-22 11:32:57 +00:00
Diego Astiazaran ee6700f697 [clang-doc] Fix casting not working in gcc 5.4.0
An implicit cast of std::string to llvm::SmallString<> was breaking GCC 5.4.0 builder.
A pair using llvm::SmallString<> now uses std::string.

Differential Revision: https://reviews.llvm.org/D66378

llvm-svn: 369182
2019-08-17 01:45:03 +00:00
Diego Astiazaran 3550da79ec [clang-doc] Redesign of generated HTML files
The new design includes a header (contains the project name), a main section, and a footer.
The main section is divided into three subsections. Left, middle, right. The left section contains the general index, the middle contains the info's data, and the right contains the index for the info's content.
The CSS has been updated.
A flag --project-name is added.
The Attributes attribute of the TagNode struct is now a vector of pairs because these attributes should be rendered in the insertion order.
The functions (cpp and js) that converts an Index tree structure into HTML were slightly modified; the first ul tag created is now a ol tag. The inner lists are still ul.

Differential Revision: https://reviews.llvm.org/D66353

llvm-svn: 369139
2019-08-16 18:38:11 +00:00
Diego Astiazaran b46131e5c3 [clang-doc] Fix records in global namespace
When a Record is declared in the global namespace, clang-doc serializes
it as a child of the global namespace, so the global namespace is now
one if its parent namespaces. This namespace was not being included in
the list of namespaces of the Info causing paths to be incorrect and the
index rendered incorrectly.
Affected tests have been fixed.

Differential revision: https://reviews.llvm.org/D66298

llvm-svn: 369123
2019-08-16 16:10:32 +00:00
Diego Astiazaran ba3d595f93 [clang-doc] Serialize inherited attributes and methods
clang-doc now serializes the inherited attributes and methods, not only the name of the base class.
All inherited are tracked, if B:A and C:B, info of A is included in C.
This data is stored in attribute Bases in a RecordInfo.
Previously tracked inheritance data, stored in Parents and VParents, hasn't been removed to reduce review load.

Differential revision: https://reviews.llvm.org/D66238

llvm-svn: 369075
2019-08-16 00:10:49 +00:00
Diego Astiazaran b7bb9fb28f [clang-doc] Sort index elements case insensitive
Implement logic to compare the references of the index case insensitive.

Differential revision: https://reviews.llvm.org/D66299

llvm-svn: 369068
2019-08-15 23:32:12 +00:00
Diego Astiazaran 77dc05b945 [clang-doc] Fix use of source-root flag
The value, if any, of --source-root flag was not being used.
This has been fixed and the logic was moved to the ClangDocContext
contructor.

Differential revision: https://reviews.llvm.org/D66268

llvm-svn: 369065
2019-08-15 23:20:42 +00:00
Diego Astiazaran 6a29ae4bde [clang-doc] Fix bitcode writer for access specifiers
Bitcode writer was not emitting the corresponding record for the Access attribute of a FunctionInfo. This has been added.
AS_none was being used as the default value for any AcesssSpecifier attribute
(in FunctionInfo and MemberTypeInfo), this has been changed to AS_public
because this is the enum value that evaluates to 0.
The bitcode writer doesn't write values that are 0 so if an attribute
was set to AS_public, this value is not written and after reading the
bitcode it would have the default value which is AS_none. This is why
the default value is now AS_public.

Differential Revision: https://reviews.llvm.org/D66151

llvm-svn: 369063
2019-08-15 23:04:27 +00:00
Jonas Devlieghere 1c705d9c53 [clang-tools-extra] Migrate llvm::make_unique to std::make_unique
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368944
2019-08-14 23:52:23 +00:00
Diego Astiazaran 6169a73088 [clang-doc] Add missing check in tests
Path is now checked when comparing two Infos in the unit tests.

Differential Revision: https://reviews.llvm.org/D66124

llvm-svn: 368912
2019-08-14 20:19:33 +00:00
Diego Astiazaran e27f778a19 [clang-doc] Generate HTML links for children namespaces/records
Path is now stored in the references to the child while serializing,
then this path is used to generate the relative path in the HTML
generator.
Now some references have paths and some don't so in the reducing phase,
references are now properly merged checking for empty attributes.
Tests added for HTML and YAML generators, merging and serializing.
computeRelativePath function had a bug when the filepath is part of the
given directory; it returned a path that starts with a separator. This
has been fixed.

Differential Revision: https://reviews.llvm.org/D65987

llvm-svn: 368602
2019-08-12 18:42:46 +00:00
Diego Astiazaran dc30049cb3 [clang-doc] Generate an HTML index file
clang-doc now generates a file that contains only an index to all the
infos that can be used as the landing page for the generated website.

Differential Revision: https://reviews.llvm.org/D65918

llvm-svn: 368484
2019-08-09 20:52:28 +00:00
Diego Astiazaran 665e9676c2 [clang-format] Add link to source code in file definitions
Two command line options have been added to clang-doc.
  --repository=<string>       - URL of repository that hosts code; used for links to definition locations.
  --source-root=<string>      - Directory where processed files are stored. Links to definition locations will only be generated if the file is in this dir.

If the file is in the source-root and a repository options is passed;
a link to the source code will be rendered by the HTML generator.

Differential Revision: https://reviews.llvm.org/D65483

llvm-svn: 368460
2019-08-09 17:49:41 +00:00
Diego Astiazaran e2d4577075 [clang-doc] Protect Index with mutex during reducing and generation stage
Idx in ClangDocContext instance was being modified by multiple threads
causing a seg fault.
A mutex is added to avoid this.

Differential Revision: https://reviews.llvm.org/D65915

llvm-svn: 368313
2019-08-08 17:14:17 +00:00
Diego Astiazaran d47be4da5a [clang-doc] Add second index for sections within info's content
This new index contains links to the main section of infos: Namespaces, Records, Functions, Enums, Members.
Also to each child function or enum.
Index is currently rendered on top of the info content, this will be fixed later with CSS.

Depends on D65690.

Differential Revision: https://reviews.llvm.org/D65030

llvm-svn: 368209
2019-08-07 21:04:52 +00:00
Diego Astiazaran 6ab28e8cba [clang-doc] Parallelize reducing phase
Reduce phase has been parallelized and a execution time was reduced by
60% with this.
The reading of bitcode (bitcode -> Info) was moved to this segment of
code parallelized so it now happens just before reducing.

Differential Revision: https://reviews.llvm.org/D65628

llvm-svn: 368206
2019-08-07 20:54:26 +00:00
Diego Astiazaran 40fde90193 [clang-doc] Fix paths of js in import tags
HTML requires posix-style paths.

Differential Revision: https://reviews.llvm.org/D65827

llvm-svn: 368087
2019-08-06 20:59:14 +00:00
Diego Astiazaran 7dfe0bc3c1 [clang-doc] Add index in each info html file
An index structure is created while generating the output file for each
info. This structure is parsed to JSON and written to a file in the
output directory. The html for the index is not rendered by clang-doc. A
Javascript file is included in the output directory, this will the JSON
file and insert HTML elements into the file.

Differential Revision: https://reviews.llvm.org/D65690

llvm-svn: 368070
2019-08-06 18:31:46 +00:00
Diego Astiazaran 15e468e0d5 [clang-doc] Fix link generation
Before making a link to a reference it is required to check that the
reference has a path (eg. primitives won't have paths).
This was done by checking if the path was empty; that worked because
when generating paths the outdirectory was included, so if the path was
assigned it had that outdirectory at least.
The path generation was changed, it's now only the composite of the
namespaces without the outdirectory. So if the info is in the global
namespace the path would be empty and the old check wouldn't work as expected.
A new attribute has been added to the Reference struct that indicates if
the info's parent is the global namespace.
Paths generation now fails if the path is empty and if the info
is not in the global namespace.

Differential Revision: https://reviews.llvm.org/D64958

llvm-svn: 367958
2019-08-06 00:11:34 +00:00
Fangrui Song d9b948b6eb Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFC
F_{None,Text,Append} are kept for compatibility since r334221.

llvm-svn: 367800
2019-08-05 05:43:48 +00:00
Diego Astiazaran 8fb7074d3b [clang-doc] Add flag to continue after mapping errors
The tool used to stop execution if there was an error in the mapping
phase. It will now show the error but continue with the files that were
mapped correctly if the flag is true.

Differential revision: https://reviews.llvm.org/D65627

llvm-svn: 367729
2019-08-02 22:02:36 +00:00
Diego Astiazaran 6ad2151b59 [clang-doc] Fix failing tests on Windows
Tests on Windows were failing due to path separator differences.
Links in HTML should use posix-style paths.

Differential Revision: https://reviews.llvm.org/D65419

llvm-svn: 367264
2019-07-29 22:03:39 +00:00
Diego Astiazaran d6cdd98a25 [clang-format] Fix style of css file paths
CSS files included in HTML should have a path in posix style, it should
not be different for Windows.

Differential Revision: https://reviews.llvm.org/D65309

llvm-svn: 367137
2019-07-26 18:02:42 +00:00
Diego Astiazaran acd35f6c5e [clang-doc] Add option for user provided stylesheets
An option has been added to clang-doc to provide a list of css stylesheets that the user wants to use for the generated html docs.

Depends on D64539.

Differential Revision: https://reviews.llvm.org/D64938

llvm-svn: 367072
2019-07-25 22:46:40 +00:00
Diego Astiazaran db5d8e3db2 [clang-doc] Add stylesheet to generated html docs
A default css stylesheet is included for docs generated in html format.

Differential Revision: https://reviews.llvm.org/D64539

llvm-svn: 367056
2019-07-25 21:27:50 +00:00
Diego Astiazaran 64ca857004 [clang-doc] Fix output format of html
The children of a TagNode are rendered in the same line as the parent only if they are all TextNodes.
When children are not inline; two text nodes that are adjacent won't have a new line between them, each tag node is rendered in its own line.

Differential Revision: https://reviews.llvm.org/D65005

llvm-svn: 367050
2019-07-25 20:49:00 +00:00
Diego Astiazaran 597b3fd3a8 [clang-doc] Fix html entities in rendered text
Replace &, <, >, ", and ' with their corresponding html entities in text rendered
by HTML generator.

Differential Revision: https://reviews.llvm.org/D65107

llvm-svn: 367045
2019-07-25 20:14:45 +00:00
Julie Hockett 2c1c9a2407 [clang-doc] Add html links to references
<a> tags are added for the parents and members of records and return type and
params of functions. The link redirects to the reference's info file.

The directory path where each info file will be saved is now generated in the
serialization phase and stored as an attribute in each Info.

Bitcode writer and reader were modified to handle the new attributes.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

Differential Revision: https://reviews.llvm.org/D63663

llvm-svn: 365937
2019-07-12 18:32:00 +00:00
Mikael Holmen c593f5e671 [clang-doc] Silence compiler warning with gcc 7.4 [NFC]
Without the fix gcc 7.4.0 complains with

/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'llvm::SmallString<16> clang::doc::{anonymous}::HTMLTag::ToString() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:165:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'bool clang::doc::{anonymous}::HTMLTag::HasInlineChildren() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:142:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp: In member function 'bool clang::doc::{anonymous}::HTMLTag::IsSelfClosing() const':
/data/repo/master/clang-tools-extra/clang-doc/HTMLGenerator.cpp:126:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
cc1plus: all warnings being treated as errors

llvm-svn: 365736
2019-07-11 06:50:10 +00:00
Julie Hockett 671bac7436 [clang-doc] Add a structured HTML generator
Implements an HTML generator.
Nodes are used to represent each part of the HTML file. There are TagNodes that
represent every HTML tag (p, h1, div, ...) and they have children nodes, which
can be TagNodes or TextNodes (these nodes only have text).
Proper indentation is rendered within the files generated by tool.
No styling (CSS) is included.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com)

Differential Revision: https://reviews.llvm.org/D63857

llvm-svn: 365687
2019-07-10 19:03:25 +00:00
Bjorn Pettersson 009225374a Bitstream reader: Fix undefined behavior seen after rL364464
Summary:
After rL364464 the following tests started to fail when
running the clang-doc tests with an ubsan instrumented
build of clang-doc:
    Clang Tools :: clang-doc/single-file-public.cpp
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode
    Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode

We need to check that the read value is in range for being
casted to the llvm::bitc::FixedAbbrevIDs enum, before the
cast in ClangDocBitcodeReader::skipUntilRecordOrBlock.

SerializedDiagnosticReader::skipUntilRecordOrBlock was updated
in the same way.

Reviewers: jfb

Reviewed By: jfb

Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64262

llvm-svn: 365239
2019-07-05 20:22:40 +00:00
Francis Visoiu Mistrih e0308279cb [Bitcode] Move Bitstream to a separate library
This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

Differential Revision: https://reviews.llvm.org/D63899

llvm-svn: 365091
2019-07-03 22:40:07 +00:00
Julie Hockett 097aedc9d9 [clang-doc] Serialize child namespaces and records
Serialization of child namespaces and records is now handled.
Namespaces can have child records and child namespaces.
Records can only have child records.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

Differential Revision: https://reviews.llvm.org/D63911

llvm-svn: 364963
2019-07-02 19:59:56 +00:00
Julie Hockett d42f22997e [clang-doc] Fix segfault in comment sorting
Differential Revision: https://reviews.llvm.org/D63962

llvm-svn: 364949
2019-07-02 17:57:11 +00:00
Julie Hockett d900ef0a5b [clang-doc] Handle anonymous namespaces
Improves output for anonymous decls, and updates the '--public' flag to exclude everything under an anonymous namespace.

Differential Revision: https://reviews.llvm.org/D52847

llvm-svn: 364674
2019-06-28 19:07:56 +00:00
Julie Hockett 93a290fdc9 [clang-doc] De-duplicate comments and locations
De-duplicate comments and declaration locations in reduce function.
When two files include the same header file, this file's content is mapped
twice causing comments and locations to be duplicated after the reduce stage.

Committed on behalf of Diego Astiazarán (diegoaat97@gmail.com).

Differential Revision: https://reviews.llvm.org/D62970

llvm-svn: 364670
2019-06-28 18:17:58 +00:00
JF Bastien 0e82895826 BitStream reader: propagate errors
The bitstream reader handles errors poorly. This has two effects:

 * Bugs in file handling (especially modules) manifest as an "unexpected end of
   file" crash
 * Users of clang as a library end up aborting because the code unconditionally
   calls `report_fatal_error`

The bitstream reader should be more resilient and return Expected / Error as
soon as an error is encountered, not way late like it does now. This patch
starts doing so and adopting the error handling where I think it makes sense.
There's plenty more to do: this patch propagates errors to be minimally useful,
and follow-ups will propagate them further and improve diagnostics.

https://bugs.llvm.org/show_bug.cgi?id=42311
<rdar://problem/33159405>

Differential Revision: https://reviews.llvm.org/D63518

llvm-svn: 364464
2019-06-26 19:50:12 +00:00
Julie Hockett b1f01e27ec [clang-doc] Add basic support for templates and typedef
In serialize::parseBases(...), when a base record is a template
specialization, the specialization was used as the parent. It should be
the base template so there is only one file generated for this record.
When the specialized template is implicitly declared the reference USR
corresponded to the GlobalNamespace's USR, this will now be the base
template's USR.

More information about templates will be added later.

In serialize::emiInfo(RecorDecl*, ...), typedef records were not handled
and the name was empty. This is now handled and a IsTypeDef attribute is
added to RecordInfo struct.

In serialize::emitInfo(CXXMethodDecl*, ...), template specialization is
handled like in serialize::parseBases(...).

Bitcode writer and reader are modified to handle the new attribute of
RecordInfo.

Submitted on behalf of Diego Astiazarán (diegoaat97@gmail.com)
Differential Revision: https://reviews.llvm.org/D63367

llvm-svn: 364222
2019-06-24 19:31:02 +00:00
Julie Hockett f64d4ec9be [clang-doc] Build as clang_tool
Instead of as clang_executable.

Differential Revision: https://reviews.llvm.org/D59974

llvm-svn: 357274
2019-03-29 16:56:36 +00:00
Fangrui Song ffe9f00cfe Fix file headers. NFC
llvm-svn: 355188
2019-03-01 09:52:53 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
to reflect the new license.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351636
2019-01-19 08:50:56 +00:00
Julie Hockett 9e22b4c76d [clang-doc] Switch to default to all-TUs executor
Since we generally want to document a whole project, not just one file.

Differential Revision: https://reviews.llvm.org/D53170

llvm-svn: 345418
2018-10-26 19:11:34 +00:00
Julie Hockett 229c63b021 [clang-doc] Limit integration tests
Now that the clang-doc libraries are covered by unit tests, we don't
need to have extensive (and unmaintainable) integration tests. This
replaces the integration test suite with a smaller one that just tests
the tool itself and removes extraneous dumping logic from the tool
itself.

Includes tests that cover the parse->serialize->merge->generate
pipeline, as well as tests for the --public, --format, --doxygen, and
--output flags.

Differential Revision: https://reviews.llvm.org/D53150

llvm-svn: 344655
2018-10-16 23:07:37 +00:00