summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r145244. It causes us to create broken ASTs with missing type informationRichard Smith2011-11-291-43/+15
| | | | | | | | | | for some cast expressions. Original commit message: Removed useless ImplicitCast nodes in explicit cstyle and static casts llvm-svn: 145447
* Removed useless ImplicitCast nodes in explicit cstyle and static castsNicola Gigante2011-11-281-15/+43
| | | | llvm-svn: 145244
* Test commitNicola Gigante2011-11-261-0/+1
| | | | llvm-svn: 145147
* Fixed plausible overloads location.Abramo Bagnara2011-11-151-1/+1
| | | | llvm-svn: 144700
* Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally addRichard Smith2011-11-101-0/+1
| | | | | | | | | | them when performing a const conversion on the implicit object argument for a member operator call on an rvalue. No change to the testsuite: the test for this change is that the added assertion does not fire any more. llvm-svn: 144333
* There's no good reason to track temporaries in ExprWithCleanups,John McCall2011-11-101-1/+1
| | | | | | | but it is sometimes useful to track blocks. Do so. Also optimize the storage of these expressions. llvm-svn: 144263
* Add (hopefully) the last missing lvalue-to-rvalue conversion. Add an assertionRichard Smith2011-10-281-0/+14
| | | | | | to catch some future implicit lvalue-to-rvalue casts of inappropriate kinds. llvm-svn: 143182
* Make the loading of information attached to an IdentifierInfo from anDouglas Gregor2011-10-271-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* -Wc++98-compat: warn if a SFINAE substitution in C++11 suppresses an accessRichard Smith2011-10-191-7/+25
| | | | | | control diagnostic. llvm-svn: 142463
* For modules, all macros that aren't include guards are implicitlyDouglas Gregor2011-10-171-28/+0
| | | | | | | public. Add a __private_macro__ directive to hide a macro, similar to the __module_private__ declaration specifier. llvm-svn: 142188
* HasFormOfMemberPointer implies IsAddressOfOperand for an overload set. SimplifyDouglas Gregor2011-10-131-2/+2
| | | | llvm-svn: 141878
* Allow calling an overloaded function set by taking the address of theDouglas Gregor2011-10-131-4/+2
| | | | | | functions, e.g., (&f)(0). Fixes <rdar://problem/9803316>. llvm-svn: 141877
* Catch placeholder types in DefaultLvalueConversionJohn McCall2011-10-111-16/+100
| | | | | | | | | | | and DefaultFunctionArrayLvalueConversion. To prevent significant regression for should-this-be-a-call fixits, and to repair some such regression from the introduction of bound member placeholders, make those placeholder checks try to build calls appropriately. Harden the build-a-call logic while we're at it. llvm-svn: 141738
* When using an unavailable/deprecated interface Foo inside Foo's ↵Argyrios Kyrtzidis2011-10-061-1/+2
| | | | | | | | interface/implementation don't emit unavailable errors. llvm-svn: 141334
* Only print _Bool as 'bool' when 'bool' is defined as an object-likeDouglas Gregor2011-09-271-0/+17
| | | | | | macro whose only replacement token is '_Bool'. llvm-svn: 140656
* Get rid of useless helper Sema::CastCategory.Eli Friedman2011-09-271-6/+0
| | | | llvm-svn: 140642
* Rename DiagnosticInfo to Diagnostic as per issue 5397David Blaikie2011-09-261-1/+1
| | | | llvm-svn: 140493
* Rename Diagnostic to DiagnosticsEngine as per issue 5397David Blaikie2011-09-251-2/+2
| | | | llvm-svn: 140478
* Introduce an egregious hack for modules to cope with headers that comeDouglas Gregor2011-09-201-0/+29
| | | | | | | | from unfriendly (== not at all modularized) directories. This is temporary, and it only affects module construction until I'll figured out how to deal with system headers. llvm-svn: 140159
* Give conversions of block pointers to ObjC pointers a different cast kindJohn McCall2011-09-091-1/+3
| | | | | | | | than conversions of C pointers to ObjC pointers. In order to ensure that we've caught every case, add asserts to CastExpr that strictly determine which cast kind is used for which kind of bit cast. llvm-svn: 139352
* Warn on missing [super finalize] calls.Nico Weber2011-08-281-0/+1
| | | | | | This matches gcc's logic. Second half of PR10661. llvm-svn: 138730
* Introduce a -cc1 option "-emit-module", that creates a binary moduleDouglas Gregor2011-08-251-6/+13
| | | | | | | | | from the given source. -emit-module behaves similarly to -emit-pch, except that Sema is somewhat more strict about the contents of -emit-module. In the future, there are likely to be more interesting differences. llvm-svn: 138595
* Warn on missing [super dealloc] calls.Nico Weber2011-08-221-0/+1
| | | | | | This matches gcc's logic. Half of PR10661. llvm-svn: 138240
* Switch the __int128_t and __uint128_t types over to predefined typesDouglas Gregor2011-08-121-32/+24
| | | | | | | in the AST format, which are built lazily by the ASTContext when requested. llvm-svn: 137437
* Switch the Objective-C 'SEL' type over to a predefined type in theDouglas Gregor2011-08-121-13/+6
| | | | | | | AST file format, lazily generating the actual declaration in ASTContext as needed. llvm-svn: 137434
* Switch the Objective-C 'Class' type over to a predefined type in theDouglas Gregor2011-08-121-13/+5
| | | | | | | AST file format, lazily generating the actual declaration in ASTContext as needed. llvm-svn: 137431
* Move the creation of the predefined typedef for Objective-C's 'id'Douglas Gregor2011-08-121-12/+10
| | | | | | | | | type over into the AST context, then make that declaration a predefined declaration in the AST format. This ensures that different AST files will at least agree on the (global) declaration ID for 'id', and eliminates one of the "special" types in the AST file format. llvm-svn: 137429
* Encapsulate the Objective-C id/Class/SEL "redefinition" types inDouglas Gregor2011-08-111-3/+0
| | | | | | | | | ASTContext with accessors/mutators. The only functional change is that the AST writer won't bother writing the id/Class/SEL redefinition type if it hasn't been explicitly set; previously, it ended up being written as a synonym for the built-in id/Class/SEL. llvm-svn: 137349
* Make Sema::WeakUndeclaredIdentifiers lazily deserialized.Douglas Gregor2011-07-281-0/+17
| | | | llvm-svn: 136368
* Switch Sema::DynamicClasses over to LazyVectorDouglas Gregor2011-07-281-5/+6
| | | | llvm-svn: 136317
* Switch Sema::UnusedFileScopedDecls over to a LazyVector. Douglas Gregor2011-07-271-3/+7
| | | | | | | | | - Added LazyVector::erase() to support this use case. - Factored out the LazyDecl-of-Decls to RecordData translation in the ASTWriter. There is still a pile of code duplication here to eliminate. llvm-svn: 136270
* Introduce a new data structure, LazyVector, which is a vector whoseDouglas Gregor2011-07-271-2/+6
| | | | | | | | | | | | | contents are lazily loaded on demand from an external source (e.g., an ExternalASTSource or ExternalSemaSource). The "loaded" entities are kept separate from the "local" entities, so that the two can grow independently. Switch Sema::TentativeDefinitions from a normal vector that is eagerly populated by the ASTReader into one of these LazyVectors, making the ASTReader a bit more like me (i.e., lazy). llvm-svn: 136262
* Cleanup the stray comments and variables I could dig out of Sema toChandler Carruth2011-07-261-4/+4
| | | | | | refer to 'expansion' instead of 'instantiation'. llvm-svn: 136060
* Mechanically rename SourceManager::getInstantiationLoc andChandler Carruth2011-07-251-1/+1
| | | | | | | | FullSourceLoc::getInstantiationLoc to ...::getExpansionLoc. This is part of the API and documentation update from 'instantiation' as the term for macros to 'expansion'. llvm-svn: 135914
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-9/+9
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Build up statistics about the work done for analysis based warnings.Chandler Carruth2011-07-061-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Special detail is added for uninitialized variable analysis as this has serious performance problems than need to be tracked. Computing some of this data is expensive, for example walking the CFG to determine its size. To avoid doing that unless the stats data is going to be used, we thread a bit into the Sema object to track whether detailed stats should be collected or not. This bit is used to avoid computations whereever the computations are likely to be more expensive than checking the state of the flag. Thus, counters are in some cases unconditionally updated, but the more expensive (and less frequent) aggregation steps are skipped. With this patch, we're able to see that for 'gcc.c': *** Analysis Based Warnings Stats: 232 functions analyzed (0 w/o CFGs). 7151 CFG blocks built. 30 average CFG blocks per function. 1167 max CFG blocks per function. 163 functions analyzed for uninitialiazed variables 640 variables analyzed. 3 average variables per function. 94 max variables per function. 96409 block visits. 591 average block visits per function. 61546 max block visits per function. And for the reduced testcase in PR10183: *** Analysis Based Warnings Stats: 98 functions analyzed (0 w/o CFGs). 8526 CFG blocks built. 87 average CFG blocks per function. 7277 max CFG blocks per function. 68 functions analyzed for uninitialiazed variables 1359 variables analyzed. 19 average variables per function. 1196 max variables per function. 2540494 block visits. 37360 average block visits per function. 2536495 max block visits per function. That last number is the somewhat scary one that indicates the problem in PR10183. llvm-svn: 134494
* Add support for C++ namespace-aware typo correction, e.g., correctingDouglas Gregor2011-06-281-0/+6
| | | | | | | | | | | | | | | 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
* Automatic Reference Counting.John McCall2011-06-151-5/+35
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Whenever we instantiate a static data member, make sure to define any newNick Lewycky2011-05-311-24/+16
| | | | | | | | | vtables! Fixes PR10020 This also allows us to revert the part of r130023 which added a big loop around the template instantiation. llvm-svn: 132331
* Implement CWG1170, which makes access-control errors into templateDouglas Gregor2011-05-111-3/+6
| | | | | | | argument deduction failures. Only implemented in C++0x, since this is a significant change in behavior from C++98/03. llvm-svn: 131209
* 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
OpenPOWER on IntegriCloud