summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaCXXScopeSpec.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Handle unscoped enumeration in nested name specifier.Serge Pavlov2015-01-181-8/+27
| | | | | | | | | | If an unscoped enum is used as a nested name specifier and the language dialect is not C++ 11, issue an extension warning. This fixes PR16951. Differential Revision: http://reviews.llvm.org/D6389 llvm-svn: 226413
* Remove a comment that appears a second time 22 lines further down.Nico Weber2014-12-301-3/+0
| | | | llvm-svn: 225004
* [c++1z] Support [[deprecated]] attributes on namespaces. Note that it only ↵Aaron Ballman2014-11-141-0/+4
| | | | | | applies to situations where the namespace is mentioned. Thus, use on anonymous namespaces is diagnosed. llvm-svn: 222054
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-5/+4
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* -ms-extensions: Implement __super scope specifier (PR13236).Nikola Smiljanic2014-09-261-1/+36
| | | | | | | | | We build a NestedNameSpecifier that records the CXXRecordDecl in which __super appeared. Name lookup is performed in all base classes of the recorded CXXRecordDecl. Use of __super is allowed only inside class and member function scope. llvm-svn: 218484
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-061-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Limit our MSVC compat hack for nested names from dependent basesReid Kleckner2014-08-141-2/+7
| | | | | | | | | | | | | | | | | | | | Previously, any undeclared unqualified id starting a nested name specifier in a dependent context would have its lookup retried during template instantiation. Now we limit that retry hack to methods of a class with dependent bases. Free function templates in particular are no longer affected by this hack. Also, diagnose this as a Microsoft extension. This has the downside that template authors may see this warning *and* an error during instantiation time about this identifier. Fixing that will probably require formalizing some kind of "delayed" identifier, instead of our ad-hoc solutions of forming dependent AST nodes when lookup fails. Based on a patch by Kim Gräsman! Differential Revision: http://reviews.llvm.org/D4854 llvm-svn: 215683
* Consolidate some note diagnosticsAlp Toker2014-05-281-6/+2
| | | | | | | | | These note diags have the same message and can be unified further but for now let's just bring them together. Incidental change: Display a source range in the final attr diagnostic. llvm-svn: 209728
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-19/+19
| | | | llvm-svn: 209613
* Initial implementation of -modules-earch-all option, for searching for ↵John Thompson2014-04-231-1/+2
| | | | | | symbols in non-imported modules. llvm-svn: 206977
* Improve error recovery around colon.Serge Pavlov2014-04-131-11/+69
| | | | | | | | | | Parse of nested name spacifier is modified so that it properly recovers if colon is mistyped as double colon in case statement. This patch fixes PR15133. Differential Revision: http://llvm-reviews.chandlerc.com/D2870 llvm-svn: 206135
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-1/+1
| | | | | | class. llvm-svn: 203640
* Improve diagnostic for using non-class/namespace/scoped enum in a nested ↵David Blaikie2014-02-091-14/+17
| | | | | | | | | | | | | | | name specifier. Rather than simply saying "X is not a class or namespace", clarify what X is by providing the aka type in the case where X is a type, or pointing to the named declaration if there's an unambiguous one to refer to. In the ambiguous case, the ambiguities are already enumerated (though could be clarified by describing what kind of entities they are) Included a few FIXMEs in tests where some further improvements could be made. llvm-svn: 201038
* Rename language option MicrosoftMode to MSVCCompatAlp Toker2014-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | There's been long-standing confusion over the role of these two options. This commit makes the necessary changes to differentiate them clearly, following up from r198936. MicrosoftExt (aka. fms-extensions): Enable largely unobjectionable Microsoft language extensions to ease portability. This mode, also supported by gcc, is used for building software like FreeBSD and Linux kernel extensions that share code with Windows drivers. MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode): Turn on a special mode supporting 'heinous' extensions for drop-in compatibility with the Microsoft Visual C++ product. Standards-compilant C and C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt. Note that full -fms-compatibility mode is currently enabled by default on the Windows target, which may need tuning to serve as a reasonable default. See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined type_info out of InitializePredefinedMacros' No change in behaviour. llvm-svn: 199209
* Make Sema::BuildCXXNestedNameSpecifier correctly clear the previousKaelyn Uhrain2013-12-161-0/+2
| | | | | | | | CXXScopeSpec when necessary while performing typo correction. This fixes the crash reported in PR18213 (the problem existed since r185487, and r193020 made it easier to hit). llvm-svn: 197409
* Fix crash if a variable template specialization is used in a ↵Richard Smith2013-12-041-3/+3
| | | | | | nested-name-specifier. llvm-svn: 196335
* Fix several crash-on-invalids when using template-ids that aren'tRichard Smith2013-12-041-6/+7
| | | | | | simple-template-ids (eg, 'operator+<int>') in weird places. llvm-svn: 196333
* Use -fms-compatibility to trigger lookup into dep. basesReid Kleckner2013-09-201-2/+2
| | | | | | | Update the docs for -fms-extensions and -fms-compatibility to try to clarify the difference between the two. llvm-svn: 191095
* Don't correct typos in Sema::BuildCXXNestedNameSpecifier with -fms-extensionsKaelyn Uhrain2013-09-191-1/+1
| | | | | | | | When -fms-extensions is enabled, the typo correction was being called here on non-error paths (as in test/SemaTemplate/lookup-dependent-bases.cpp) and correct compilation depended on Sema::CorrectTypo not finding a viable candidate. llvm-svn: 191046
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-23/+15
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Allow typo correction to try removing nested name specifiers.Kaelyn Uhrain2013-07-021-3/+7
| | | | | | | | | | | | | | | | | The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487
* Remove dead code.Eli Friedman2013-06-191-10/+0
| | | | llvm-svn: 184379
* Remove some no-op static_casts.Richard Smith2013-03-261-12/+5
| | | | llvm-svn: 177954
* Use 'const Decl *' throughout code completion in SemaDmitri Gribenko2013-01-231-2/+2
| | | | llvm-svn: 173277
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-3/+3
| | | | llvm-svn: 171367
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-3/+3
| | | | | | | | | | | | | 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 CXXRecordDecl::forallBases to not look through bases which are dependentRichard Smith2012-11-221-9/+3
| | | | | | | | and defined within the current instantiation, but which are not part of the current instantiation. Previously, it would look at bases which could be specialized separately from the current template. llvm-svn: 168477
* Fix typo correction of one qualified name to another.David Blaikie2012-10-121-1/+2
| | | | | | | | | | | | | | When suggesting "foo::bar" as a correction for "fob::bar" we mistakenly replaced only "bar" with "foo::bar" producing "fob::foo::bar" which was broken. This corrects that replacement in as many places as I could find & provides test cases for all those cases I could find a test case for. There are a couple that don't seem to be reachable (one looks entirely dead, the other just doesn't seem to ever get called with a namespace to namespace change). Review by Richard Smith ( http://llvm-reviews.chandlerc.com/D57 ). llvm-svn: 165817
* Move Sema::RequireCompleteType() and Sema::RequireCompleteExprType()Douglas Gregor2012-05-041-3/+2
| | | | | | | | | | | off PartialDiagnostic. PartialDiagnostic is rather heavyweight for something that is in the critical path and is rarely used. So, switch over to an abstract-class-based callback mechanism that delays most of the work until a diagnostic is actually produced. Good for ~11k code size reduction in the compiler and 1% speedup in -fsyntax-only on the code in <rdar://problem/11004361>. llvm-svn: 156176
* In C++11 mode, implement the C++11 semantics forDouglas Gregor2012-05-011-2/+5
| | | | | | | | | | | [basic.lookup.classref]p1 and p4, which concerns name lookup for nested-name-specifiers and template names, respectively, in a member access expression. C++98/03 forces us to look both in the scope of the object and in the current scope, then compare the results. C++11 just takes the result from the scope of the object, if something is found. Fixes <rdar://problem/11328502>. llvm-svn: 155935
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-4/+8
| | | | | | | class template's definition, and for explicit specializations of such enum members. llvm-svn: 153304
* Instantiating a class template should not instantiate the definition of anyRichard Smith2012-03-141-31/+41
| | | | | | | | scoped enumeration members. Later uses of an enumeration temploid as a nested name specifier should cause its instantiation. Plus some groundwork for explicit specialization of member enumerations of class templates. llvm-svn: 152750
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-7/+7
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-061-0/+1
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-9/+8
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Make the callback object to Sema::CorrectTypo mandatory.Kaelyn Uhrain2012-01-311-1/+1
| | | | llvm-svn: 149451
* Added source location for the template keyword in AST template-id expressions.Abramo Bagnara2012-01-271-4/+4
| | | | llvm-svn: 149127
* Remove unreachable code in Clang. (replace with llvm_unreachable where ↵David Blaikie2012-01-171-5/+3
| | | | | | appropriate or when GCC requires it) llvm-svn: 148292
* Convert SemaCXXScopeSpec.cpp to pass a callback object to CorrectTypo,Kaelyn Uhrain2012-01-121-3/+22
| | | | | | improvng the typo correction results in certain situations. llvm-svn: 148052
* Support decltype in nested-name-specifiers.David Blaikie2011-12-041-0/+23
| | | | llvm-svn: 145785
* Add -Wc++98-compat warning for enumerations in nested name specifiers.Richard Smith2011-10-201-0/+3
| | | | llvm-svn: 142568
* -Wc++98-compat and -Wc++98-compat-pedantic warnings for Sema, part 2.Richard Smith2011-10-181-1/+1
| | | | llvm-svn: 142426
* Rename TagDecl::isDefinition -> isCompleteDefinitionJohn McCall2011-10-071-1/+1
| | | | | | | for better self-documenting code, since the semantics are subtly different from getDefinition(). llvm-svn: 141355
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-1/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-1/+1
| | | | llvm-svn: 140367
* Rename LangOptions::Microsoft to LangOptions::MicrosoftExt to make it clear ↵Francois Pichet2011-09-171-1/+1
| | | | | | | | that this flag must be used only for Microsoft extensions and not emulation; to avoid confusion with the new LangOptions::MicrosoftMode flag. Many of the code now under LangOptions::MicrosoftExt will eventually be moved under the LangOptions::MicrosoftMode flag. llvm-svn: 139987
* In Microsoft mode, if we are within a templated function and we can't ↵Francois Pichet2011-07-271-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | resolve Identifier during BuildCXXNestedNameSpecifier, then extend the SS with Identifier. This will have the effect of resolving Identifier during template instantiation. The goal is to be able to resolve a function call whose nested-name-specifier is located inside a dependent base class. class C { public: static void foo2() { } }; template <class T> class A { public: typedef C D; }; template <class T> class B : public A<T> { public: void foo() { D::foo2(); } }; Note that this won't work if the NestedNameSpecifier refers to a type. This fixes 1 error when parsing the MSVC 2010 standard headers file with clang. llvm-svn: 136203
* Fixed enum types can be complete without actually being valid to useJohn McCall2011-07-061-6/+21
| | | | | | | as scope specifiers; diagnose the attempt, rather than letting it go to an assert. The rest of PR10264. llvm-svn: 134479
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-14/+17
| | | | | | | | | | | | | | | vector<int> to std::vector<int> Patch by Kaelyn Uhrain, with minor tweaks + PCH support from me. Fixes PR5776/<rdar://problem/8652971>. Thanks Kaelyn! llvm-svn: 134007
* When checking a set of template parameter lists against aDouglas Gregor2011-05-151-1/+1
| | | | | | | | | nested-name-specifier, re-evaluate the nested-name-specifier as if we were entering that context (which we did!), so that we'll resolve a template-id to a particular class template partial specialization. Fixes PR9913. llvm-svn: 131383
OpenPOWER on IntegriCloud