summaryrefslogtreecommitdiff
path: root/lib/AST/DeclarationName.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Use getOperatorSpelling to get the spelling of an overloaded operatorRichard Smith2019-06-141-7/+1
| | | | | | rather than duplicating operator name tables in multiple places. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363446 91177308-0d34-0410-b5e6-96231b3b80d8
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Various optimizations + refactoring in DeclarationName(Table)Bruno Ricci2018-09-211-198/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce the following optimizations in DeclarationName(Table): 1. Store common kinds inline in DeclarationName instead of DeclarationNameExtra. Currently the kind of C++ constructor, destructor, conversion function and overloaded operator names is stored in DeclarationNameExtra. Instead store it inline in DeclarationName. To do this align IdentifierInfo, CXXSpecialName, DeclarationNameExtra and CXXOperatorIdName to 8 bytes so that we can use the lower 3 bits of DeclarationName::Ptr. This is already the case on 64 bits archs anyway. This also allow us to remove DeclarationNameExtra from CXXSpecialName and CXXOperatorIdName, which shave off a pointer from CXXSpecialName. 2. Synchronize the enumerations DeclarationName::NameKind, DeclarationName::StoredNameKind and Selector::IdentifierInfoFlag. This makes DeclarationName::getNameKind much more efficient since we can replace the switch table by a single comparison and an addition. 3. Put the overloaded operator names inline in DeclarationNameTable to remove an indirection. This increase the size of DeclarationNameTable a little bit but this is not important since it is only used in ASTContext, and never copied nor moved from. This also get rid of the last dynamic allocation in DeclarationNameTable. Altogether these optimizations cut the run time of parsing all of Boost by about 0.8%. While we are at it, do the following NFC modifications: 1. Put the internal classes CXXSpecialName, CXXDeductionGuideNameExtra, CXXOperatorIdName, CXXLiteralOperatorIdName and DeclarationNameExtra in a namespace detail since these classes are only meant to be used by DeclarationName and DeclarationNameTable. Make this more explicit by making the members of these classes private and friending DeclarationName(Table). 2. Make DeclarationName::getFETokenInfo a non-template since every users are using it to get a void *. It was supposed to be used with a type to avoid a subsequent static_cast. 3. Change the internal functions DeclarationName::getAs* to castAs* since when we use them we already know the correct kind. This has no external impact since all of these are private. Reviewed By: erichkeane, rjmccall Differential Revision: https://reviews.llvm.org/D52267 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342729 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Remove unnecessary indirections in DeclarationNameTableBruno Ricci2018-08-061-103/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DeclarationNameTable currently hold 3 "void *" to FoldingSet<CXXSpecialName>, FoldingSet<CXXLiteralOperatorIdName> and FoldingSet<CXXDeductionGuideNameExtra>. CXXSpecialName, CXXLiteralOperatorIdName and CXXDeductionGuideNameExtra are private classes holding extra information about a "special" declaration name and are in AST/DeclarationName.cpp. The original intent seems to have been to keep these classes private and only expose DeclarationNameExtra and DeclarationName (the code dates from 2008 and has not been significantly changed since). However this make the code less straightforward than necessary because of the need to have "void *" in DeclarationNameTable (with 1 of 3 comments wrong) and to manually allocate/deallocate the FoldingSets. Moreover removing the extra indirections reduce the run-time of an fsyntax-only on all of Boost by 2.3% which is not totally unexpected given how frequently this data structure is used (especially for C++). A concern raised by erichkeane during the review was that including Type.h would increase the compile time unreasonably. However test builds (both clean and incremental) showed that this patch did not result in any compile time increase. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D50261 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@339030 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid returning an invalid end source locStephen Kelly2018-07-301-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338301 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove trailing spaceFangrui Song2018-07-301-7/+7
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338291 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Fix some Clang-tidy modernize and Include What You Use warnings; other ↵Eugene Zelenko2017-11-211-4/+23
| | | | | | minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318813 91177308-0d34-0410-b5e6-96231b3b80d8
* [ASTPrinter] Print nested name specifiers for out-of-line functionsAlex Lorenz2017-04-111-1/+3
| | | | | | | rdar://31501863 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299962 91177308-0d34-0410-b5e6-96231b3b80d8
* P0091R3: Improved syntactic checking of deduction-guides.Richard Smith2017-02-081-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294395 91177308-0d34-0410-b5e6-96231b3b80d8
* P0091R3: Implement basic parsing support for C++17 deduction-guides.Richard Smith2017-02-071-7/+91
| | | | | | | | | | | | We model deduction-guides as functions with a new kind of name that identifies the template whose deduction they guide; the bulk of this patch is adding the new name kind. This gives us a clean way to attach an extensible list of guides to a class template in a way that doesn't require any special handling in AST files etc (and we're going to need these functions we come to performing deduction). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294266 91177308-0d34-0410-b5e6-96231b3b80d8
* ObjC Module: try to make objc module deterministic.Manman Ren2016-11-171-2/+8
| | | | | | | | Make sure that comparing selectors in DeclarationName does its job. rdar://problem/28988750 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@287244 91177308-0d34-0410-b5e6-96231b3b80d8
* [NFC] Header cleanupMehdi Amini2016-07-181-2/+1
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@275882 91177308-0d34-0410-b5e6-96231b3b80d8
* Make Sema::getPrintingPolicy less ridiculously expensive. This used to performRichard Smith2016-05-191-18/+9
| | | | | | | | | | | an identifier table lookup, *and* copy the LangOptions (including various std::vector<std::string>s). Twice. We call this function once each time we start parsing a declaration specifier sequence, and once for each call to Sema::Diag. This reduces the compile time for a sample .c file from the linux kernel by 20%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270009 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST/index] Introduce an option 'SuppressTemplateArgsInCXXConstructors' in ↵Argyrios Kyrtzidis2016-02-151-1/+7
| | | | | | | | | | printing policy. Enable it for USRs and names when indexing. Forward references can have different template argument names; including them makes USRs and names unstable, since the name depends on whether we saw a forward reference or not. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260866 91177308-0d34-0410-b5e6-96231b3b80d8
* [AST] Add a print() method in DeclarationName that accepts a PrintingPolicy.Argyrios Kyrtzidis2016-02-131-26/+50
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260833 91177308-0d34-0410-b5e6-96231b3b80d8
* Annotate dump() methods with LLVM_DUMP_METHOD, addressing Richard Smith ↵Yaron Keren2016-01-291-1/+1
| | | | | | r259192 post commit comment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@259232 91177308-0d34-0410-b5e6-96231b3b80d8
* When pretty-printing a C++11 literal operator, don't insert whitespace betweenRichard Smith2015-10-081-1/+1
| | | | | | | | the "" and the suffix; that breaks names such as 'operator""if'. For symmetry, also remove the space between the 'operator' and the '""'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@249641 91177308-0d34-0410-b5e6-96231b3b80d8
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-8/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208517 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply "Pretty Printer: Fix printing of conversion operator decls and calls."Benjamin Kramer2014-02-251-0/+2
| | | | | | 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
* Revert "Pretty Printer: Fix printing of conversion operator decls and calls."Rafael Espindola2014-02-251-2/+0
| | | | | | | | This reverts commit r202167. It broke Analysis/auto-obj-dtors-cfg-output.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202173 91177308-0d34-0410-b5e6-96231b3b80d8
* Pretty Printer: Fix printing of conversion operator decls and calls.Benjamin Kramer2014-02-251-0/+2
| | | | | | | | | | | | | - Don't emit anything when we encounter a call to a conversion operator. "bar(a & b)" instead of "bar(a & b.operator int())" This preserves the semantics and is still idempotent if we print the AST multiple times. - Properly print declarations of conversion operators. "explicit operator bool();" instead of "bool operator _Bool();" PR18776. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202167 91177308-0d34-0410-b5e6-96231b3b80d8
* When formatting a C++-only declaration name, enable C++ mode in the formatter'sRichard Smith2014-01-221-4/+12
| | | | | | | | | | language options. This is not really ideal -- we should require the right language options to be passed in, or not require language options to format a name -- but it fixes a number of *obviously* wrong formattings. Patch by Olivier Goffart! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199778 91177308-0d34-0410-b5e6-96231b3b80d8
* Fixed a FIXME; created a print method for Selectors that accepts a ↵Aaron Ballman2014-01-031-1/+2
| | | | | | | | raw_ostream, and started using it in places it made sense. No functional changes intended, just API cleanliness. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198428 91177308-0d34-0410-b5e6-96231b3b80d8
* Provide operator<< for stream output of DeclarationNamesDavid Blaikie2013-05-141-77/+65
| | | | | | | | | | | ASTDumper was already trying to do this & instead got an implicit bool conversion by surprise (thus printing out 0 or 1 instead of the name of the declaration). To avoid that issue & simplify call sites, simply make it the normal/expected operator<<(raw_ostream&, ...) overload & simplify all the existing call sites. (bonus: this function doesn't need to be a member or friend, it's just using public API in DeclarationName) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181832 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't include Type.h in DeclarationName.h.Benjamin Kramer2012-12-011-0/+15
| | | | | | Recursively prune some includes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169094 91177308-0d34-0410-b5e6-96231b3b80d8
* Simplify some users of DeclarationName::getNameKind. Fold ↵Benjamin Kramer2012-05-191-1/+1
| | | | | | getFETokenInfoAsVoid into its only caller. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157116 91177308-0d34-0410-b5e6-96231b3b80d8
* Synchronize the representations of DeclarationName and Selector soDouglas Gregor2012-05-041-45/+0
| | | | | | | | | that bridging between the two is free. Saves ~4k of code size, although I don't see any measurable performance difference (unfortunately). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156187 91177308-0d34-0410-b5e6-96231b3b80d8
* Inline DenseMapInfo<clang::DeclarationName>::getHashValue() for a 0.4% ↵Douglas Gregor2012-05-031-6/+0
| | | | | | speedup on <rdar://problem/11004361> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156129 91177308-0d34-0410-b5e6-96231b3b80d8
* Split DeclarationName::getFETokenInfoAsVoid() into hot/cold paths andDouglas Gregor2012-05-031-2/+2
| | | | | | | | (trivially) make DeclContext::lookup()'s const version inlinable. Good for 0.3% on <rdar://problem/11004361>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156126 91177308-0d34-0410-b5e6-96231b3b80d8
* Literal operator suffixes and regular names live in separate namespaces.Richard Smith2012-03-091-3/+8
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152395 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert my patches which removed Diagnostic.h includes by moving some ↵Benjamin Kramer2012-02-071-15/+0
| | | | | | | | | | | | | | | | | | operator overloads out of line. This seems to negatively affect compile time onsome ObjC tests (which use a lot of partial diagnostics I assume). I have to come up with a way to keep them inline without including Diagnostic.h everywhere. Now adding a new diagnostic requires a full rebuild of e.g. the static analyzer which doesn't even use those diagnostics. This reverts commit 6496bd10dc3a6d5e3266348f08b6e35f8184bc99. This reverts commit 7af19b817ba964ac560b50c1ed6183235f699789. This reverts commit fdd15602a42bbe26185978ef1e17019f6d969aa7. This reverts commit 00bd44d5677783527d7517c1ffe45e4d75a0f56f. This reverts commit ef9b60ffed980864a8db26ad30344be429e58ff5. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150006 91177308-0d34-0410-b5e6-96231b3b80d8
* Move various diagnostic operator<< overloads out of line and remove includes ↵Benjamin Kramer2012-02-041-0/+15
| | | | | | | | | of Diagnostic.h. Fix all the files that depended on transitive includes of Diagnostic.h. With this patch in place changing a diagnostic no longer requires a full rebuild of the StaticAnalyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149781 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-3/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148577 91177308-0d34-0410-b5e6-96231b3b80d8
* Change operator<< for raw_ostream and NamedDecl to take a reference instead ↵Benjamin Kramer2011-10-141-3/+3
| | | | | | | | of a pointer. Passing a pointer was a bad idea as it collides with the overload for void*. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141971 91177308-0d34-0410-b5e6-96231b3b80d8
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-3/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140407 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-6/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140367 91177308-0d34-0410-b5e6-96231b3b80d8
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-2/+2
| | | | | | | | | LLVM.h imports them into the clang namespace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135852 91177308-0d34-0410-b5e6-96231b3b80d8
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-011-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@134225 91177308-0d34-0410-b5e6-96231b3b80d8
* Selector::getIdentifierInfoForSlot() can return NULL values, a factDouglas Gregor2011-02-181-4/+2
| | | | | | | | | | | | | that was ignored in a few places (most notably, code completion). Introduce Selector::getNameForSlot() for the common case where we only care about the name. Audit all uses of getIdentifierInfoForSlot(), switching many over to getNameForSlot(), fixing a few crashers. Fixed <rdar://problem/8939352>, a code-completion crasher. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125977 91177308-0d34-0410-b5e6-96231b3b80d8
* PR3558: mark "logically const" accessor methods in ASTContext as const,Jay Foad2011-01-121-1/+1
| | | | | | | and mark the fields they use as mutable. This allows us to remove a few const_casts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123314 91177308-0d34-0410-b5e6-96231b3b80d8
* Silence GCC warning about control reaching the end of the function and ↵Chandler Carruth2010-12-151-0/+2
| | | | | | explicitly mark that all cases are handled. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121855 91177308-0d34-0410-b5e6-96231b3b80d8
* Variadic templates: extend the Expr class with a bit that specifiesDouglas Gregor2010-12-151-0/+21
| | | | | | | | | | | | | | | | | | | | whether the expression contains an unexpanded parameter pack, in the same vein as the changes to the Type hierarchy. Compute this bit within all of the Expr subclasses. This change required a bunch of reshuffling of dependency calculations, mainly to consolidate them inside the constructors and to fuse multiple loops that iterate over arguments to determine type dependence, value dependence, and (now) containment of unexpanded parameter packs. Again, testing is painfully sparse, because all of the diagnostics will change and it is more important to test the to-be-written visitor that collects unexpanded parameter packs. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121831 91177308-0d34-0410-b5e6-96231b3b80d8
* Added locations and type source info for DeclarationName.Abramo Bagnara2010-08-111-0/+96
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110860 91177308-0d34-0410-b5e6-96231b3b80d8
* Make ASTContext always use the BumpPtrAllocator.Douglas Gregor2010-07-251-20/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109375 91177308-0d34-0410-b5e6-96231b3b80d8
* Allocate most of DeclarationNamesTable using ASTContext's allcocator. The ↵Ted Kremenek2010-05-101-24/+22
| | | | | | | | only things that aren't allocated this way are the internal FoldingSets. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103429 91177308-0d34-0410-b5e6-96231b3b80d8
* Start converting pieces of DeclarationNameTable to be allocated using ↵Ted Kremenek2010-05-101-4/+10
| | | | | | | | | | ASTContext's allocator. While DeclarationNameTable doesn't leak, it uses 'malloc' too often. Start with having 'CXXLiteralOperatorNames' allocated using ASTContext's allocator and add a 'DoDestroy()' method to DeclarationNameTable that is called by ~ASTContext. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103426 91177308-0d34-0410-b5e6-96231b3b80d8
* Add printName to DeclarationName which prints the human-readable name on aBenjamin Kramer2010-04-171-24/+35
| | | | | | | raw_ostream. Use it in getAsString and NamedDecl's raw_ostream operator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101633 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the standard DeclarationName comparator to be a tri-valued comparator.John McCall2010-02-131-18/+29
| | | | | | | | | Use that while fixing a nasty misuse of qsort in vtable codegen which, somehow, has not actually caused a crash. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96062 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement semantic checking for C++ literal operators.Sean Hunt2010-01-131-6/+40
| | | | | | | | This now rejects literal operators that don't meet the requirements. Templates are not yet checked for. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93315 91177308-0d34-0410-b5e6-96231b3b80d8
* Implement name lookup for conversion function template specializationsDouglas Gregor2010-01-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template<typename T> operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93162 91177308-0d34-0410-b5e6-96231b3b80d8