summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ASTContext.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix the AST representation for non-type template arguments to encodeEli Friedman2012-09-261-3/+6
| | | | | | | | | | | | enough information so we can mangle them correctly in cases involving dependent parameter types. (This specifically impacts cases involving null pointers and cases involving parameters of reference type.) Fix the mangler to use this information instead of trying to scavenge it out of the parameter declaration. <rdar://problem/12296776>. llvm-svn: 164656
* Comment AST: TableGen'ize all command lists in CommentCommandTraits.cpp.Dmitri Gribenko2012-09-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now we have a list of all commands. This is a good thing in itself, but it also enables us to easily implement typo correction for command names. With this change we have objects that contain information about each command, so it makes sense to resolve command name just once during lexing (currently we store command names as strings and do a linear search every time some property value is needed). Thus comment token and AST nodes were changed to contain a command ID -- index into a tables of builtin and registered commands. Unknown commands are registered during parsing and thus are also uniformly assigned an ID. Using an ID instead of a StringRef is also a nice memory optimization since ID is a small integer that fits into a common bitfield in Comment class. This change implies that to get any information about a command (even a command name) we need a CommandTraits object to resolve the command ID to CommandInfo*. Currently a fresh temporary CommandTraits object is created whenever it is needed since it does not have any state. But with this change it has state -- new commands can be registered, so a CommandTraits object was added to ASTContext. Also, in libclang CXComment has to be expanded to include a CXTranslationUnit so that all functions working on comment AST nodes can get a CommandTraits object. This breaks binary compatibility of CXComment APIs. Now clang_FullComment_getAsXML(CXTranslationUnit TU, CXComment CXC) doesn't need TU parameter anymore, so it was removed. This is a source-incompatible change for this C API. llvm-svn: 163540
* Added missing const.Abramo Bagnara2012-09-091-1/+1
| | | | llvm-svn: 163477
* Fixed support for disabled wchar_t and added an appropriate test.Abramo Bagnara2012-09-091-2/+2
| | | | llvm-svn: 163476
* Change the representation of builtin functions in the ASTEli Friedman2012-08-311-0/+3
| | | | | | | | | (__builtin_* etc.) so that it isn't possible to take their address. Specifically, introduce a new type to represent a reference to a builtin function, and a new cast kind to convert it to a function pointer in the operand of a call. Fixes PR13195. llvm-svn: 162962
* objective-C: clang must implicitly convert Fariborz Jahanian2012-08-301-0/+1
| | | | | | | | | | | __objc_yes/__objc_no to (BOOL)1/(BOOL)0 when BOOL is declared; otherwise it resorts to default of 'signed char'. This is important to selecting the correct Numeric API numberWithBool: Can't have a clang test for this. Will checkin and executable llvm test. // rdar://12156616 llvm-svn: 162922
* Fix a crash in type merging with enum types.Eli Friedman2012-08-301-3/+6
| | | | llvm-svn: 162886
* Fix a -Wdocumentation warning.Dmitri Gribenko2012-08-281-3/+3
| | | | llvm-svn: 162730
* Attaching comments to decls: since it was decided that Decl::isImplicit shouldDmitri Gribenko2012-08-231-2/+0
| | | | | | | | | | | | not be set for implicit instantiations, remove the FIXME. This should be the last bit for PR13634. The actual fix happened in r162238. Motivation: it might be misleading to mark implicit instantiations as Decl::isImplicit = true. Because then, in order to be consistent, we should mark all instantiated members as implicit. But the user did actually type the declaration for the member, but the compiler played with it a little bit. llvm-svn: 162488
* ASTContext::getCommentForDecl: add comment.Dmitri Gribenko2012-08-221-0/+4
| | | | llvm-svn: 162374
* Attaching comments to declarations: when documentation is requested for anDmitri Gribenko2012-08-221-5/+62
| | | | | | implicit instantiation, look for documentation attached to the template. llvm-svn: 162371
* When performing a trivial copy of a C++ type, we must be careful notJohn McCall2012-08-211-0/+21
| | | | | | | | | | | to overwrite objects that might have been allocated into the type's tail padding. This patch is missing some potential optimizations where the destination is provably a complete object, but it's necessary for correctness. Patch by Jonathan Sauer. llvm-svn: 162254
* Attaching comments to declarations: ignore implicit decls. Decl::isImplicit()Dmitri Gribenko2012-08-201-0/+18
| | | | | | | | does not return true for all implicit decls currently. This should fix PR13634 for now, but Decl::isImplicit() should be fixed, too. llvm-svn: 162238
* Attaching comments to declarations: parse the comment in context of theDmitri Gribenko2012-08-161-3/+20
| | | | | | declaration it was attached to. llvm-svn: 162033
* Fix misaligned allocation of QualifiedTempateName and DependentTemplateName.Richard Smith2012-08-161-5/+10
| | | | llvm-svn: 162005
* Attaching comments to redeclarations: fix wrong assumptionsDmitri Gribenko2012-08-141-6/+26
| | | | | | | | | | | | | | | | | | The reason for the recent fallout for "attaching comments to any redeclaration" change are two false assumptions: (1) a RawComment is attached to a single decl (not true for 'typedef struct X *Y' where we want the comment to be attached to both X and Y); (2) the whole redeclaration chain has only a single comment (obviously false, the user can put a separate comment for each redeclaration). To fix (1) I revert the part of the recent change where a 'Decl*' member was introduced to RawComment. Now ASTContext has a separate DenseMap for mapping 'Decl*' to 'FullComment*'. To fix (2) I just removed the test with this assumption. We might not parse every comment in redecl chain if we already parsed at least one. llvm-svn: 161878
* Factor out computation of whether a typeid's expression is potentiallyRichard Smith2012-08-131-1/+1
| | | | | | evaluated into a CXXTypeid member function. No functionality change. llvm-svn: 161779
* When looking for the comment associated with a declaration, adjust theDouglas Gregor2012-08-131-0/+11
| | | | | | | | 'templated' declaration for a function or class template to refer to the function or class template itself, to which the documentation will be attached. Fixes PR13593. llvm-svn: 161762
* Attaching comments to declarations: find comment attached to any redeclarationDmitri Gribenko2012-08-111-43/+55
| | | | | | | | Not only look for the comment near the declaration itself, but also walk the redeclaration chain: the previous declaration might have had a documentation comment. llvm-svn: 161722
* Comment parsing: extract TableGen'able pieces into new CommandTraits class.Dmitri Gribenko2012-08-091-3/+6
| | | | llvm-svn: 161548
* Attaching comments to declarations: handle using-declaration.Dmitri Gribenko2012-08-021-2/+2
| | | | llvm-svn: 161211
* ASTContext.h: replace include by a forward declaration.Dmitri Gribenko2012-08-021-0/+1
| | | | llvm-svn: 161186
* Comment parsing: add support for \tparam command on all levels.Dmitri Gribenko2012-07-311-1/+10
| | | | | | | | | | 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
* Implement resolving of HTML character references (named: &amp;, decimal: &#42;,Dmitri Gribenko2012-07-271-1/+2
| | | | | | | | | hex: &#x1a;) during comment parsing. Now internal representation of plain text in comment AST does not contain character references, but the characters themselves. llvm-svn: 160891
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* Implement an optimization for finding the comment that occurs just after aDmitri Gribenko2012-07-171-6/+24
| | | | | | | | | | given declaration. It is based on the observation that during parsing the comment that should be attached to the decl is usually among the last two documentation comments parsed. llvm-svn: 160400
* Related to PR11848 and core-21989: switch ContainsUnexpandedParameterPack fromRichard Smith2012-07-161-4/+11
| | | | | | | | | being a property of a canonical type to being a property of the fully-sugared type. This should only make a difference in the case where an alias template ignores one of its parameters, and that parameter is an unexpanded parameter pack. llvm-svn: 160244
* Add a per target max vector alignment field (e.g., 32-byte alignment for x86 ↵Chad Rosier2012-07-131-0/+4
| | | | | | | | | | due to AVX). Currently, if no aligned attribute is specified the alignment of a vector is inferred from its size. Thus, very large vectors will be over-aligned with no benefit. Target owners should set this target max. llvm-svn: 160209
* Attaching comments to declarations during parsing: handle more Objective-C ↵Dmitri Gribenko2012-07-131-2/+14
| | | | | | declarations. llvm-svn: 160156
* [Windows] Use thiscall as the default calling convention for class methods. ↵Timur Iskhodzhanov2012-07-121-2/+8
| | | | | | PR12785 llvm-svn: 160121
* Enable comment parsing and semantic analysis to emit diagnostics. A fewDmitri Gribenko2012-07-111-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Restrict the set of declaration kinds for which we allow trailing comments.Dmitri Gribenko2012-07-061-1/+1
| | | | llvm-svn: 159878
* Don't store pointers into a std::vector (RawCommentList::Comments). AlthoughDmitri Gribenko2012-07-061-9/+10
| | | | | | | | currently we take address of std::vector's contents only after we finished adding all comments (so no reallocation can happen), this will change in future. llvm-svn: 159845
* Use C++ cast.Dmitri Gribenko2012-07-061-1/+2
| | | | llvm-svn: 159830
* ASTContext.cpp: Appease msvc to cast NULL to typed pointer, or msvc mistakes ↵NAKAMURA Takumi2012-07-061-1/+1
| | | | | | NULL as int. llvm-svn: 159818
* Implement AST classes for comments, a real parser for Doxygen comments and aDmitri Gribenko2012-07-061-4/+36
| | | | | | | | | | | | | | 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
* Remove get(V)BaseClassOffsetInBits, the CharUnit functions should be used ↵Benjamin Kramer2012-07-041-2/+2
| | | | | | | | instead. No functionality change. llvm-svn: 159719
* PR13189: va_list broken with precompiled headersMeador Inge2012-07-011-0/+14
| | | | | | | | | | 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
* blocks: fixes a crash when encoding block typeFariborz Jahanian2012-06-301-0/+2
| | | | | | | with argument type of size 0. // rdar://11777609 PR13229. llvm-svn: 159477
* objective-c IRGen: fixes a crash when method type is being mangledFariborz Jahanian2012-06-291-4/+4
| | | | | | when an argument type size is 0. // rdar://11777609, PR13229 llvm-svn: 159472
* Remove redundant check.Dmitri Gribenko2012-06-281-0/+2
| | | | llvm-svn: 159355
* Attaching comments to declarations: don't attach comments to implicit ↵Dmitri Gribenko2012-06-281-0/+4
| | | | | | declarations. llvm-svn: 159354
* Attaching documentation comments to declarations: don't attach a comment to ↵Dmitri Gribenko2012-06-271-2/+3
| | | | | | a declaration if there is a preprocessor directive between them. llvm-svn: 159305
* Implement a lexer for structured comments.Dmitri Gribenko2012-06-261-2/+2
| | | | llvm-svn: 159223
* VC9 does not like heterogenous compare function objects.Dmitri Gribenko2012-06-211-1/+1
| | | | llvm-svn: 158936
* Restructure how the driver communicates information about theJohn McCall2012-06-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Structured comment parsing, first step.Dmitri Gribenko2012-06-201-0/+102
| | | | | | | | | * 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
* Explicitly build __builtin_va_list.Meador Inge2012-06-161-8/+225
| | | | | | | The target specific __builtin_va_list types are now explicitly built instead of injecting strings into the preprocessor input. llvm-svn: 158592
* Documentation cleanup: eliminated Doxygen warnings by deleting a doc commentJames Dennett2012-06-151-8/+0
| | | | | | | on ASTContext::CreateTypeSourceInfo that duplicated information from the (more complete) version in ASTContext.h. llvm-svn: 158504
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-4/+4
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
OpenPOWER on IntegriCloud