summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Per Richard's suggestion, rename DefLoc to DefaultLoc where it appears.Alexis Hunt2011-05-061-16/+17
| | | | llvm-svn: 131018
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-061-9/+4
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Do defaulted constructors properly.Alexis Hunt2011-05-061-10/+53
| | | | | | | | Explictly defaultedness is correctly reflected on the AST, but there are no changes to how that affects the definition of functions or much else really. llvm-svn: 130974
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-061-2/+1
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement support for C++0x alias templates.Richard Smith2011-05-051-16/+25
| | | | llvm-svn: 130953
* Implement some framework for defaulted constructors.Alexis Hunt2011-05-051-1/+2
| | | | | | There's some unused stuff for now. llvm-svn: 130912
* When tag lookup finds something ambiguous, and we're defining a newDouglas Gregor2011-05-041-0/+13
| | | | | | | | | | | | | tag, filter out those ambiguous names that we found if they aren't within the declaration context where this newly-defined tag will be visible. This is basically a hack, because we really need to fix the lookup of tag declarations in this case to not find things it shouldn't. However, it's better than what we had before, and it fixes <rdar://problem/9168556>. llvm-svn: 130810
* When parsing a template friend declaration we dropped the templateChandler Carruth2011-05-031-1/+11
| | | | | | | | | | | | | | | | | | | | parameters on the floor in certain cases: class X { template <typename T> friend typename A<T>::Foo; }; This was parsed as a *non* template friend declaration some how, and received an ExtWarn. Fixing the parser to actually provide the template parameters to the freestanding declaration parse triggers the code which specifically looks for such constructs and hard errors on them. Along the way, this prevents us from trying to instantiate constructs like the above inside of a outer template. This is important as loosing the template parameters means we don't have a well formed declaration and template instantiation will be unable to rebuild the AST. That fixes a crash in the GCC test suite. llvm-svn: 130772
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-011-6/+17
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Extend Sema::ClassifyName() to support C++, ironing out a few issuesDouglas Gregor2011-04-271-33/+41
| | | | | | | | | in the classification of template names and using declarations. We now properly typo-correct the leading identifiers in statements to types, templates, values, etc. As an added bonus, this reduces the number of lookups required for disambiguation. llvm-svn: 130288
* Improve diagnostics for typo correction via Sema::ClassifyName(), byDouglas Gregor2011-04-271-3/+19
| | | | | | | | looking at the context and the correction and using a custom diagnostic. Also, enable some Fix-It tests that were somewhat lamely disabled. llvm-svn: 130283
* Add ms_struct attribute on record typeeFariborz Jahanian2011-04-261-0/+2
| | | | | | (and ignore it for now) - wip. llvm-svn: 130224
* 'extern' variables in functions don't shadow externs in global scope. Fixes ↵Argyrios Kyrtzidis2011-04-251-14/+4
| | | | | | rdar://8883302, this time for C++ as well. llvm-svn: 130157
* When Sema::ClassifyName() finds an invalid ivar reference, return anDouglas Gregor2011-04-251-11/+3
| | | | | | | invalid expression rather than the far-more-generic "error". Fixes a mild regression in error recovery uncovered by the GCC testsuite. llvm-svn: 130128
* Implement a new identifier-classification scheme where SemaDouglas Gregor2011-04-241-0/+306
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | performs name lookup for an identifier and resolves it to a type/expression/template/etc. in the same step. This scheme is intended to improve both performance (by reducing the number of redundant name lookups for a given identifier token) and error recovery (by giving Sema a chance to correct type names before the parser has decided that the identifier isn't a type name). For example, this allows us to properly typo-correct type names at the beginning of a statement: t.c:6:3: error: use of undeclared identifier 'integer'; did you mean 'Integer'? integer *i = 0; ^~~~~~~ Integer t.c:1:13: note: 'Integer' declared here typedef int Integer; ^ Previously, we wouldn't give a Fix-It because the typo correction occurred after the parser had checked whether "integer" was a type name (via Sema::getTypeName(), which isn't allowed to typo-correct) and therefore decided to parse "integer * i = 0" as an expression. By typo-correcting earlier, we typo-correct to the type name Integer and parse this as a declaration. Moreover, in this context, we can also typo-correct identifiers to keywords, e.g., t.c:7:3: error: use of undeclared identifier 'vid'; did you mean 'void'? vid *p = i; ^~~ void and recover appropriately. Note that this is very much a work-in-progress. The new Sema::ClassifyName is only used for expression-or-declaration disambiguation in C at the statement level. The next steps will be to make this work for the same disambiguation in C++ (where functional-style casts make some trouble), then push it further into the parser to eliminate more redundant name lookups. Fixes <rdar://problem/7963833> for C and starts us down the path of <rdar://problem/8172000>. llvm-svn: 130082
* Correctly emit a diagnostic for multiple templated function definitions in ↵Francois Pichet2011-04-221-18/+18
| | | | | | -flate-template-parsing mode. llvm-svn: 130030
* Add -fdelayed-template-parsing option. Using this option all templated ↵Francois Pichet2011-04-221-1/+6
| | | | | | | | | function definitions are parsed at the end of the translation unit only if it is required by an actual instantiation. As such all the symbols of the TU are available during name lookup. Using this flag is necessary for compatibility with Microsoft template code. This also provides some parsing speed improvement. llvm-svn: 130022
* Do not return true from MergeFunctionDecl for a warn_static_non_static ↵Francois Pichet2011-04-221-6/+8
| | | | | | warning in Microsoft mode. llvm-svn: 130010
* I concur with DPG here. This does indeed apply in 0x mode. Added testChandler Carruth2011-04-221-2/+1
| | | | | | | | | cases that demonstrates exactly why this does indeed apply in 0x mode. If isPOD is currently broken in 0x mode, we should fix that directly rather than papering over it here. llvm-svn: 130007
* For consistency, change suffix from war_ to warn_ for some Microsoft ↵Francois Pichet2011-04-221-1/+1
| | | | | | warnings I introduced lately. llvm-svn: 129986
* Downgrade error "static declaration of 'foo' follows non-static declaration" ↵Francois Pichet2011-04-221-2/+4
| | | | | | to a warning in Microsoft mode. llvm-svn: 129985
* ADT/Triple: Switch to using .isOSDarwin() predicate.Daniel Dunbar2011-04-191-2/+1
| | | | llvm-svn: 129823
* Support for C++11 (non-template) alias declarations.Richard Smith2011-04-151-41/+69
| | | | llvm-svn: 129567
* Add support for C++0x's range-based for loops, as specified by the C++11 ↵Richard Smith2011-04-141-0/+41
| | | | | | draft standard (N3291). llvm-svn: 129541
* Still not used to put the * next to the variable name.Francois Pichet2011-04-131-1/+1
| | | | llvm-svn: 129426
* In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal to ↵Francois Pichet2011-04-131-1/+32
| | | | | | | | | | | | | | | | | | the type of one of the base classes then downgrade the missing typename error to a warning. Up to now this is the only case I found where MSVC doesn't require "typename" at class scope. Really strange! This fixes 1 error when parsing the MSVC 2008 header files. Example: template<class T> class A { public: typedef int TYPE; }; template<class T> class B : public A<T> { public: A<T>::TYPE a; // no typename required because A<T> is a base class. }; llvm-svn: 129425
* PR8369: make __attribute((regparm(0))) work correctly. Original patch byEli Friedman2011-04-091-2/+3
| | | | | | pageexec@freemail.hu, tweaks by me. llvm-svn: 129206
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | This patch authored by Eric Niebler. Many methods on the Sema class (e.g. ConvertPropertyForRValue) take Expr pointers as in/out parameters (Expr *&). This is especially true for the routines that apply implicit conversions to nodes in-place. This design is workable only as long as those conversions cannot fail. If they are allowed to fail, they need a way to report their failures. The typical way of doing this in clang is to use an ExprResult, which has an extra bit to signal a valid/invalid state. Returning ExprResult is de riguour elsewhere in the Sema interface. We suggest changing the Expr *& parameters in the Sema interface to ExprResult &. This increases interface consistency and maintainability. This interface change is important for work supporting MS-style C++ properties. For reasons explained here <http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-February/013180.html>, seemingly trivial operations like rvalue/lvalue conversions that formerly could not fail now can. (The reason is that given the semantics of the feature, getter/setter method lookup cannot happen until the point of use, at which point it may be found that the method does not exist, or it may have the wrong type, or overload resolution may fail, or it may be inaccessible.) llvm-svn: 129143
* Fix PR 9626 (duplicated self-init warnings under -Wuninitialized) with ↵Ted Kremenek2011-04-041-1/+10
| | | | | | | | | | | | | | numerous CFG and UninitializedValues analysis changes: 1) Change the CFG to include the DeclStmt for conditional variables, instead of using the condition itself as a faux DeclStmt. 2) Update ExprEngine (the static analyzer) to understand (1), so not to regress. 3) Update UninitializedValues.cpp to initialize all tracked variables to Uninitialized at the start of the function/method. 4) Only use the SelfReferenceChecker (SemaDecl.cpp) on global variables, leaving the dataflow analysis to handle other cases. The combination of (1) and (3) allows the dataflow-based -Wuninitialized to find self-init problems when the initializer contained control-flow. llvm-svn: 128858
* Accept __declspec(dllimport) for function defined at class scope in ↵Francois Pichet2011-03-291-1/+3
| | | | | | | | Microsoft mode. This fixes a bunch of errors when compiling MSVC header files with the -DDLL flag. llvm-svn: 128457
* Diagnose uninitialized uses of a variable within its own initializer.Chandler Carruth2011-03-271-1/+44
| | | | | | | | | | | This is basically the same idea as the warning on uninitialized uses of fields within an initializer list. As such, it is on by default and under -Wuninitialized. Original patch by Richard Trieu, with some massaging from me on the wording and grouping of the diagnostics. llvm-svn: 128376
* Don't warn about the 'extern' in 'extern "C"' on a tag decl. This isJohn McCall2011-03-261-2/+7
| | | | | | usually useless, but not always. llvm-svn: 128326
* Get rid of handling of the 'explicit' keyword from class-head. We still ↵Anders Carlsson2011-03-251-5/+3
| | | | | | parse it though, although that will change shortly. llvm-svn: 128277
* Minor fix in the injection of labels, since we want to look at the ↵Douglas Gregor2011-03-241-1/+1
| | | | | | redeclaration context of each declaration in the identifier chain. Should fix Linux self-host llvm-svn: 128210
* Insomniac refactoring: change how the parser allocates attributes so thatJohn McCall2011-03-241-4/+6
| | | | | | | | | AttributeLists do not accumulate over the lifetime of parsing, but are instead reused. Also make the arguments array not require a separate allocation, and make availability attributes store their stuff in augmented memory, too. llvm-svn: 128209
* Warn about unused declaration-specifiers on tag declarations.John McCall2011-03-221-10/+42
| | | | llvm-svn: 128118
* Apply Jonathan Sauer's proposed solution to PR9519. Thanks!John McCall2011-03-221-1/+1
| | | | llvm-svn: 128075
* Defined friend functions are *implicitly* inlined, unless the inline ↵Abramo Bagnara2011-03-181-8/+8
| | | | | | specifier occurs explicitly. llvm-svn: 127877
* Fixed inconsistency when adding TemplateParameterListsInfo.Abramo Bagnara2011-03-181-69/+69
| | | | llvm-svn: 127876
* Fix PR9488: 'auto' type substitution can fail (for instance, if it creates a ↵Richard Smith2011-03-171-3/+5
| | | | | | | | reference-to-void type). Don't crash if it does. Also fix an issue where type source information for the resulting type was being lost. llvm-svn: 127811
* Detect attempts to provide a specialization of a function within aDouglas Gregor2011-03-161-3/+9
| | | | | | dependent scope and produce an error (rather than crashing). Fixes PR8979. llvm-svn: 127749
* When we're inserting a synthesized label declaration for aDouglas Gregor2011-03-161-2/+6
| | | | | | | | | | | | | | | | 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-1/+14
| | | | | | | | | 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
* Make deallocation functions implicitly noexcept in C++0x.Sebastian Redl2011-03-141-2/+2
| | | | llvm-svn: 127596
* Propagate the new exception information to FunctionProtoType.Sebastian Redl2011-03-121-4/+6
| | | | | | | | Change the interface to expose the new information and deal with the enormous fallout. Introduce the new ExceptionSpecificationType value EST_DynamicNone to more easily deal with empty throw specifications. Update the tests for noexcept and fix the various bugs uncovered, such as lack of tentative parsing support. llvm-svn: 127537
* Avoid do drop outer template parameter lists on the floor.Abramo Bagnara2011-03-101-4/+4
| | | | llvm-svn: 127404
* Revert r127206 "Detect attempts to provide a specialization of a function withinDaniel Dunbar2011-03-091-8/+3
| | | | | | a...", it appears to cause us to reject various valid codes. llvm-svn: 127373
* Fixed InnerLocStart.Abramo Bagnara2011-03-091-7/+6
| | | | llvm-svn: 127330
* Warn on usage of unavailable objc 'class' inFariborz Jahanian2011-03-081-0/+1
| | | | | | varienty of cases. // rdar://9092208 llvm-svn: 127257
* Teach libclang's token-annotation logic about context-sensitiveDouglas Gregor2011-03-081-2/+4
| | | | | | keywords for Objective-C+ and C++0x. llvm-svn: 127253
OpenPOWER on IntegriCloud