summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/Sema.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix ODR-use of a MemberExpr to check before marking a pure function used. RemoveNick Lewycky2013-01-311-1/+1
| | | | | | a workaround for this bug from the -Wundefined-internals warning. llvm-svn: 174020
* Remove function that is newly dead as of r173538.Nick Lewycky2013-01-261-4/+0
| | | | llvm-svn: 173550
* Preserve Sema::UndefinedInternals across PCH boundaries. FixesNick Lewycky2013-01-261-16/+8
| | | | | | -Wundefined-internal warnings with PCH. llvm-svn: 173538
* The standard ARM C++ ABI dictates that inline functions areJohn McCall2013-01-251-1/+1
| | | | | | | | never key functions. We did not implement that rule for the iOS ABI, which was driven by what was implemented in gcc-4.2. However, implement it now for other ARM-based platforms. llvm-svn: 173515
* Fixed trailing whitespace.Michael Gottesman2013-01-201-44/+44
| | | | llvm-svn: 172939
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-1/+1
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* Mark all subsequent decls used.Rafael Espindola2013-01-081-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | In the source static void f(); static void f(); template<typename T> static void g() { f(); } static void f() { } void h() { g<int>(); } the call to f refers to the second decl, but it is only marked used at the end of the translation unit during instantiation, after the third f decl has been linked in. With this patch we mark all subsequent decls used, so that it is easy to check if a symbol is used or not. llvm-svn: 171888
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-2/+2
| | | | llvm-svn: 171367
* Don't warn on unused member functions that are extern because of a typedef.Rafael Espindola2012-12-301-0/+3
| | | | llvm-svn: 171267
* Don't warn for undefined but used decls that are external because of a typedef.Rafael Espindola2012-12-291-0/+3
| | | | | | | | This fixes pr14736. It is fairly ugly, but I don't think we can do much better as we have to wait at least until the end of the typedef to know if the function will have external linkage or not. llvm-svn: 171240
* Fix a regression from the previous commit.Rafael Espindola2012-12-261-1/+5
| | | | | | | Template instantiation can set the canonical decl to used after subsequent decls have been chained, so we have to check that too. llvm-svn: 171088
* Use the most recent redecl to decide if it is needed.Rafael Espindola2012-12-261-1/+1
| | | | | | This fixes pr14691, which I think is a regression from r168519. llvm-svn: 171077
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-16/+16
| | | | | | | | | | | | | 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
* Reject uses of __int128 on platforms that don't support it. Also move the uglyRichard Smith2012-11-291-1/+1
| | | | | | | 'getPointerWidth(0) >= 64' test to be a method on TargetInfo, ready to be properly cleaned up. llvm-svn: 168856
* Use a .def file for most of the diagnostic options.Douglas Gregor2012-10-231-2/+1
| | | | llvm-svn: 166520
* Add a new warning -Wmissing-variable-declarations, to warn about variablesEli Friedman2012-10-231-0/+2
| | | | | | | | | defined without a previous declaration. This is similar to -Wmissing-prototypes, but for variables instead of functions. Patch by Ed Schouten. llvm-svn: 166498
* From Vassil Vassilev: enable Sema to deal with multiple ExternalSemaSources.Axel Naumann2012-10-181-2/+29
| | | | llvm-svn: 166208
* Pull ScopeInfo implementation into its own file.Jordan Rose2012-09-281-159/+0
| | | | | | | | | The infrastructure for -Warc-repeated-use-of-weak got a little too heavy to leave sitting at the top of Sema.cpp. No functionality change. llvm-svn: 164856
* -Warc-repeated-use-of-weak: check ivars and variables as well.Jordan Rose2012-09-281-60/+77
| | | | | | | | | | Like properties, loading from a weak ivar twice in the same function can give you inconsistent results if the object is deallocated between the two loads. It is safer to assign to a strong local variable and use that. Second half of <rdar://problem/12280249>. llvm-svn: 164855
* Add a warning (off by default) for repeated use of the same weak property.Jordan Rose2012-09-281-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivating example: if (self.weakProp) use(self.weakProp); As with any non-atomic test-then-use, it is possible a weak property to be non-nil at the 'if', but be deallocated by the time it is used. The correct way to write this example is as follows: id tmp = self.weakProp; if (tmp) use(tmp); The warning is controlled by -Warc-repeated-use-of-receiver, and uses the property name and base to determine if the same property on the same object is being accessed multiple times. In cases where the base is more complicated than just a single Decl (e.g. 'foo.bar.weakProp'), it picks a Decl for some degree of uniquing and reports the problem under a subflag, -Warc-maybe-repeated-use-of-receiver. This gives a way to tune the aggressiveness of the warning for a particular project. The warning is not on by default because it is not flow-sensitive and thus may have a higher-than-acceptable rate of false positives, though it is less noisy than -Wreceiver-is-weak. On the other hand, it will not warn about some cases that may be legitimate issues that -Wreceiver-is-weak will catch, and it does not attempt to reason about methods returning weak values. Even though this is not a real "analysis-based" check I've put the bug emission code in AnalysisBasedWarnings for two reasons: (1) to run on every kind of code body (function, method, block, or lambda), and (2) to suggest that it may be enhanced by flow-sensitive analysis in the future. The second (smaller) half of this work is to extend it to weak locals and weak ivars. This should use most of the same infrastructure. Part of <rdar://problem/12280249> llvm-svn: 164854
* Fix crash when a decltype expression in a trailing return type refers to theRichard Smith2012-09-251-0/+1
| | | | | | | | | | function being instantiated. An error recovery codepath was recursively performing name lookup (and triggering an unbounded stack of template instantiations which blew out the stack before hitting the depth limit). Patch by Wei Pan! llvm-svn: 164586
* Conditionally parse documentation comments in system headers byTed Kremenek2012-09-131-0/+3
| | | | | | | | | | passing -fretain-comments-from-system-headers. By default, the compiler no longer parses such documentation comments, as they can result in a noticeable compile time/PCH slowdown. Fixes <rdar://problem/11860820>. llvm-svn: 163778
* Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer2012-08-231-2/+1
| | | | | | | | MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
* When code completion is enabled, don't do any work inDouglas Gregor2012-08-171-0/+5
| | | | | | Sema::ActOnEndOfTranslationUnit(). This is a (minor) optimization. llvm-svn: 162144
* Fix an assertion failure instantiating a constexpr function from within a ↵Eli Friedman2012-08-011-2/+0
| | | | | | -dealloc method. PR13401. llvm-svn: 161135
* Renamed RawComment kinds to avoid name clash.Abramo Bagnara2012-07-041-2/+2
| | | | llvm-svn: 159706
* patch to suggest 'static' function should be 'static inline' Fariborz Jahanian2012-06-271-3/+11
| | | | | | | when it appears to be unused and occurs in a header. // rdar://11202617 llvm-svn: 159282
* Add a warning about almost-Doxygen trailing comments: //< and /*< ... */Dmitri Gribenko2012-06-221-0/+18
| | | | llvm-svn: 159001
* Structured comment parsing, first step.Dmitri Gribenko2012-06-201-0/+5
| | | | | | | | | * Retain comments in the AST * Serialize/deserialize comments * Find comments attached to a certain Decl * Expose raw comment text and SourceRange via libclang llvm-svn: 158771
* Explicitly build __builtin_va_list.Meador Inge2012-06-161-0/+4
| | | | | | | The target specific __builtin_va_list types are now explicitly built instead of injecting strings into the preprocessor input. llvm-svn: 158592
* Look at incomplete FunctionTemplateDecls in order to determine whetherDaniel Jasper2012-06-141-0/+2
| | | | | | a CXXRecordDecl is complete. Fixes Bug 13086. llvm-svn: 158469
* Introduce -Wunused-private-field. If enabled, this warning detectsDaniel Jasper2012-06-061-0/+91
| | | | | | | unused private fields of classes that are fully defined in the current translation unit. llvm-svn: 158054
* When we suppress an error due to SFINAE, stash the diagnostic away with theRichard Smith2012-05-071-6/+24
| | | | | | | | | | | | | | | | | | | overload candidate, and include its message in any subsequent 'candidate not viable due to substitution failure' note we may produce. To keep the note small (since the 'overload resolution failed' diagnostics are often already very verbose), the text of the SFINAE diagnostic is included as part of the text of the note, and any notes which were attached to it are discarded. There happened to be spare space in OverloadCandidate into which a PartialDiagnosticAt could be squeezed, and this patch goes to lengths to avoid unnecessary PartialDiagnostic copies, resulting in no slowdown that I could measure. (Removal in passing of some PartialDiagnostic copies has resulted in a slightly smaller clang binary overall.) Even on a torture test, I was unable to measure a memory increase of above 0.2%. llvm-svn: 156297
* Change how we suppress access control in explicit instantiationsJohn McCall2012-05-071-1/+1
| | | | | | | | | | so that we actually accumulate all the delayed diagnostics. Do this so that we can restore those diagnostics to good standing if it turns out that we were wrong to suppress, e.g. if the tag specifier is actually an elaborated type specifier and not a declaration. llvm-svn: 156291
* Refactor DelayedDiagnostics so that it keeps diagnostics inJohn McCall2012-05-071-1/+4
| | | | | | | separate pools owned by the RAII objects that keep pushing decl state. This gives us quite a bit more flexibility. llvm-svn: 156289
* Sema: Initialize NSString method cache members.Benjamin Kramer2012-04-221-1/+3
| | | | | | Found by valgrind. llvm-svn: 155324
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. llvm-svn: 154799
* [Sema] Fix SemaDiagnosticBuilder to be inline.Daniel Dunbar2012-03-141-39/+32
| | | | | | | | | | - As with DiagnosticBuilder, it is very important that SemaDiagnosticBuilder be completely inline to ensure that the compiler can rip it apart and sink it to registers. This is good for another 30k reduction in code size. llvm-svn: 152708
* Spelling.Daniel Dunbar2012-03-131-1/+1
| | | | llvm-svn: 152644
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-8/+8
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Add clang support for new Objective-C literal syntax for NSDictionary, NSArray,Ted Kremenek2012-03-061-1/+8
| | | | | | | | | | | | | NSNumber, and boolean literals. This includes both Sema and Codegen support. Included is also support for new Objective-C container subscripting. My apologies for the large patch. It was very difficult to break apart. The patch introduces changes to the driver as well to cause clang to link in additional runtime support when needed to support the new language features. Docs are forthcoming to document the implementation and behavior of these features. llvm-svn: 152137
* Reapply r151638 and r151641.James Molloy2012-02-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug that was caught by Apple's internal buildbots was valid and also showed another bug in my implementation. These are now fixed, with regression tests added to catch them both (not Darwin-specific). Original log: ==================== Revert r151638 because it causes assertion hit on PCH creation for Cocoa.h Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. ==================== llvm-svn: 151712
* Revert r151638 because it causes assertion hit on PCH creation for Cocoa.hArgyrios Kyrtzidis2012-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | Original log: --------------------- Correctly track tags and enum members defined in the prototype of a function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. --------------------- I also reverted r151641 which was enhancement on top of r151638. llvm-svn: 151667
* Correctly track tags and enum members defined in the prototype of a ↵James Molloy2012-02-281-1/+1
| | | | | | | | | | | | | | | function, and ensure they are properly scoped. This fixes code such as: enum e {x, y}; int f(enum {y, x} n) { return 0; } This finally fixes PR5464 and PR5477. llvm-svn: 151638
* Implement C++11 [expr.call]p11: If the operand to a decltype-specifier is aRichard Smith2012-02-221-1/+2
| | | | | | | | | | | | | | | | | | function call (or a comma expression with a function call on its right-hand side), possibly parenthesized, then the return type is not required to be complete and a temporary is not bound. Other subexpressions inside a decltype expression do not get this treatment. This is implemented by deferring the relevant checks for all calls immediately within a decltype expression, then, when the expression is fully-parsed, checking the relevant constraints and stripping off any top-level temporary binding. Deferring the completion of the return type exposed a bug in overload resolution where completion of the argument types was not attempted, which is also fixed by this change. llvm-svn: 151117
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-211-1/+1
| | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. llvm-svn: 151011
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-141-0/+11
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Lambdas have a deleted default constructor and a deleted copyDouglas Gregor2012-02-121-0/+1
| | | | | | assignment operator, per C++ [expr.prim.lambda]p19. Make it so. llvm-svn: 150345
* When completing a lambda expression, make sure to check and attach theDouglas Gregor2012-02-081-2/+4
| | | | | | body of the lambda to the function call operator. llvm-svn: 150087
* Make parsing of objc @implementations more robust.Argyrios Kyrtzidis2012-02-071-0/+2
| | | | | | | | | | | | | | | | | | | Parsing of @implementations was based on modifying global state from the parser; the logic for late parsing of methods was spread in multiple places making it difficult to have a robust error recovery. -it was difficult to ensure that we don't neglect parsing the lexed methods. -it was difficult to setup the original objc container context for parsing the lexed methods after completing ParseObjCAtImplementationDeclaration and returning to top level context. Enhance parsing of @implementations by centralizing it in Parser::ParseObjCAtImplementationDeclaration(). ParseObjCAtImplementationDeclaration now returns only after an @implementation is fully parsed; all the data and logic for late parsing of methods is now in one place. This allows us to provide code-completion for late parsed methods with mis-matched braces. rdar://10775381 llvm-svn: 149987
OpenPOWER on IntegriCloud