Commit Graph

4053 Commits

Author SHA1 Message Date
Dmitri Gribenko 767ea0ff4a CommentBriefParser: remove dead store. Found by Clang Analyzer.
llvm-svn: 159673
2012-07-03 18:10:20 +00:00
Abramo Bagnara b1cdde7d21 Reintroduced FieldDecl public methods setBitWidth and removeBitWidth.
llvm-svn: 159579
2012-07-02 20:35:48 +00:00
Dmitri Gribenko 3292d06a1b Add a new libclang completion API to get brief documentation comment that is
attached to a declaration in the completion string.

Since extracting comments isn't free, a new code completion option is
introduced.

A new code completion option that enables including brief comments
into CodeCompletionString should be a, err, code completion option.
But because ASTUnit caches global declarations during parsing before
even completion consumer is created, the option is duplicated as a
translation unit option (in both libclang and ASTUnit, like the option
to cache code completion results).

llvm-svn: 159539
2012-07-02 17:35:10 +00:00
Meador Inge cfb6090912 PR13189: va_list broken with precompiled headers
For some targets a structure named __va_list_tag is built to help define
the __builtin_va_list type.  However, __va_list_tag was not being treated as a
predefined type thus causing problems when serializing the AST.  This commit
fixes that oversight by adding the necessary support to treat __va_list_tag
as a predefined type.

llvm-svn: 159508
2012-07-01 15:57:25 +00:00
Jordan Rose 58d547200e Add support for the C11 _Alignof keyword.
This behaves like the existing GNU __alignof and C++11 alignof keywords;
most of the patch is simply adding the third token spelling to various places.

llvm-svn: 159494
2012-06-30 21:33:57 +00:00
Fariborz Jahanian d4879414f4 blocks: fixes a crash when encoding block type
with argument type of size 0. // rdar://11777609
PR13229.

llvm-svn: 159477
2012-06-30 00:48:59 +00:00
Fariborz Jahanian 271b8d43ce objective-c IRGen: fixes a crash when method type is being mangled
when an argument type size is 0. // rdar://11777609, PR13229

llvm-svn: 159472
2012-06-29 22:54:56 +00:00
Dmitri Gribenko 025d518e3e Factor out a check for block commands (that implicitly start a new paragraph) into a separate function.
llvm-svn: 159444
2012-06-29 18:19:20 +00:00
Axel Naumann 693344b505 From Philippe Canal:
Update the two function overloads
    void TemplateSpecializationType::PrintTemplateArgumentList(raw_ostream &OS,....
to behave like
    std::string TemplateSpecializationType::PrintTemplateArgumentList(const TemplateArgument *Args,...
hence making sure that clang consistently adds a space between two '>' at the end of nested template arguments.

llvm-svn: 159412
2012-06-29 07:30:33 +00:00
Dmitri Gribenko 5c8897d37d Remove redundant check.
llvm-svn: 159355
2012-06-28 16:25:36 +00:00
Dmitri Gribenko df17d64881 Attaching comments to declarations: don't attach comments to implicit declarations.
llvm-svn: 159354
2012-06-28 16:19:39 +00:00
Rafael Espindola ecbe2e9795 Fix another issue with devirtualizing calls to final methods by passing them
the correct this pointer. There is some potential for sharing a bit more
code with canDevirtualizeMemberFunctionCalls, but that can be done in an
independent patch.

llvm-svn: 159326
2012-06-28 01:56:38 +00:00
Dmitri Gribenko 0743f94671 Cleanup \brief comment. Since it is a single paragraph, no need to save newlines there.
llvm-svn: 159325
2012-06-28 01:38:21 +00:00
Dmitri Gribenko a1e9c8e783 Teach \brief parser about commands that start a new paragraph implicitly
llvm-svn: 159309
2012-06-28 00:01:41 +00:00
Dmitri Gribenko 7e8729b904 Attaching documentation comments to declarations: don't attach a comment to a declaration if there is a preprocessor directive between them.
llvm-svn: 159305
2012-06-27 23:43:37 +00:00
Dmitri Gribenko 632d58afab Fix an infinite loop in comment lexer: we were not advancing in the input character stream when we saw a '<' that is not a start of an HTML tag.
llvm-svn: 159303
2012-06-27 23:28:29 +00:00
Rafael Espindola b7f5a9c5cd Implement John McCall's review of r159212 other than the this pointer not
being updated. Will fix that in a second.

llvm-svn: 159280
2012-06-27 18:18:05 +00:00
Rafael Espindola a245edc82f Fix a crash I introduced in r159212.
llvm-svn: 159279
2012-06-27 17:44:39 +00:00
Dmitri Gribenko 1669f70273 Remove unsigned and a pointer from a comment token (so that each token can have only one semantic string value attached to it), at a cost of adding an additional token.
llvm-svn: 159270
2012-06-27 16:53:58 +00:00
Dmitri Gribenko 60ddd8a1b1 Comment lexer: counting backwards from token end is thought to be confusing. We already have a pointer to the beginning of the token, so use it to extract the text instead.
llvm-svn: 159269
2012-06-27 16:30:35 +00:00
Dmitri Gribenko 60c7ec699b Initialize RawComment::BriefTextValid in other constructor, too.
llvm-svn: 159253
2012-06-27 05:48:36 +00:00
Dmitri Gribenko 99e0942cd9 Simplify logic in BriefParser::Parse(), per Jordan's comment.
llvm-svn: 159247
2012-06-27 01:17:34 +00:00
Timur Iskhodzhanov 1b1d630e0c [Windows] Improve mangling of templates when back references are present
llvm-svn: 159234
2012-06-26 22:29:50 +00:00
Richard Smith b063d93cfb Remove typedef which is unused after r159189.
llvm-svn: 159224
2012-06-26 20:54:26 +00:00
Dmitri Gribenko 5188c4b9cc Implement a lexer for structured comments.
llvm-svn: 159223
2012-06-26 20:39:18 +00:00
David Blaikie 47e4518117 Remove spurious semicolons committed in r159216.
llvm-svn: 159218
2012-06-26 18:52:09 +00:00
Richard Trieu 9184423984 Add template type diffing to Clang. This feature will provide a better
comparison between two templated types when they both appear in a diagnostic.
Type elision will remove indentical template arguments, which can be disabled
with -fno-elide-type.  Cyan highlighting is applied to the differing types.

For more formatting, -fdiagnostic-show-template-tree will output the template
type as an indented text tree, with differences appearing inline. Template
tree works with or without type elision.

llvm-svn: 159216
2012-06-26 18:18:47 +00:00
Rafael Espindola 49e860b248 During codegen of a virtual call we would extract any casts in the expression
to see if we had an underlying final class or method, but we would then
use the cast type to do the call, resulting in a direct call to the wrong
method.

llvm-svn: 159212
2012-06-26 17:45:31 +00:00
Fariborz Jahanian 6362803cfe block literal irgen: several improvements on naming block
literal helper functions. All helper functions (global
and locals) use block_invoke as their prefix. Local literal
helper names are prefixed by their enclosing mangled function
names. Blocks in non-local initializers (e.g. a global variable 
or a C++11 field) are prefixed by their mangled variable name. 
The descriminator number added to end of the name starts off 
with blank (for first block) and _<N> (for the N+2-th block).

llvm-svn: 159206
2012-06-26 16:06:38 +00:00
Richard Smith 26d4cc1b96 Fix lifetime issue for backing APValue of OpaqueValueExpr in recursive
constexpr function evaluation, and corresponding ASan / valgrind issue in
tests, by storing the corresponding value with the relevant stack frame. This
also prevents re-evaluation of the source of the underlying OpaqueValueExpr,
which makes a major performance difference for certain contrived code (see
testcase update).

llvm-svn: 159189
2012-06-26 08:12:11 +00:00
Eli Friedman 4830ec8260 Use std::map instead of llvm::DenseMap because we rely on the stability of references to values in these maps. PR13197.
llvm-svn: 159161
2012-06-25 21:21:08 +00:00
Nico Weber 7b5a716f3d Make explicit specializations at class scope work
for non-type template parameters in microsoft mode.
PR12709.

llvm-svn: 159147
2012-06-25 17:21:05 +00:00
Nico Weber 3a691a367c Support L__FUNCTION__ in microsoft mode, PR11789
Heavily based on a patch from
Aaron Wishnick <aaron.s.wishnick@gmail.com>.

I'll clean up the duplicated function in CodeGen as
a follow-up, later today or tomorrow.

llvm-svn: 159060
2012-06-23 02:07:59 +00:00
Timur Iskhodzhanov 9137c399bd [Windows] Fix mangling of repeated types in the presence of bool and function pointers PR13176,PR13177
llvm-svn: 159059
2012-06-23 00:54:17 +00:00
Charles Davis de2e5ed4aa MicrosoftMangle: Fix mangling of integral constant non-type template arguments in a class specialization.
llvm-svn: 159056
2012-06-23 00:27:49 +00:00
Dmitri Gribenko 923074016b Handle include directive with comments. It turns out that in this case comments are not coming in source order. Instead of trying to std::sort() comments (which can be costly), just remove comments that are not in order.
llvm-svn: 158940
2012-06-21 22:04:37 +00:00
Dmitri Gribenko fecc2e0245 VC9 does not like heterogenous compare function objects.
llvm-svn: 158936
2012-06-21 21:02:45 +00:00
Richard Smith 73af5c6dda MS: Mangle rvalue references and nullptr_t, and produce back-references when
appropriate. Patch by João Matos!

llvm-svn: 158895
2012-06-21 02:52:27 +00:00
Chandler Carruth 28969b4139 Remove a goofy CMake hack and use the standard CMake facilities to
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
2012-06-21 01:30:21 +00:00
Dmitri Gribenko 7bedfda489 RawCommentList::addComment: fix the assertion so it actually checks that new comment is after the last one (change Comments[0] to Comments.back()), and handle the case of two consecutive comments, e.g. /** *//* */. There is already a testcase for that (but it didn't trigger the assert because the assert itself was wrong).
llvm-svn: 158882
2012-06-21 00:28:14 +00:00
John McCall 18ac1632f0 Introduce ObjCRuntime::hasWeakClassImport() and use it in the appropriate
places.  I've turned this off for the GNU runtimes --- I don't know if
they support weak class import, but it's easy enough for them to opt in.

Also tweak a comment per review by Jordan.

llvm-svn: 158860
2012-06-20 21:58:02 +00:00
Dmitri Gribenko 93b9ecba9b Remove unused ASTContext& arg in RawCommentList::addComment, as pointed out by Chandler in commit message for r158807.
llvm-svn: 158845
2012-06-20 20:39:04 +00:00
Chandler Carruth 39a3e7544a Fix a big layering violation introduced by r158771.
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
2012-06-20 09:53:52 +00:00
John McCall 5fb5df9c83 Restructure how the driver communicates information about the
target Objective-C runtime down to the frontend:  break this
down into a single target runtime kind and version, and compute
all the relevant information from that.  This makes it
relatively painless to add support for new runtimes to the
compiler.  Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z,
available at the driver level as a better and more general
alternative to -fgnu-runtime and -fnext-runtime.  This new
concept of an Objective-C runtime also encompasses what we
were previously separating out as the "Objective-C ABI", so
fragile vs. non-fragile runtimes are now really modelled as
different kinds of runtime, paving the way for better overall
differentiation.

As a sort of special case, continue to accept the -cc1 flag
-fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak.

I won't go so far as to say "no functionality change", even
ignoring the new driver flag, but subtle changes in driver
semantics are almost certainly not intended.

llvm-svn: 158793
2012-06-20 06:18:46 +00:00
Dmitri Gribenko aab8383a2b Structured comment parsing, first step.
* 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
2012-06-20 00:34:58 +00:00
Alexis Hunt 78e2b91319 Do not crash when we dynamic cast a final type to void*.
llvm-svn: 158763
2012-06-19 23:44:55 +00:00
Jakob Stoklund Olesen e1c0ae6fda Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

llvm-svn: 158749
2012-06-19 21:48:43 +00:00
Alexis Hunt 7b28cdb3da Improve the specification of spellings in Attr.td.
Note that this is mostly a structural patch that handles the change from the old
spelling style to the new one. One consequence of this is that all AT_foo_bar
enum values have changed to not be based off of the first spelling, but rather
off of the class name, so they are now AT_FooBar and the like (a straw poll on
IRC showed support for this). Apologies for code churn.

Most attributes have GNU spellings as a temporary solution until everything else
is sorted out (such as a Keyword spelling, which I intend to add if someone else
doesn't beat me to it). This is definitely a WIP.

I've also killed BaseCheckAttr since it was unused, and I had to go through
every attribute anyway.

llvm-svn: 158700
2012-06-19 03:39:03 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00