summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Look through block pointers and ObjC object pointersMatt Beaumont-Gay2011-05-051-4/+3
| | | | llvm-svn: 130906
* Change cycle detection to be based off of a warning flag.Alexis Hunt2011-05-051-1/+4
| | | | llvm-svn: 130898
* Implement Sema::isExprCallable.Matt Beaumont-Gay2011-05-041-0/+100
| | | | | | | | We can use this to produce nice diagnostics (and try to fixit-and-recover) in various cases where we might see "MyFunction" instead of "MyFunction()". The changes in SemaExpr are an example of how to use isExprCallable. llvm-svn: 130878
* Implement a better version of delegating constructor cycle detection.Alexis Hunt2011-05-041-0/+3
| | | | | | | | | | | | | This is more efficient as it's all done at once at the end of the TU. This could still get expensive, so a flag is provided to disable it. As an added bonus, the diagnostics will now print out a cycle. The PCH test is XFAILed because we currently can't deal with a note emitted in the header and I, being tired, see no other way to verify the serialization of delegating constructors. We should probably address this problem /somehow/ but no good solution comes to mind. llvm-svn: 130836
* Recognize gcc's ms_struct pragma (and ignore for now).Fariborz Jahanian2011-04-251-2/+2
| | | | | | This is wip. llvm-svn: 130138
* Synthesizing the definition of an implicit member is an AST modification, so ↵Sebastian Redl2011-04-241-0/+4
| | | | | | notify any mutation listeners of it. This fixes a crasher in chained PCH, where an implicit destructor in a PCH gets a definition in a chained PCH, which is then lost. However, any further use of the destructor would cause its definition to be regenerated in the final file, hiding the bug. llvm-svn: 130103
* At the end of the translation unit, defining a vtable can introduceDouglas Gregor2011-04-221-16/+24
| | | | | | | | new templates that need to be instantiated and vice-versa. Iterate until we've instantiated all required templates and defined all required vtables. Fixed PR9325 / <rdar://problem/9055177>. llvm-svn: 130023
* Add -fdelayed-template-parsing option. Using this option all templated ↵Francois Pichet2011-04-221-0/+1
| | | | | | | | | 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
* We regard a function as 'unused' from the codegen perspective, so our ↵Argyrios Kyrtzidis2011-04-191-6/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | warnings diverge from gcc's unused warnings which don't get emitted if the function is referenced even in an unevaluated context (e.g. in templates, sizeof, etc.). Also, saying that a function is 'unused' because it won't get codegen'ed is somewhat misleading. - Don't emit 'unused' warnings for functions that are referenced in any part of the user's code. - A warning that an internal function/variable won't get emitted is useful though, so introduce -Wunneeded-internal-declaration which will warn if a function/variable with internal linkage is not "needed" ('used' from the codegen perspective), e.g: static void foo() { } template <int> void bar() { foo(); } test.cpp:1:13: warning: function 'foo' is not needed and will not be emitted static void foo() { } ^ Addresses rdar://8733476. llvm-svn: 129794
* Use ExprResult& instead of Expr *& in SemaJohn Wiegley2011-04-081-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* In C++ the argument of logical not should always be bool. Added missing ↵Abramo Bagnara2011-04-071-0/+15
| | | | | | implicit cast for scalars. llvm-svn: 129066
* Fix my earlier commit to work with escaped newlines and leave breadcrumbsJohn McCall2011-03-081-0/+21
| | | | | | | in case we want to make a world where we can check intermediate instantiations for this kind of breadcrumb. llvm-svn: 127221
* Fixed TypedefDecl and TemplateTypeParameter source range.Abramo Bagnara2011-03-061-3/+8
| | | | llvm-svn: 127119
* Don't emit unused warning for deleted functions. Fixes rdar://8365684 & ↵Argyrios Kyrtzidis2011-03-031-0/+2
| | | | | | http://llvm.org/PR9391. llvm-svn: 126950
* Enhance Sema::DiagRuntimeBehavior() to delay some diagnostics to see if the ↵Ted Kremenek2011-02-231-1/+12
| | | | | | | | | | related code is reachable. This suppresses some diagnostics that occur in unreachable code (e.g., -Warray-bound). We only pay the cost of doing the reachability analysis when we issue one of these diagnostics. llvm-svn: 126290
* Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.Ted Kremenek2011-02-231-1/+1
| | | | llvm-svn: 126288
* Issue AnalysisBasedWarnings as part of calling ↵Ted Kremenek2011-02-231-2/+8
| | | | | | Sema::PopBlockOrFunctionScope(). No real functionality change. llvm-svn: 126287
* Tweaks to C++0x deduced auto type support:Richard Smith2011-02-211-0/+6
| | | | | | | | * Flag indicating 'we're parsing this auto typed variable's initializer' moved from VarDecl to Sema * Temporary template parameter list for auto deduction is now allocated on the stack. * Deduced 'auto' types are now uniqued. llvm-svn: 126139
* Warn about code that uses variables and functions with internal linkageJohn McCall2011-02-191-0/+61
| | | | | | | | | | | | | | without defining them. This should be an error, but I'm paranoid about "uses" that end up not actually requiring a definition. I'll revisit later. Also, teach IR generation to not set internal linkage on variable declarations, just for safety's sake. Doing so produces an invalid module if the variable is not ultimately defined. Also, fix several places in the test suite where we were using internal functions without definitions. llvm-svn: 126016
* Switch labels over to using normal name lookup, instead of their Chris Lattner2011-02-181-49/+0
| | | | | | | own weird little DenseMap. Hey look, we now emit unused label warnings deterministically, amazing. llvm-svn: 125813
* add a fixmeChris Lattner2011-02-171-0/+2
| | | | llvm-svn: 125772
* Step #2/N of __label__ support: keep pushing LabelDecl forward,Chris Lattner2011-02-171-2/+1
| | | | | | | | | | making them be template instantiated in a more normal way and make them handle attributes like other decls. This fixes the used/unused label handling stuff, making it use the same infrastructure as other decls. llvm-svn: 125771
* Step #1/N of implementing support for __label__: split labels intoChris Lattner2011-02-171-0/+48
| | | | | | | | | | | | | | | | | | | LabelDecl and LabelStmt. There is a 1-1 correspondence between the two, but this simplifies a bunch of code by itself. This is because labels are the only place where we previously had references to random other statements, causing grief for AST serialization and other stuff. This does cause one regression (attr(unused) doesn't silence unused label warnings) which I'll address next. This does fix some minor bugs: 1. "The only valid attribute " diagnostic was capitalized. 2. Various diagnostics printed as ''labelname'' instead of 'labelname' 3. This reduces duplication of label checking between functions and blocks. Review appreciated, particularly for the cindex and template bits. llvm-svn: 125733
* When parsing an out-of-line member function declaration, we must delayJohn McCall2011-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | access-control diagnostics which arise from the portion of the declarator following the scope specifier, just in case access is granted by friending the individual method. This can also happen with in-line member function declarations of class templates due to templated-scope friend declarations. We were really playing fast-and-loose before with this sort of thing, and it turned out to work because *most* friend functions are in file scope. Making us delay regardless of context exposed several bugs with how we were manipulating delay. I ended up needing a concept of a context that's independent of the declarations in which it appears, and then I actually had to make some things save contexts correctly, but delay should be much cleaner now. I also encapsulated all the delayed-diagnostics machinery in a single subobject of Sema; this is a pattern we might want to consider rolling out to other components of Sema. llvm-svn: 125485
* Move support for "#pragma STDC FP_CONTRACT" to Parser; add Sema actionsPeter Collingbourne2011-02-141-1/+1
| | | | llvm-svn: 125474
* Perform the bad-address-space conversions check as part of John McCall2011-02-011-9/+0
| | | | | | CheckPointerTypesForAssignment. llvm-svn: 124632
* If there were errors, disable 'unused' warnings since they will mostly be noise.Argyrios Kyrtzidis2011-01-311-19/+23
| | | | | | Fixes rdar://8736362. llvm-svn: 124577
* Teach the evaluation of the __is_convertible_to trait to translateDouglas Gregor2011-01-271-5/+11
| | | | | | | | | | | | | | | access control errors into SFINAE errors, so that the trait provides enough support to implement the C++0x std::is_convertible type trait. To get there, the SFINAETrap now knows how to set up a SFINAE context independent of any template instantiations or template argument deduction steps, and (separately) can set a Sema flag to translate access control errors into SFINAE errors. The latter can also be useful if we decide that access control errors during template argument deduction should cause substitution failure (rather than a hard error) as has been proposed for C++0x. llvm-svn: 124446
* Separate the access-control diagnostics from other diagnostics that do not ↵Douglas Gregor2011-01-271-0/+2
| | | | | | have SFINAE behavior. llvm-svn: 124441
* Don't insert class templates into the DynamicClasses vector.Anders Carlsson2011-01-251-0/+2
| | | | llvm-svn: 124201
* Implement basic support for template instantiation of pack expansionsDouglas Gregor2010-12-201-1/+2
| | | | | | | | | | | | | | | | | whose patterns are template arguments. We can now instantiate, e.g., typedef tuple<pair<OuterTypes, InnerTypes>...> type; where OuterTypes and InnerTypes are template type parameter packs. There is a horrible inefficiency in TemplateArgumentLoc::getPackExpansionPattern(), where we need to create copies of TypeLoc data because our interfaces traffic in TypeSourceInfo pointers where they should traffic in TypeLocs instead. I've isolated in efficiency in this one routine; once we refactor our interfaces to traffic in TypeLocs, we can eliminate it. llvm-svn: 122278
* Move the functionality to mark all vtables of key functions as used withinChandler Carruth2010-12-121-0/+12
| | | | | | | | | | | | | | a translation unit to the ActOnEndOfTranslationUnit function instead of doing it at the start of DefineUsedVTables. The latter is now called *recursively* during template instantiation, which causes an absolutely insane number of walks of every record decl in the translation unit. After this patch, an extremely template instantiation heavy test case's compile time drops by 10x, and we see between 15% and 20% improvement in average compile times across a project. This is just recovering a regression, it doesn't make anything faster than it was several weeks ago. llvm-svn: 121644
* Tie DefineVTablesUsed() in with recursive function instantiation so that we emitNick Lewycky2010-11-251-20/+18
| | | | | | | | | | a useful template instantiation stack. Fixes PR8640. This also causes a slight change to where the "instantianted from" note shows up in truly esoteric cases (see the change to test/SemaCXX/destructor.cpp), but that isn't directly the fault of this patch. llvm-svn: 120135
* Refactoring. Get FunctionScopeInfo to use DiagnosticErrorTrap.Argyrios Kyrtzidis2010-11-191-9/+7
| | | | llvm-svn: 119764
* Refactoring of Diagnostic class.Argyrios Kyrtzidis2010-11-181-6/+6
| | | | | | | | | | | -Move the stuff of Diagnostic related to creating/querying diagnostic IDs into a new DiagnosticIDs class. -DiagnosticIDs can be shared among multiple Diagnostics for multiple translation units. -The rest of the state in Diagnostic object is considered related and tied to one translation unit. -Have Diagnostic point to the SourceManager that is related with. Diagnostic can now accept just a SourceLocation instead of a FullSourceLoc. -Reflect the changes to various interfaces. llvm-svn: 119730
* Fix a silly bug in the suppression of non-error diagnostics in aDouglas Gregor2010-10-131-0/+2
| | | | | | | SFINAE context, where we weren't getting the right diagnostic argument count. I blame DiagnosticBuilder's weirdness. Fixes PR8372. llvm-svn: 116411
* Introduce support for emitting diagnostics (warnings + their notes)Douglas Gregor2010-10-121-19/+36
| | | | | | | | | | | | | | | that are suppressed during template argument deduction. This change queues diagnostics computed during template argument deduction. Then, if the resulting function template specialization or partial specialization is chosen by overload resolution or partial ordering (respectively), we will emit the queued diagnostics at that point. This addresses most of PR6784. However, the check for unnamed/local template arguments (which existed before this change) is still only skin-deep, and needs to be extended to look deeper into types. It must be improved to finish PR6784. llvm-svn: 116373
* Move ExternalSemaSource::ReadMethodPool's implementation to Sema.cpp so that ↵Sebastian Redl2010-09-281-0/+6
| | | | | | the header can get away with forward declarations only for ObjCMethodList and Selector. Fixes <rdar://8467631>. llvm-svn: 114978
* Fix a few minor issues with parsing and semantic analysis of C++Douglas Gregor2010-09-081-1/+1
| | | | | | | | typeid expressions: - make sure we have a proper source location for the closing ')' - cache the declaration of std::type_info once we've found it llvm-svn: 113441
* Initialize the MSVCGuidDecl variable in the correct order.Bill Wendling2010-09-081-2/+3
| | | | llvm-svn: 113412
* Microsoft's __uuidof operator implementation part 1.Francois Pichet2010-09-081-1/+1
| | | | llvm-svn: 113356
* Devirtualize Sema, kill off DeleteExpr and DeleteStmt, and reformat.John McCall2010-09-031-5/+0
| | | | llvm-svn: 112945
* One who seeks knowledge learns something new every day.John McCall2010-08-261-0/+19
| | | | | | | | | One who seeks the Tao unlearns something new every day. Less and less remains until you arrive at non-action. When you arrive at non-action, nothing will be left undone. llvm-svn: 112244
* Restore r112114 now that SmallVector<...,0> is safe.John McCall2010-08-261-2/+2
| | | | llvm-svn: 112148
* Revert r112114, "Pull DelayedDiagnostic and AccessedEntity out into their ownDaniel Dunbar2010-08-261-2/+2
| | | | | | header.", it is teh broken. llvm-svn: 112123
* Pull DelayedDiagnostic and AccessedEntity out into their own header.John McCall2010-08-251-2/+2
| | | | | | | | This works courtesy of the new SmallVector<..., 0> specialization that doesn't require a complete type. Note that you'll need to pull at least SmallVector.h from LLVM to compile successfully. llvm-svn: 112114
* Split out a header to hold APIs meant for the Sema implementation from Sema.h.John McCall2010-08-251-0/+1
| | | | | | | Clients of Sema don't need to know (for example) the list of diagnostics we support. llvm-svn: 112093
* Initialize the translation-unit scope before lexing the firstDouglas Gregor2010-08-251-1/+1
| | | | | | | token. The first token might be something that ends up triggering code completion, which in turn requires a valid Scope. Test case forthcoming. llvm-svn: 112066
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-1/+1
| | | | | | to the new constants. llvm-svn: 112047
* More incremental progress towards not including Expr.h in Sema.h.John McCall2010-08-251-10/+6
| | | | llvm-svn: 112044
OpenPOWER on IntegriCloud