summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/IdentifierResolver.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Remove trailing spaceFangrui Song2018-07-301-27/+27
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-1/+1
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\@brief'); do perl -pi -e 's/\@brief //g' $i & done for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [Sema] Revert r329346 because of memory sanitizer failures.Eugene Zelenko2018-04-051-11/+11
| | | | llvm-svn: 329357
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-04-051-11/+11
| | | | | | other minor fixes (NFC). llvm-svn: 329346
* [Sema] Fix some Clang-tidy modernize and Include What You Use warnings; ↵Eugene Zelenko2018-02-211-16/+21
| | | | | | other minor fixes (NFC). llvm-svn: 325659
* [modules] Separately track whether an identifier's preprocessor information andRichard Smith2016-02-051-1/+1
| | | | | | | | | | name lookup information have changed since deserialization. For a C++ modules build, we do not need to re-emit the identifier into the serialized identifier table if only the name lookup information has changed (and in all cases, we don't need to re-emit the macro information if only the name lookup information has changed). llvm-svn: 259901
* [modules] Remove redundant import of lexical decls when building a lookup tableRichard Smith2015-03-231-1/+1
| | | | | | | | | | | | | | | for a DeclContext, and fix propagation of exception specifications along redeclaration chains. This reverts r232905, r232907, and r232907, which reverted r232793, r232853, and r232853. One additional change is present here to resolve issues with LLDB: distinguish between whether lexical decls missing from the lookup table are local or are provided by the external AST source, and still look in the external source if that's where they came from. llvm-svn: 232928
* Reverting r232793 until some new LLDB failures are discussedVince Harron2015-03-221-1/+1
| | | | llvm-svn: 232905
* [modules] Remove some redundant work when building a lookup table for a ↵Richard Smith2015-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | DeclContext. When we need to build the lookup table for a DeclContext, we used to pull in all lexical declarations for the context; instead, just build a lookup table for the local lexical declarations. We previously didn't guarantee that the imported declarations would be in the returned map, but in some cases we'd happen to put them all in there regardless. Now we're even lazier about this. This unnecessary work was papering over some other bugs: - LookupVisibleDecls would use the DC for name lookups in the TU in C, and this was not guaranteed to find all imported names (generally, the DC for the TU in C is not a reliable place to perform lookups). We now use an identifier-based lookup mechanism for this. - We didn't actually load in the list of eagerly-deserialized declarations when importing a module (so external definitions in a module wouldn't be emitted by users of those modules unless they happened to be deserialized by the user of the module). llvm-svn: 232793
* [modules] Rework merging of redeclaration chains on module import.Richard Smith2015-03-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | We used to save out and eagerly load a (potentially huge) table of merged formerly-canonical declarations when we loaded each module. This was extremely inefficient in the presence of large amounts of merging, and didn't actually save any merging lookup work, because we still needed to perform name lookup to check that our merged declaration lists were complete. This also resulted in a loss of laziness -- even if we only needed an early declaration of an entity, we would eagerly pull in all declarations that had been merged into it regardless. We now store the relevant fragments of the table within the declarations themselves. In detail: * The first declaration of each entity within a module stores a list of first declarations from imported modules that are merged into it. * Loading that declaration pre-loads those other entities, so that they appear earlier within the redeclaration chain. * The name lookup tables list the most recent local lookup result, if there is one, or all directly-imported lookup results if not. llvm-svn: 231424
* PR20769: Fix confusion when checking whether a prior default argument was inRichard Smith2014-08-271-0/+3
| | | | | | scope when checking for conflicts. llvm-svn: 216628
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-5/+5
| | | | llvm-svn: 209613
* [C++11] Replacing iterators redecls_begin() and redecls_end() with ↵Aaron Ballman2014-03-061-4/+2
| | | | | | iterator_range redecls(). Updating all of the usages of the iterators with range-based for loops, which allows the begin/end forms to be removed entirely. llvm-svn: 203179
* Per [dcl.meaning]p1, a name in an inline namespace can be redeclared using aRichard Smith2013-12-051-4/+3
| | | | | | | name from the enclosing namespace set if the name is specified as a qualified-id. llvm-svn: 196464
* Convert anachronistic use of 'void *' to 'DeclContext *' in Scope that was a ↵Ted Kremenek2013-10-081-2/+1
| | | | | | holdover from the long-dead Action interface. llvm-svn: 192203
* Delete dead code.Eli Friedman2013-06-191-37/+0
| | | | llvm-svn: 184277
* [Modules] Cope better with top-level declarations loaded after being ↵Douglas Gregor2013-02-111-0/+8
| | | | | | | | | | | | | | | | | | | | declared in the current translation unit <rdar://problem/13189985>. These two related tweaks to keep the information associated with a given identifier correct when the identifier has been given some top-level information (say, a top-level declaration) and more information is then loaded from a module. The first ensures that an identifier that was "interesting" before being loaded from an AST is considered to be different from its on-disk counterpart. Otherwise, we lose such changes when writing the current translation unit as a module. Second, teach the code that injects AST-loaded names into the identifier chain for name lookup to keep the most recent declaration, so that we don't end up confusing our declaration chains by having a different declaration in there. llvm-svn: 174895
* IdentifierResolver: Remove an unnecessary include and an unused parameter.Nico Weber2012-12-171-3/+1
| | | | llvm-svn: 170297
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-1/+1
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Fix more try scoping bugs introduced by r167650.David Blaikie2012-11-121-8/+5
| | | | | | | Introduces more clear scoping flags & flag combinations which should hopefully be more understandable. llvm-svn: 167766
* Handle redeclarations of catch variables in catch blocks.David Blaikie2012-11-101-1/+4
| | | | | | Fix to regression caused by r167650, caught by Richard Smith in code review. llvm-svn: 167653
* PR14296: function parameter name collisions in function try/catchDavid Blaikie2012-11-101-1/+6
| | | | | | | | | | | | C++11 3.3.3/2 "A parameter name shall not be redeclared in the outermost block of the function definition nor in the outermost block of any handler associated with a function-try-block." It's not totally clear to me whether the "FIXME" case is covered by this, but Richard Smith thinks it probably should be. It's just a bit more involved to fix that case. llvm-svn: 167650
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-1/+1
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Remove ref/value inconsistency in redecl_iterator.David Blaikie2012-05-011-1/+1
| | | | | | | | | | | | | Similar to r155808 - this mistake has been made in a few iterators. Based on Chandler Carruth's feedback to r155808 I added an implicit conversion to Decl* to ease adoption/usage. Useful for the pointer comparison, but not the dyn_cast (due to template argument deduction causing the conversion not to be used) - there for future convenience, though. This idiom (op T* for iterators) seems to be fairly idiomatic within the LLVM codebase & I'll likely add it as I fix up the other iterators here. llvm-svn: 155869
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-1/+1
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Reapply r151638 and r151641.James Molloy2012-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation. These are now fixed, with regression tests added to catch them both (not Darwin-specific). Original log: ==================== Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. ==================== llvm-svn: 151712
* Revert r151638 because it causes assertion hit on PCH creation for Cocoa.hArgyrios Kyrtzidis2012-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. llvm-svn: 151667
* Correctly track tags and enum members defined in the prototype of a ↵James Molloy2012-02-281-1/+1
| | | | | | | | | | | | | | | function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. llvm-svn: 151638
* Only mark an IdentifierInfo as having changed since deserializationDouglas Gregor2012-01-241-5/+1
| | | | | | | | when it actually has changed (and not, e.g., when we've simply attached a deserialized macro definition). Good for ~1.5% reduction in module file size, mostly in the identifier table. llvm-svn: 148808
* Keep track of all declarations of an Objective-C class (both forwardDouglas Gregor2011-12-151-9/+0
| | | | | | | | | | declarations and definitions) as ObjCInterfaceDecls within the same redeclaration chain. This new representation matches what we do for C/C++ variables/functions/classes/templates/etc., and makes it possible to answer the query "where are all of the declarations of this class?" llvm-svn: 146679
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-19/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AST file more lazy, so that we don't eagerly load that information for all known identifiers each time a new AST file is loaded. The eager reloading made some sense in the context of precompiled headers, since very few identifiers were defined before PCH load time. With modules, however, a huge amount of code can get parsed before we see an @import, so laziness becomes important here. The approach taken to make this information lazy is fairly simple: when we load a new AST file, we mark all of the existing identifiers as being out-of-date. Whenever we want to access information that may come from an AST (e.g., whether the identifier has a macro definition, or what top-level declarations have that name), we check the out-of-date bit and, if it's set, ask the AST reader to update the IdentifierInfo from the AST files. The update is a merge, and we now take care to merge declarations before/after imports with declarations from multiple imports. The results of this optimization are fairly dramatic. On a small application that brings in 14 non-trivial modules, this takes modules from being > 3x slower than a "perfect" PCH file down to 30% slower for a full rebuild. A partial rebuild (where the PCH file or modules can be re-used) is down to 7% slower. Making the PCH file just a little imperfect (e.g., adding two smallish modules used by a bunch of .m files that aren't in the PCH file) tips the scales in favor of the modules approach, with 24% faster partial rebuilds. This is just a first step; the lazy scheme could possibly be improved by adding versioning, so we don't search into modules we already searched. Moreover, we'll need similar lazy schemes for all of the other lookup data structures, such as DeclContexts. llvm-svn: 143100
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* Fix the insertion of label declarations into the identifier chain inDouglas Gregor2011-03-241-3/+18
| | | | | | | the case where we only have a single identifier with that name in the chain. Fixes PR9463 for real this time. llvm-svn: 128208
* When we're inserting a synthesized label declaration for aDouglas Gregor2011-03-161-21/+11
| | | | | | | | | | | | | | | | forward-looking "goto" statement, make sure to insert it *after* the last declaration in the identifier resolver's declaration chain that is either outside of the function/block/method's scope or that is declared in that function/block/method's specific scope. Previously, we could end up inserting the label ahead of declarations in inner scopes, confusing C++ name lookup. Fixes PR9491/<rdar://problem/9140426> and <rdar://problem/9135994>. Note that the crash-on-invalid PR9495 is *not* fixed. That's a separate issue. llvm-svn: 127737
* When synthesizing a label declaration based on a goto statement thatDouglas Gregor2011-03-141-0/+33
| | | | | | | | | cannot yet be resolved, be sure to push the new label declaration into the right place within the identifier chain. Otherwise, name lookup in C++ gets confused when searching for names that are lexically closer than the label. Fixes PR9463. llvm-svn: 127623
* Support explicit template specialization and instantiation for membersDouglas Gregor2011-03-071-2/+6
| | | | | | | | | | | of a C++0x inline namespace within enclosing namespaces, as noted in C++0x [namespace.def]p8. Fixes <rdar://problem/9006349>, a libc++ failure where Clang was rejected an explicit specialization of std::swap (since libc++ puts it into an inline, versioned namespace std::__1). llvm-svn: 127162
* Rename DeclContext::getLookupContext to getRedeclContext and change its ↵Sebastian Redl2010-08-311-2/+2
| | | | | | semantics slightly. No functionality change in the absence of inline namespaces. Also, change a few places where inline namespaces actually make a difference to be prepared for them. llvm-svn: 112563
* Struggle mightily against header inclusion in Sema.h.John McCall2010-08-241-0/+15
| | | | llvm-svn: 111904
* DeclPtrTy -> Decl *John McCall2010-08-211-2/+2
| | | | llvm-svn: 111733
* More PCH -> AST renaming.Sebastian Redl2010-08-181-4/+4
| | | | llvm-svn: 111472
* Move Sema's headers into include/clang/Sema, renaming a few along the way.Douglas Gregor2010-08-121-1/+1
| | | | llvm-svn: 110945
* Correctly deal with using names for both functions and structs in chained PCH.Sebastian Redl2010-07-301-0/+10
| | | | llvm-svn: 109871
* Optimize the implementation of IdDeclInfo pooling in the IdentifierResolver.John McCall2010-02-151-13/+25
| | | | llvm-svn: 96253
* Eliminate dead code.Eli Friedman2010-01-021-42/+0
| | | | llvm-svn: 92424
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-8/+8
| | | | llvm-svn: 81346
* Add DeclContext::Equals to compare declaration contexts based on their ↵Douglas Gregor2009-09-011-2/+1
| | | | | | primary context. Use this instead of pointer comparisons llvm-svn: 80690
* Make sure to compare primary declaration contexts when determining whether a ↵Douglas Gregor2009-08-261-1/+2
| | | | | | declaration is in scope llvm-svn: 80126
* Lazy deserialization of the declaration chains associated withDouglas Gregor2009-04-211-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | identifiers from a precompiled header. This patch changes the primary name lookup method for entities within a precompiled header. Previously, we would load all of the names of declarations at translation unit scope into a large DenseMap (inside the TranslationUnitDecl's DeclContext), and then perform a special "last resort" lookup into this DeclContext when we knew there was a PCH file (see Sema::LookupName). Now, when we see an identifier named for the first time, we load all of the declarations with that name that are visible from the translation unit into the IdentifierInfo's chain of declarations. Thus, the explicit "look into the translation unit's DeclContext" code is gone, and Sema effectively uses the same IdentifierInfo-based name lookup mechanism whether we are using a PCH file or not. This approach should help PCH scale with the size of the input program rather than the size of the PCH file. The "Hello, World!" application with Carbon.h as a PCH file now loads 20% of the identifiers in the PCH file rather than 85% of the identifiers. 90% of the 20% of identifiers loaded are actually loaded when we deserialize the preprocessor state. The next step is to make the preprocessor load macros lazily, which should drastically reduce the number of types, declarations, and identifiers loaded for "Hello, World". llvm-svn: 69737
* Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for aChris Lattner2009-03-281-2/+2
| | | | | | | | | | | | | | | | | | | | pointer. Its purpose in life is to be a glorified void*, but which does not implicitly convert to void* or other OpaquePtr's with a different UID. Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>. Change the entire parser/sema interface to use DeclPtrTy instead of DeclTy*. This makes the C++ compiler enforce that these aren't convertible to other opaque types. We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc, but I don't plan to do that in the short term. The one outstanding known problem with this patch is that we lose the bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to bitmangle the success bit into the low bit of DeclPtrTy. I will rectify this with a subsequent patch. llvm-svn: 67952
* Switch attributes to be allocated from the declcontext bump pointer just likeChris Lattner2009-03-041-6/+4
| | | | | | | decls. This reduces the number of calls to malloc on cocoa.h with pth and -disable-free from 15958 to 12444 times (down ~3500). llvm-svn: 66023
OpenPOWER on IntegriCloud