Commit Graph

44 Commits

Author SHA1 Message Date
Serge Pavlov 8323711b07 Make output of -ast-print a valid C++ code.
Output generated by option -ast-print looks like C/C++ code, and it
really is for plain C. For C++ the produced output was not valid C++
code, but the differences were small. With this change the output
is fixed and can be compiled. Tests are changed so that output produced
by -ast-print is compiled again with the same flags and both outputs are
compared.

Option -ast-print is extensively used in clang tests but it itself
was tested poorly, existing tests only checked that compiler did not
crash. There are unit tests in file DeclPrinterTest.cpp, but they test
only terse output mode.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286439 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-10 08:49:37 +00:00
Sergey Kalinichev 2c0b7d1511 [libclang] Visit TypeAliasTemplateDecl
This makes TypeAliasTemplateDecl accessible via LibClang and python bindings

Differential Revision: http://reviews.llvm.org/D13844


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253166 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-15 13:48:32 +00:00
Argyrios Kyrtzidis 04421f5043 [test/Index] Update libclang tests to use libclang for creating PCH files.
This is consistent and tests the primary configuration we want to test, libclang
creating and consuming PCH files.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244066 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-05 17:23:59 +00:00
Argyrios Kyrtzidis 03c39bf6c0 [libclang] Use same USR encoding for 'class' as 'struct'.
'class' and 'struct' can be used interchangebly for forward references.
Use the same encoding otherwise we may get into a weird situation where the USR for the same
declaration is different based on whether the definition of the tag reference is visible or not.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223632 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 08:48:33 +00:00
Argyrios Kyrtzidis ab1d30c042 [libclang] Function templates can be 'overloaded' by return type, so encode the return type in the USR
and handle DependentNameType in order to be able to distinguish them.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@223628 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-08 08:48:11 +00:00
Dmitri Gribenko 89a92d3570 Comment parsing: remove HTML attribute validation
Since the community says that a blacklist is not good enough, and I don't have
enough time now to implement a proper whitelist, let's just remove the
attribute validation.

But, nevertheless, we can still communicate in the generated XML if our parser
found an issue with the HTML.  But this bit is best-effort and is specifically
called out in the schema as such.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207712 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 21:54:30 +00:00
Dmitri Gribenko 07aed9621e Comment parsing: close a hole in CDATA escaping in XML output
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206886 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 12:34:52 +00:00
Dmitri Gribenko e36bbd1eec Comment parsing: in the generated XML file, mark HTML that is safe to pass
through to the output even if the input comment comes from an untrusted source

Attribute filtering is currently based on a blacklist, which right now includes
all event handler attributes (they contain JavaScipt code).  It should be
switched to a whitelist, but going over all of the HTML5 spec requires a
significant amount of time.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206882 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 10:59:13 +00:00
Dmitri Gribenko b29c030ef9 Comment parsing: attach comments to enums declared using the NS_ENUM macro
Previously we would only attach comments to the typedef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204942 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-27 16:40:51 +00:00
Benjamin Kramer c148531050 Pretty Printer: Print constexpr and ref qualifiers. Don't print return types on destructors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202181 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-25 18:49:49 +00:00
Benjamin Kramer 73db075cf6 Reapply "Pretty Printer: Fix printing of conversion operator decls and calls."
There were many additional tests that had the bad behavior baked in.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202174 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-25 18:03:55 +00:00
Alp Toker 2b01e1e26d Correct hyphenations in comments and assert messages
This patch tries to avoid unrelated changes other than fixing a few
hyphen-related ambiguities in nearby lines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196466 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-05 04:47:09 +00:00
Dmitri Gribenko 67799d6c2a Comment parsing tests: introduce a little more structure in testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195187 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 01:23:26 +00:00
Dmitri Gribenko 4dfe6b0823 Revert r195176, it is breaking buildbots for unclear reason
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195184 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 00:59:02 +00:00
Dmitri Gribenko ff453c293d Comment parsing tests: introduce a little more structure in testcase
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195176 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-20 00:15:58 +00:00
Dmitri Gribenko db4041648f Remove full path from CHECK line
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195147 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 19:29:32 +00:00
Dmitri Gribenko 122064b66d Documentation parsing: in HeaderDoc, \abstract is equivalent to \brief
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@195145 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-19 19:18:54 +00:00
Dmitri Gribenko f6785e3117 Documentation parsing: add support for \throws \throw \exception commands
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194521 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-12 22:16:08 +00:00
Dmitri Gribenko c31fbe34c9 Comment parsing: recognize \def (but processing is a no-op, like the rest of
similar commands that duplicate the declaration name)


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194312 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-09 03:50:37 +00:00
Dmitri Gribenko c3a064d4fb Comment parsing tests: move tests where they belong
Move C++-specific tests that were checking if we attach a base class comment to
a derived class to an existing test comment-to-html-xml-conversion.cpp.  Note
that the original testing approach was not actually testing the class--comment
relationship.  It only checked that we attached the comment *somewhere*.

The rest of subclass-comment.mm should be also moved elsewhere.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188658 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-19 07:13:02 +00:00
Fariborz Jahanian ceaa1ecfa3 Documentation parsing: if typedef name is being declared
via a macro, try using declaration's starting location.
This is improvement over not having a valid location and
dropping comment altogether. // rdar://14348912


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187085 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-24 22:58:51 +00:00
Dmitri Gribenko c5b0054693 Comment parsing: allow "\param ..." to describe variadic arguments
Original patch by Fariborz Jahanian; extended by me.

Fixes rdar://14124644


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184688 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-24 04:41:32 +00:00
Dmitri Gribenko 97e5bc2643 Comment parsing: followup to r184610: allow multiple \returns
Remove unneeded member in CommentSema, add a test for the XML schema (the
schema already allowed multiple paragraphs in <ResultDiscussion>, but there
were no tests for that), fix HTML generation (it is not allowed to have <p>
inside <dl>).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184652 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-22 23:03:37 +00:00
Fariborz Jahanian d52b20c706 [document parsing]: Allow multiple adjacent \return and the like
commands. Render them properly in XML output.
// rdar://14207725


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@184610 91177308-0d34-0410-b5e6-96231b3b80d8
2013-06-21 23:49:29 +00:00
Daniel Jasper 85b03eb9fe Fix test error caused by r183008.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183010 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-31 15:15:41 +00:00
Daniel Jasper 92b522db4e Fix test breakage caused by change in clang-format.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181888 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-15 14:27:33 +00:00
Evgeniy Stepanov c528aa2e23 Mark comment-to-html-xml-conversion test as XFAIL:msan, in addition to valgrind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178138 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-27 13:05:40 +00:00
Dmitri Gribenko af01bed59b Comment parsing: improve the fidelity of XML output for many block commands
This change introduces a 'kind' attribute for the <Para> tag, that captures the
kind of the parent block command.

For example:

\todo Meow.

used to be just <Para>Meow.</Para>, but now it is
<Para kind="todo">Meow.</Para>


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174216 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01 20:23:57 +00:00
Dmitri Gribenko f494e48140 Comment parsing: fold named character references test into other HTML tests
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173934 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 14:44:47 +00:00
NAKAMURA Takumi 614323cc1c clang/test/Index/comment-to-html-xml-conversion.cpp: Mark this as XFAIL:valgrind, for now. Working in progress.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173121 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-22 03:49:16 +00:00
Manuel Klimek 2f1ac41a6d Fixes formatting of empty blocks.
We now only put empty blocks into a single line, if all of:
- all tokens of the structural element fit into a single line
- we're not in a control flow statement

Note that we usually don't put record definitions into a single line, as
there's usually at least one more token (the semicolon) after the
closing brace. This doesn't hold when we are in a context where there is
no semicolon, like "enum E {}".

There were some missing tests around joining lines around the corner
cases of the allowed number of columns, so this patch adds some.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173055 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 16:42:44 +00:00
Daniel Jasper 032f253295 Fix parsing of templated declarations.
Before: template <template <typename T>, typename P > class X;
After:  template <template <typename T>, typename P> class X;

More importantly, the token annotations for the second ">" are now computed
correctly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173047 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-21 14:39:22 +00:00
Dmitri Gribenko 4918c53152 Actually update the test, fixup for r172923
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172925 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 22:11:28 +00:00
Dmitri Gribenko 44a3ddbf7d Comment parsing: add more tests for html character references
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172923 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 22:04:44 +00:00
Manuel Klimek 36fab8d70e Do not add newline in empty blocks.
void f() {}
now gets formatted in one line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172067 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 13:24:24 +00:00
Dmitri Gribenko 27c2cb24d5 Comment to XML conversion: no, we don't want to print instantiations for the
<Declaration> tag


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171763 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 18:45:48 +00:00
Manuel Klimek de7685487c Fix parsing of variable declarations directly after a class / struct.
Previous indent:
class A {
}
a;
void f() {
};

With this patch:
class A {
} a;
void f() {
}
;

The patch introduces a production for classes and structs, and parses
the rest of the line to the semicolon after the class scope.
This allowed us to remove a long-standing wart in the parser that would
just much the semicolon after any block.
Due to this suboptimal formating some tests were broken.

Some unrelated formatting tests broke; those hit a bug in the ast
printing, and need to be fixed separately.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171761 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 18:10:23 +00:00
Manuel Klimek d4397b99e2 Various fixes to clang-format's macro handling.
Some of this is still pretty rough (note the load of FIXMEs), but it is
strictly an improvement and fixes various bugs that were related to
macro processing but are also imporant in non-macro use cases.

Specific fixes:
- correctly puts espaced newlines at the end of the line
- fixes counting of white space before a token when escaped newlines are
  present
- fixes parsing of "trailing" tokens when eof() is hit
- puts macro parsing orthogonal to parsing other structure
- general support for parsing of macro definitions

Due to the fix to format trailing tokens, this change also includes a
bunch of fixes to the c-index tests.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171556 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-04 23:34:14 +00:00
Daniel Jasper 9a64fb5690 Prefer splitting after "template <...>" and fix indentation.
This addresses llvm.org/PR14699

Before:
template <typename T>
    void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T> void looooooooooooooooooooongFunction(
    int Paaaaaaaaaaaaaaaaaaaaram1, int Paaaaaaaaaaaaaaaaaaaaram2);

After:
template <typename T>
void looooooooooooooooooooooongFunction(int Param1, int Param2);
template <typename T>
void looooooooooooooooooooongFunction(int Paaaaaaaaaaaaaaaaaaaaram1,
                                      int Paaaaaaaaaaaaaaaaaaaaram2);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171388 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 15:08:56 +00:00
Daniel Jasper 9c10d61571 Temporary fix of tests to make buildbots happy.
Permanent solution coming up after checking back with Fariborz/Douglas.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170887 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 12:10:20 +00:00
Fariborz Jahanian 154120cde4 Add objective-C style formatting to clang format and
use it to format xml declaration tags. 
// rdar://12378714


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170727 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-20 19:54:13 +00:00
Fariborz Jahanian 02a2e5a1dd Testing C++ declarations embedded in
<declaration> tag of Comment XML.
Added DeclPrint support for constructors
and fix tests accordingly.
This is wip. // rdar://12378714


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169412 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 19:54:11 +00:00
Dmitri Gribenko e8b5db4f27 Comment to XML conversion test: correct filename.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168101 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 22:21:42 +00:00
Dmitri Gribenko 61322bc43b Split annotate-comments.cpp into a fragile (that uses hardcoded line numbers)
and a non-fragile (that uses [[@LINE]]) parts.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168098 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-15 22:03:13 +00:00