summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move the diagnostic argument formatting function out of Sema and makeDouglas Gregor2010-02-091-245/+3
| | | | | | | it available within the AST library, of which Sema is one client. No functionality change. llvm-svn: 95701
* Add a stop gap to Sema::CorrectTypo() to correct only up to 20 typos.Ted Kremenek2010-02-021-1/+1
| | | | | | | | | | | | | | | | | This is to address a serious performance problem observed when running 'clang -fsyntax-only' on really broken source files. In one case, repeatedly calling CorrectTypo() caused one source file to be rejected after 2 minutes instead of 1 second. This patch causes typo correction to take neglible time on that file while still providing correction results for the first 20 cases. I felt this was a reasonable number for moderately broken source files. I don't claim this is the best solution. Comments welcome. It is necessary for us to address this issue because it is a serious performance problem. llvm-svn: 95049
* Add VarDecl::isThisDeclarationADefinition(), which properly encapsulates the ↵Sebastian Redl2010-01-311-6/+9
| | | | | | logic for when a variable declaration is a (possibly tentativ) definition. Add a few functions building on this, and shift C tentative definition handling over to this new functionality. This shift also kills the Sema::TentativeDefinitions map and instead simply stores all declarations in the renamed list. The correct handling for multiple tentative definitions is instead shifted to the final walk of the list. llvm-svn: 94968
* Don't a.k.a. through the primary typedef of an anonymous tag decl.John McCall2010-01-131-0/+6
| | | | llvm-svn: 93362
* Generalize target weirdness handling having proper layering in mind:Anton Korobeynikov2010-01-101-1/+8
| | | | | | | | | 1. Add helper class for sema checks for target attributes 2. Add helper class for codegen of target attributes As a proof-of-concept - implement msp430's 'interrupt' attribute. llvm-svn: 93118
* Move the -Wconversion logic into SemaChecking.cpp. There's a fair amount ofJohn McCall2010-01-041-310/+1
| | | | | | | overlap between this and -Wsign-compare, which is why I want them in the same place. llvm-svn: 92543
* Get rid of FixedWidthIntType, as suggested by Chris and Eli.Anders Carlsson2009-12-291-8/+1
| | | | llvm-svn: 92246
* Kill off PreDeclaratorDC.John McCall2009-12-191-2/+2
| | | | llvm-svn: 91772
* Rework how virtual member functions are marked. If a class has no key ↵Anders Carlsson2009-12-071-12/+21
| | | | | | function, we now wait until the end of the translation unit to mark its virtual member functions as references. This lays the groundwork for fixing PR5557. llvm-svn: 90752
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-8/+8
| | | | | | | | | | | | | | | | | | | | | variables, but the results are imperfect. For posterity, I did: cat <<EOF > $cmdfile s/DeclaratorInfo/TypeSourceInfo/g s/DInfo/TInfo/g s/TypeTypeSourceInfo/TypeSourceInfo/g s/SourceTypeSourceInfo/TypeSourceInfo/g EOF find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \; find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \; find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \; llvm-svn: 90743
* Refactor our handling of expression evaluation contexts, so that SemaDouglas Gregor2009-11-261-2/+5
| | | | | | | | | | | | maintains a stack of evaluation contexts rather than having the parser do it. This change made it simpler to track in which contexts temporaries were created, so that we could... "Forget" about temporaries created within unevaluated contexts, so that we don't build a CXXExprWithTemporaries and, therefore, destroy the integral-constness of our expressions. Fixes PR5609. llvm-svn: 89908
* Allow user re-definition of SEL as well as accessing its fields.Fariborz Jahanian2009-11-251-1/+1
| | | | | | This fixes pr5611. llvm-svn: 89895
* Make 'SEL' pointer to a builtin type and not anFariborz Jahanian2009-11-231-1/+1
| | | | | | | objective-c pointer type. This was a serious mishap and luckily, Ted's test caught that (and patch fixes the test case). llvm-svn: 89680
* This patch implements objective-c's 'SEL' type as a built-inFariborz Jahanian2009-11-211-5/+3
| | | | | | | | | | | | | | | | | | type and fixes a long-standing code gen. crash reported in at least two PRs and a radar. (radar 7405040 and pr5025). There are couple of remaining issues that I would like for Ted. and Doug to look at: Ted, please look at failure in Analysis/MissingDealloc.m. I have temporarily added an expected-warning to make the test pass. This tests has a declaration of 'SEL' type which may not co-exist with the new changes. Doug, please look at a FIXME in PCHWriter.cpp/PCHReader.cpp. I think the changes which I have ifdef'ed out are correct. They need be considered for in a few Indexer/PCH test cases. llvm-svn: 89561
* Do not enter forward class 'Protocol' in decl context.Fariborz Jahanian2009-11-181-1/+1
| | | | | | Will do it later. Fixes pr5552. llvm-svn: 89269
* Rework Sema code completion interface.Daniel Dunbar2009-11-131-2/+3
| | | | | | | | | | | | | - Provide Sema in callbacks, instead of requiring it in constructor. This eliminates the need for a factory function. Clients now just pass the object to consume the results in directly. - CodeCompleteConsumer is cheap to construct, so building it whenever we are doing code completion is reasonable. Doug, please review. llvm-svn: 87099
* Fix PR 5422: handle lvalue results when evaluating 'based' ptrtoints as part ofJohn McCall2009-11-111-3/+9
| | | | | | the -Wconversion check. llvm-svn: 86891
* Improve diagnostics when a default template argument does not matchDouglas Gregor2009-11-111-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | with its corresponding template parameter. This can happen when we performed some substitution into the default template argument and what we had doesn't match any more, e.g., template<int> struct A; template<typename T, template<T> class X = A> class B; B<long> b; Previously, we'd emit a pretty but disembodied diagnostic showing how the default argument didn't match the template parameter. The diagnostic was good, but nothing tied it to the *use* of the default argument in "B<long>". This commit fixes that. Also, tweak the counting of active template instantiations to avoid counting non-instantiation records, such as those we create for (surprise!) checking default arguments, instantiating default arguments, and performing substitutions as part of template argument deduction. llvm-svn: 86884
* Support -Wshorten-64-to-32 for integer types only, which seems to satisfy theJohn McCall2009-11-071-0/+4
| | | | | | core requirements. Fixes rdar://problem/6389954 llvm-svn: 86364
* Improve -Wconversion by permitting binary operations on values of the targetJohn McCall2009-11-071-42/+129
| | | | | | type (or smaller) to stay "closed" within the type. llvm-svn: 86356
* Implement -Wconversion. Off by default, in the non-gcc group. There'sJohn McCall2009-11-071-6/+225
| | | | | | significant work left to be done to reduce the false-positive rate here. llvm-svn: 86326
* Change our basic strategy for avoiding deprecation warnings when the decl useJohn McCall2009-11-041-1/+1
| | | | | | | | | | | | appears in a deprecated context. In the new strategy, we emit the warnings as usual unless we're currently parsing a declaration, where "declaration" is restricted to mean a decl group or a few special cases in Objective C. If we *are* parsing a declaration, we queue up the deprecation warnings until the declaration has been completely parsed, and then emit them only if the decl is not deprecated. We also standardize the bookkeeping for deprecation so as to avoid special cases. llvm-svn: 85998
* Preserve type source information in TypedefDecls. Preserve it acrossJohn McCall2009-10-241-16/+22
| | | | | | | | | template instantiation. Preserve it through PCH. Show it off to the indexer. I'm healthily ignoring the vector type cases because we don't have a sensible TypeLoc implementation for them anyway. llvm-svn: 84994
* Implement PR5242: don't desugar a type more than once in a diagnostic. ThisChris Lattner2009-10-201-14/+33
| | | | | | | | | | | | | | implements a framework that allows us to use information about previously substituted values to simplify subsequent ones. Maybe this would be useful for C++'y stuff, who knows. We now get: t.c:4:21: error: invalid operands to binary expression ('size_t' (aka 'unsigned long *') and 'size_t') return (size_t) 0 + (size_t) 0; ~~~~~~~~~~ ^ ~~~~~~~~~~ on the testcase. Note that size_t is only aka'd once. llvm-svn: 84604
* teach FormatDiagnostic to aggregate previously formatted arguments andChris Lattner2009-10-201-0/+2
| | | | | | | | | pass them down into the ArgToStringFn implementation. This allows redundancy across operands to a diagnostic to be eliminated. This isn't used yet, so no functionality change. llvm-svn: 84602
* code cleanup, convert if tree to switch etc.Chris Lattner2009-10-201-19/+26
| | | | llvm-svn: 84599
* When performing template-substitution into a type, don't just replace theJohn McCall2009-10-181-28/+100
| | | | | | | | | | | | | | | | | | TemplateTypeParmType with the substituted type directly; instead, replace it with a SubstTemplateTypeParmType which will note that the type was originally written as a template type parameter. This makes it reasonable to preserve source information even through template substitution. Also define the new SubstTemplateTypeParmType class, obviously. For consistency with current behavior, we stringize these types as if they were the underlying type. I'm not sure this is the right thing to do. At any rate, I paled at adding yet another clause to the don't-desugar 'if' statement, so I extracted a function to do it. The new function also does The Right Thing more often, I think: e.g. if we have a chain of typedefs leading to a vector type, we will now desugar all but the last one. llvm-svn: 84412
* Remove the ConstantArrayType subtypes. This information is preserved in theJohn McCall2009-10-161-3/+2
| | | | | | | | | | TypeLoc records for declarations; it should not be necessary to represent it directly in the type system. Please complain if you were using these classes and feel you can't replicate previous functionality using the TypeLoc API. llvm-svn: 84222
* Improve diagnostics when the parser encounters a declarator with anDouglas Gregor2009-10-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | unknown type name, e.g., foo::bar x; when "bar" does not refer to a type in "foo". With this change, the parser now calls into the action to perform diagnostics and can try to recover by substituting in an appropriate type. For example, this allows us to easily diagnose some missing "typename" specifiers, which we now do: test/SemaCXX/unknown-type-name.cpp:29:1: error: missing 'typename' prior to dependent type name 'A<T>::type' A<T>::type A<T>::f() { return type(); } ^~~~~~~~~~ typename Fixes PR3990. llvm-svn: 84053
* Unify our diagnostic printing for errors of the form, "we didn't likeDouglas Gregor2009-10-131-68/+89
| | | | | | | | | | what we found when we looked into <blah>", where <blah> is a DeclContext*. We can now format DeclContext*'s in nice ways, e.g., "namespace N", "the global namespace", "'class Foo'". This is part of PR3990, but we're not quite there yet. llvm-svn: 84028
* Desugaring optimizations. Add single-step desugaring methods to allJohn McCall2009-09-291-3/+10
| | | | | | | | | concrete types. Use unqualified desugaring for getAs<> and sundry. Fix a few users to either not desugar or use qualified desugar, as seemed appropriate. Removed Type's qualified desugar method, as it was easy to accidentally use instead of QualType's. llvm-svn: 83116
* Refactor the representation of qualifiers to bring ExtQualType out of theJohn McCall2009-09-241-3/+1
| | | | | | | | Type hierarchy. Demote 'volatile' to extended-qualifier status. Audit our use of qualifiers and fix a few places that weren't dealing with qualifiers quite right; many more remain. llvm-svn: 82705
* Initial implementation of a code-completion interface in Clang. InDouglas Gregor2009-09-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | essence, code completion is triggered by a magic "code completion" token produced by the lexer [*], which the parser recognizes at certain points in the grammar. The parser then calls into the Action object with the appropriate CodeCompletionXXX action. Sema implements the CodeCompletionXXX callbacks by performing minimal translation, then forwarding them to a CodeCompletionConsumer subclass, which uses the results of semantic analysis to provide code-completion results. At present, only a single, "printing" code completion consumer is available, for regression testing and debugging. However, the design is meant to permit other code-completion consumers. This initial commit contains two code-completion actions: one for member access, e.g., "x." or "p->", and one for nested-name-specifiers, e.g., "std::". More code-completion actions will follow, along with improved gathering of code-completion results for the various contexts. [*] In the current -code-completion-dump testing/debugging mode, the file is truncated at the completion point and EOF is translated into "code completion". llvm-svn: 82166
* When implicitly declaring operators new, new[], delete, and delete[],Douglas Gregor2009-09-151-1/+1
| | | | | | | | | | | | give them the appropriate exception specifications. This, unfortunately, requires us to maintain and/or implicitly generate handles to namespace "std" and the class "std::bad_alloc". However, every other approach I've come up with was more hackish, and this standard requirement itself is quite the hack. Fixes PR4829. llvm-svn: 81939
* Only reuse an already existing ImplicitCastExpr if the cast kinds are the same.Anders Carlsson2009-09-151-4/+8
| | | | llvm-svn: 81841
* Get rid of the CastInfo struct.Anders Carlsson2009-09-151-3/+2
| | | | llvm-svn: 81839
* When stringizing a NamedDecl for a diagnostic, treat the templateJohn McCall2009-09-111-2/+6
| | | | | | specialization types differently. llvm-svn: 81512
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-50/+50
| | | | llvm-svn: 81346
* Fix PR4922, where Sema would complete tentative definitions in nondeterminsticChris Lattner2009-09-081-23/+25
| | | | | | | | | | order because it was doing so while iterating over a densemap. There are still similar problems in other places, for example WeakUndeclaredIdentifiers is still written to the PCH file in a nondeterminstic order, and we emit warnings about #pragma weak in nondeterminstic order. llvm-svn: 81236
* Start emitting ElaboratedTypes in C++ mode. Support the effort in variousJohn McCall2009-09-051-0/+4
| | | | | | | | ways: remove elab types during desugaring, enhance pretty-printing to allow tags to be suppressed without suppressing scopes, look through elab types when associating a typedef name with an anonymous record type. llvm-svn: 81065
* Improve missing error messages as suggested by Doug.Anders Carlsson2009-08-301-3/+3
| | | | llvm-svn: 80489
* Improve diagnostics for missing members. This renames the ↵Anders Carlsson2009-08-301-0/+25
| | | | | | err_typecheck_no_member to err_typecheck_no_member_deprecated. The idea is that err_typecheck_no_member_deprecated should be phased out and any call sites that reference it should call DiagnoseMissingMember instead. llvm-svn: 80469
* Add a RequireCompleteType variant that takes a PartialDiagnostic. The old ↵Anders Carlsson2009-08-261-0/+10
| | | | | | RequireCompleteType now creates a PartialDiagnostic and calls the new function. llvm-svn: 80165
* Improve diagnostics and recovery when the nested-name-specifier of aDouglas Gregor2009-08-261-2/+6
| | | | | | | | | | | | qualified name does not actually refer into a class/class template/class template partial specialization. Improve printing of nested-name-specifiers to eliminate redudant qualifiers. Also, make it possible to output a nested-name-specifier through a DiagnosticBuilder, although there are relatively few places that will use this leeway. llvm-svn: 80056
* Initial patch to support definitions of id and Class from headers in ↵David Chisnall2009-08-171-0/+2
| | | | | | | | | | Objective-C code. This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable. The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa. Approved by snaroff. llvm-svn: 79248
* Add a CastInfo struct that will be used for cast information when ↵Anders Carlsson2009-08-101-2/+2
| | | | | | constructing cast expressions. Right now it only stores the cast kind, but in the future it might store conversion functions and constructors. llvm-svn: 78599
* getFunctionLevelDeclContext needs to get the previous DeclContext if ↵Anders Carlsson2009-08-081-1/+2
| | | | | | EnterDeclaratorContext has been called. Fixes PR4694. (Doug, please review) llvm-svn: 78480
* Factor some code to get the "function level" DeclContext out into a separate ↵Anders Carlsson2009-08-081-9/+11
| | | | | | function. llvm-svn: 78478
* Add CK_DerivedToBase and use it PerformObjectMemberConversion.Anders Carlsson2009-07-311-2/+3
| | | | llvm-svn: 77652
* Add a CastKind enum to CastExpr. Right now it's not used for much but it ↵Anders Carlsson2009-07-311-1/+2
| | | | | | will be :) llvm-svn: 77650
OpenPOWER on IntegriCloud