The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this
breaks libclang binary compatibility, but should not be a problem since API is
so new.
This also fixes PR13372 as a side-effect.
llvm-svn: 161087
hex: ) during comment parsing.
Now internal representation of plain text in comment AST does not contain
character references, but the characters themselves.
llvm-svn: 160891
and became necessary with the change to require BindableMatchers
for binding.
Also fixes PR 13445: "hasSourceExpression only works for implicit casts".
llvm-svn: 160716
as per Chandler's request:
- introduces a new matcher base type BindableMatcher that
provides the bind() call
- makes all dynamic-cast matcher creation functions return
BindableMatchers; the special case about dynamic-cast
matchers is that the node they match on and the node
their child matchers match on are the same node, just
casted to a different type; thus, there is no ambiguity
on what bind() matches on; additionally, those are the
matchers that we name with nouns in the matcher language,
so it's easy for users to intuitively know which matchers
are bindable
To make this change possible, we got rid of a non-orthogonal
implementation of thisPointerType, which had an implicit
dynamic-cast matcher from CallExpr to CXXMemberCallExpr; as
alternative, we now provide a memberCall dynamic-cast matcher
and thisPointerType is a predicate on CXXMemberCallExpr.
Last, the ArgumentAdaptingMatcher is actually not required
for the implementation of makeDynCastAllOfComposite - this
simplification makes it more obvious where the bind() call
can be used based on the matcher creation function types.
llvm-svn: 160673
The assertion was wrong in case we have a verbatim block without a closing
command.
Also add tests for closing command name in a verbatim block, since now it can
be empty in such cases.
llvm-svn: 160568
One adds matchers for the various parts of a for loop (initializer, condition,
increment), as well as extending the hasBody matcher to work for while and
do-while loops. The second patch adds an isInteger matcher for types.
The third patch fixes a bug in allOf, where a few of the name chages
(AllOf --> allOf) had been missed.
All matchers come with unit tests.
Patches by Sam Panzer!
llvm-svn: 160115
diagnostics implemented -- see testcases.
I created a new TableGen file for comment diagnostics,
DiagnosticCommentKinds.td, because comment diagnostics don't logically
fit into AST diagnostics file. But I don't feel strongly about it.
This also implements support for self-closing HTML tags in comment
lexer and parser (for example, <br />).
In order to issue precise diagnostics CommentSema needs to know the
declaration the comment is attached to. There is no easy way to find a decl by
comment, so we match comments and decls in lockstep: after parsing one
declgroup we check if we have any new, not yet attached comments. If we do --
then we do the usual comment-finding process.
It is interesting that this automatically handles trailing comments.
We pick up not only comments that precede the declaration, but also
comments that *follow* the declaration -- thanks to the lookahead in
the lexer: after parsing the declgroup we've consumed the semicolon
and looked ahead through comments.
Added -Wdocumentation-html flag for semantic HTML errors to allow the user to
disable only HTML warnings (but not HTML parse errors, which we emit as
warnings in -Wdocumentation).
llvm-svn: 160078
very simple semantic analysis that just builds the AST; minor changes for lexer
to pick up source locations I didn't think about before.
Comments AST is modelled along the ideas of HTML AST: block and inline content.
* Block content is a paragraph or a command that has a paragraph as an argument
or verbatim command.
* Inline content is placed within some block. Inline content includes plain
text, inline commands and HTML as tag soup.
llvm-svn: 159790
used with classes that generate ASTConsumers; this allows decoupling
the ASTConsumer generation from the Frontend library (like, for example,
the MatchFinder in the upcoming ASTMatcher patch).
llvm-svn: 159760
The fundamental change is to put a CMakeLists.txt file in the unittest
directory, with a single test binary produced from it. This has several
advantages.
Among other fundamental advantages, we start to get the checking logic
for when a file is missing from the CMake build, and this caught one
missing file already! More fun details in the LLVM commit corresponding
to this one.
Note that the LLVM commit and this one most both be applied, or neither.
Sorry for any skew issues.
llvm-svn: 158910
match the LLVM implemenation. This also simplifies the name management
and splits the custom library management out from the unittest specific
management. It finally drops the dependency on parsing cmake arguments.
llvm-svn: 158894
express library-level dependencies within Clang.
This is no more verbose really, and plays nicer with the rest of the
CMake facilities. It should also have no change in functionality.
llvm-svn: 158888
That commit added a new library just to hold the RawCommentList. I've
started a discussion on the commit thread about whether that is really
meritted -- it certainly doesn't seem necessary at this stage.
However, the immediate problem is that the AST library has a hard
dependency on the Comment library, but the dependencies were set up
completely backward. In addition to the layering violation, this had an
unfortunate effect if scattering the Comments library dependency
throughout the build system, but inconsistently so -- several parts of
the CMake dependencies were missing and only showed up due to transitive
deps or the fact that the target wasn't being built by tho bots.
It turns out that the Comments library can't (currently) be a well
formed layer *below* the AST library either, as it has an API that
accepts an ASTContext. That parameter is currently unused, so maybe that
was a mistake?
Anyways, it really seems like this is logically part of the AST --
that's the whole point of the ASTContext providing access to it as far
as I can tell -- so I've merged it into the AST library to solve the
immediate layering violation problems and remove some of the churn from
our library dependencies.
llvm-svn: 158807
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang
llvm-svn: 158771
Fix RecursiveASTVisitor to visit CXXForRangeStmts accordingly to visit
implicit or explicit code.
The key bug that inspired this was the Visitor not visiting the range
initializer of such a loop, which is explicit code.
llvm-svn: 158395
first writing the changed files to a temporary location and then overwriting
the original files atomically.
Also adds a RewriterTestContext to aid unit testing rewrting logic in general.
llvm-svn: 157260
We don't create any declaration to mark the explicit instantiation of function
templates other than the instantiation itself, so visit that when traversing
the function template decl.
This is a temporary fix, pending the creation of a Decl node to represent the
explicit instantiation.
Patch by Daniel Jasper!
llvm-svn: 156522
* Work around build failures due to gcc 4.2 bugs.
* Remove BodyIndexer::TraverseCXXOperatorCallExpr, which was not being called
prior to this change, and whose presence disables a RecursiveASTVisitor
stack space optimization after this change.
llvm-svn: 155969
all instantiations of a template when we visit the canonical declaration of the
primary template, rather than trying to match them up to the partial
specialization from which they are instantiated. This fixes a bug where we
failed to visit instantiations of partial specializations of member templates of
class templates, and naturally extends to allow us to visit instantiations where
we have instantiated only a declaration.
llvm-svn: 155597
templates. In an implicit instantiation of a member class, any member
templates don't get instantiated, so the existing check which only visited
the instantiations of a defined template skipped these templates'
instantiations.
Since there is only a single declaration of a member template of a class
template specialization, just use that to determine whether to visit the
instantiations. This introduces a slight inconsistency in that we will
visit the instantiations of such templates whether or not they are
defined, but we never visit a declared-but-not-defined instantiation, so
this turns out to not matter.
Patch by Daniel Jasper!
llvm-svn: 155487
Provides an API to run clang tools (FrontendActions) as standalone tools,
or repeatedly in-memory in a process. This is useful for unit-testing,
map-reduce style applications, source transformation daemons or command line
tools.
The ability to run over multiple translation units with different command
line arguments enables building up refactoring tools that need to apply
transformations across translation unit boundaries.
See tools/clang-check/ClangCheck.cpp for an example.
llvm-svn: 154008
"#include MACRO(STUFF)".
-As an inclusion position for the included file, use the file location of the file where it
was included but *after* the macro expansions. We want the macro expansions to be considered
as before-in-translation-unit for everything in the included file.
-In the preprocessing record take into account that only inclusion directives can be encountered
as "out-of-order" (by comparing the start of the range which for inclusions is the hash location)
and use binary search if there is an extreme number of macro expansions in the include directive.
Fixes rdar://11111779
llvm-svn: 153527
the new Objective-C NSArray/NSDictionary/NSNumber literal syntax.
This introduces a new library, libEdit, which provides a new way to support
migration of code that improves on the original ARC migrator. We now believe
that most of its functionality can be refactored into the existing libraries,
and thus this new library may shortly disappear.
llvm-svn: 152141
Introduce PreprocessingRecord::rangeIntersectsConditionalDirective() which returns
true if a given range intersects with a conditional directive block.
llvm-svn: 152018