summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Note when a decl is used in AST files.Eli Friedman2013-09-051-5/+5
| | | | | | | | | | | | | | | When an AST file is built based on another AST file, it can use a decl from the fist file, and therefore mark the "isUsed" bit. We need to note this in the AST file so that the bit is set correctly when the second AST file is loaded. This patch introduces the distinction between setIsUsed() and markUsed() so that we don't call into the ASTMutationListener callback when it wouldn't be appropriate. Fixes PR16635. llvm-svn: 190016
* Reference extension is weird/surprising and unnecessary, let's not do that.David Blaikie2013-09-031-1/+1
| | | | | | Found by Chris Wailes llvm-svn: 189859
* the call to UsualArithmeticConversions should come after the call to ↵Jin-Gu Kang2013-09-021-8/+9
| | | | | | CheckVectorOperands on CheckConditionalOperands function. This problem caused compilation error with test17 on "test/CodeGen/ext-vector.c". llvm-svn: 189773
* Handle predefined expression for a captured statementWei Pan2013-08-261-0/+2
| | | | | | | | | | | - __func__ or __FUNCTION__ returns captured statement's parent function name, not the one compiler generated. Differential Revision: http://llvm-reviews.chandlerc.com/D1491 Reviewed by bkramer llvm-svn: 189219
* Split isFromMainFile into two functions.Eli Friedman2013-08-221-1/+1
| | | | | | | | | Basically, isInMainFile considers line markers, and isWrittenInMainFile doesn't. Distinguishing between the two is useful when dealing with files which are preprocessed files or rewritten with -frewrite-includes (so we don't, for example, print useless warnings). llvm-svn: 188968
* Sema: Use the right type for PredefinedExpr when it's in a lambda.Benjamin Kramer2013-08-211-8/+8
| | | | | | | | | | | | | 1. We now print the return type of lambdas and return type deduced functions as "auto". Trailing return types with decltype print the underlying type. 2. Use the lambda or block scope for the PredefinedExpr type instead of the parent function. This fixes PR16946, a strange mismatch between type of the expression and the actual result. 3. Verify the type in CodeGen. 4. The type for blocks is still wrong. They are numbered and the name is not known until CodeGen. llvm-svn: 188900
* PR16727: don't try to evaluate a potentially value-dependent expression whenRichard Smith2013-08-191-2/+4
| | | | | | checking for missing parens in &&/|| expressions. llvm-svn: 188716
* Refactor all diagnosing of TypoCorrections through a common function, inRichard Smith2013-08-171-70/+47
| | | | | | | preparation for teaching this function how to diagnose a correction that includes importing a module. llvm-svn: 188602
* Don't allow unary negation on scoped enums.Eli Friedman2013-08-161-3/+0
| | | | | | PR16900. llvm-svn: 188511
* sizeof(void) etc. should be a hard error in C++.Eli Friedman2013-08-131-0/+16
| | | | | | PR16872. llvm-svn: 188324
* Omit llvm:: before ArrayRef, as we have using llvm::ArrayRef in ↵Robert Wilhelm2013-08-091-1/+1
| | | | | | include/clang/Basic/LLVM.h. llvm-svn: 188089
* Emit an error for enum increments and decrements in C++ mode.Richard Trieu2013-08-081-0/+4
| | | | | | Fixes PR16394. llvm-svn: 187955
* Started implementing variable templates. Top level declarations should be ↵Larisse Voufo2013-08-061-36/+98
| | | | | | fully supported, up to some limitations documented as FIXMEs or TODO. Static data member templates work very partially. Static data member templates of class templates need particular attention... llvm-svn: 187762
* Implement C++'s restrictions on the type of an expression passed to a varargRichard Smith2013-08-051-18/+44
| | | | | | | | | | | | | function: it can't be 'void' and it can't be an initializer list. We give a hard error for these rather than treating them as undefined behavior (we can and probably should do the same for non-POD types in C++11, but as of this change we don't). Slightly rework the checking of variadic arguments in a function with a format attribute to ensure that certain kinds of format string problem (non-literal string, too many/too few arguments, ...) don't suppress this error. llvm-svn: 187735
* Sema: Don't assume a nested name specifier holds a typeDavid Majnemer2013-08-051-2/+1
| | | | | | | | | Sema::PerformObjectMemberConversion assumed that the Qualifier it was given holds a type. However, the specifier could hold just a namespace. In this case, we should ignore the qualifier and not attempt to cast to it. llvm-svn: 187715
* ObjectiveC ARC: finishing off issuing error whenFariborz Jahanian2013-07-311-3/+11
| | | | | | | retainable pointer is passed to an audited CF function expecting CF type. // rdar://14569171 llvm-svn: 187543
* ObjectiveC ARC: Do not issue bridge cast diagnostic whenFariborz Jahanian2013-07-311-2/+4
| | | | | | | | passing a retainable object arg to a CF audited function expecting a CF object type. Issue a normal type mismatch diagnostic. This is wip // rdar://14569171 llvm-svn: 187532
* ObjectiveC arc: minor refactoring in my last patchFariborz Jahanian2013-07-311-2/+5
| | | | | | to avoid future false positives. // rdar://14569171 llvm-svn: 187509
* ObjectiveC arc: Introduce a new initialization kindFariborz Jahanian2013-07-311-0/+6
| | | | | | | | for parameters passed to CF audited functions to be used for better diagnostics. Current set but unused. // rdar://14569171 llvm-svn: 187508
* ObjectiveC arc: Move check for type conversions in arcFariborz Jahanian2013-07-311-7/+19
| | | | | | | | out of ImpCastExprToType and to the caller site as appropriate. This is in prep. to do more work for // rdar://14569171 llvm-svn: 187503
* Fix a crasher than manifests when typo correction suggests a function template.Richard Trieu2013-07-311-2/+2
| | | | llvm-svn: 187467
* Partially revert r186903.Eli Friedman2013-07-261-1/+1
| | | | | | | | It turns out that Plum Hall depends on us not emitting an error on integer literals which fit into long long, but fit into unsigned long long. So C99 conformance requires not conforming to C99. :) llvm-svn: 187172
* Integers which are too large should be an error.Eli Friedman2013-07-231-4/+4
| | | | | | | | Switch some warnings over to errors which should never have been warnings in the first place. (Also, a minor fix to the preprocessor rules for integer literals while I'm here.) llvm-svn: 186903
* Don't emit open-paren fixit without close-paren.Eli Friedman2013-07-221-0/+4
| | | | | | | | | | getLocForEndOfToken() isn't guaranteed to succeed; if it doesn't, make sure we do something sane. Fixes PR16673. I'm not sure how to write a testcase for this short of grepping through the diagnostic output. llvm-svn: 186889
* Make IgnoreParens() look through ChooseExprs.Eli Friedman2013-07-201-2/+4
| | | | | | | | | | | | | This is the same way GenericSelectionExpr works, and it's generally a more consistent approach. A large part of this patch is devoted to caching the value of the condition of a ChooseExpr; it's needed to avoid threading an ASTContext into IgnoreParens(). Fixes <rdar://problem/14438917>. llvm-svn: 186738
* Clean up diagnostics for inheriting constructors.Eli Friedman2013-07-181-3/+20
| | | | | | | No new diagnostics, just better wording and notes pointing at more relevant locations. llvm-svn: 186629
* Improve idiomatic-parentheses by checking method family instead of relying ↵Jean-Daniel Dupas2013-07-171-1/+1
| | | | | | on the selector name. llvm-svn: 186524
* Make Expr::isConstantInitializer match IRGen.Eli Friedman2013-07-161-1/+1
| | | | | | | | | | Sema needs to be able to accurately determine what will be emitted as a constant initializer and what will not, so we get accurate errors in C and accurate -Wglobal-constructors warnings in C++. This makes Expr::isConstantInitializer match CGExprConstant as closely as possible. llvm-svn: 186464
* Make CheckAddressOfOperand a member of Sema so it can be reused byRichard Smith2013-07-111-35/+34
| | | | | | __builtin_addressof. llvm-svn: 186052
* Attempt typo correction for function calls with the wrong number of arguments.Kaelyn Uhrain2013-07-081-4/+98
| | | | | | | | | | | | | | | Combined with typo correction's new ability to apply global/absolute nested name specifiers to possible corrections, cases such as in PR12287 where the desired function is being shadowed by a lexically closer function with the same name but a different number of parameters will now include a FixIt. On a side note, since the test for this change caused test/SemaCXX/typo-correction.cpp to exceed the typo correction limit for a single file, I've included a test case for exceeding the limit and added some comments to both the original and part two of typo-correction.cpp warning future editors of the files about the limit. llvm-svn: 185881
* Fix Sema for compares with _Atomic vars.Eli Friedman2013-07-081-25/+6
| | | | | | | | | | | | | | | | Use UsualArithmeticConversions unconditionally in analysis of comparisons and conditional operators: the method performs the usual arithmetic conversions if both sides are arithmetic, and usual unary conversions if they are not. This is just a cleanup for conditional operators; for comparisons, it fixes the issue that we would try to check isArithmetic() on an atomic type. Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables of atomic type correctly. Fixes PR15537. llvm-svn: 185857
* Use SmallVectorImpl& for function arguments instead of SmallVector.Craig Topper2013-07-051-1/+1
| | | | llvm-svn: 185715
* Sema: Call IgnoreParens fewer times in CheckAddressOfOperandDavid Majnemer2013-07-051-4/+4
| | | | llvm-svn: 185684
* Add typedefs for Densemaps containing SmallVectors to avoid repeating the ↵Craig Topper2013-07-051-1/+1
| | | | | | SmallVector size when creating iterators for the DenseMap. llvm-svn: 185682
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-1/+1
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* Improve -Wlogical-not-parentheses to catch when the not is applied to an enum.Richard Trieu2013-07-041-1/+1
| | | | llvm-svn: 185602
* Allow typo correction to try removing nested name specifiers.Kaelyn Uhrain2013-07-021-6/+8
| | | | | | | | | | | | | | | | | The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487
* Fix mangling for block literals.Eli Friedman2013-07-011-7/+14
| | | | | | | | | | | | | | | Blocks, like lambdas, can be written in contexts which are required to be treated as the same under ODR. Unlike lambdas, it isn't possible to actually take the address of a block, so the mangling of the block itself doesn't matter. However, objects like static variables inside a block do need to be mangled in a consistent way. There are basically three components here. One, block literals need a consistent numbering. Two, objects/types inside a block literal need to be mangled using it. Three, objects/types inside a block literal need to have their linkage computed correctly. llvm-svn: 185372
* Ensure that debugger calls to signature-less functions default toJohn McCall2013-06-271-3/+42
| | | | | | | | | | | | | | | | | | | | | passing arguments in the fixed style. We have an abstraction for deciding this, but it's (1) deep in IR-generation, (2) necessarily tied to exact argument lists, and (3) triggered by unprototyped function types, which we can't legitimately make in C++ mode. So this solution, wherein Sema rewrites the function type to an exact prototype but leaves the variadic bit enabled so as to request x86-64-like platforms to pass the extra variadic info, is very much a hack, but it's one that works in practice on the platforms that LLDB will support in the medium term --- the only place we know of where it's a problem is instance methods in Windows, where variadic functions are implicitly cdecl. We may have a more abstracted base on which to build a solution by then. rdar://13731520 llvm-svn: 185112
* Delete dead code.Eli Friedman2013-06-271-26/+1
| | | | llvm-svn: 185053
* Don't use unnamed local enums as template arguments.Joerg Sonnenberger2013-06-261-4/+4
| | | | | | Fixes -Werror bootstrap. llvm-svn: 185023
* Fix PCH bug with member templates of local classes in nontemplate functions. Faisal Vali2013-06-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | As noted by Richard in the post: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130624/082605.html, the following code should not add an entry into PendingLocalImplicitInstantiations, since local instantiations should only occur within the context of other instantiations: int foo(double y) { struct Lambda { template<class T> T operator()(T t) const { return t; }; } lambda; return lambda(y); } Hence the attached code does the following: 1) In MarkFunctionReferenced, check if ActiveInstantiations.size() is non-zero before adding to PendingLocalImplicitInstantiations. 2) In InstantiateFunctionDefinition, we swap out/in PendingLocalImplicitInstantiations so that only those pending local instantiations that are added during the instantiation of the current function are instantiated recursively. llvm-svn: 184903
* Tweak -Wdeprecated-objc-pointer-introspection to have a subgroup for results ↵Ted Kremenek2013-06-241-1/+14
| | | | | | | | | | | | | of using -performSelectorXXX. -performSelector: and friends return a value that is boxed as an Objective-C pointer. Sometimes it is an Objective-C pointer, sometimes it isn't. Some clients may wish to silence this warning based on calling this method. Fixes <rdar://problem/14147304> llvm-svn: 184789
* [AST] Introduce a new DecayedType sugar nodeReid Kleckner2013-06-241-0/+2
| | | | | | | | | | | | | | The goal of this sugar node is to be able to look at an arbitrary FunctionType and tell if any of the parameters were decayed from an array or function type. Ultimately this is necessary to implement Microsoft's C++ name mangling scheme, which mangles decayed arrays differently from normal pointers. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1014 llvm-svn: 184763
* Extend -Wnon-pod-varargs to check calls made from member pointers.Richard Trieu2013-06-221-1/+2
| | | | llvm-svn: 184629
* Extend -Wnon-pod-varargs to more cases, such as function pointers as returnRichard Trieu2013-06-221-0/+3
| | | | | | types and function pointer arrays. llvm-svn: 184616
* Extend -Wnon-pod-varargs to check calls made from function pointers.Richard Trieu2013-06-201-1/+1
| | | | llvm-svn: 184470
* [Windows] Fix __declspec(property) when the getter returns a refReid Kleckner2013-06-191-1/+2
| | | | | | | | This fixes an issue when parsing atlbase.h. Patch by Will Wilson! llvm-svn: 184319
* Unify return type checking for functions and ObjC methods. Move all theEli Friedman2013-06-141-7/+0
| | | | | | | | random checks for ObjC object return types to SemaType.cpp. Fixes issue with ObjC method type checking reported on cfe-dev. llvm-svn: 184006
* Fix the warning for divide by zero to be a bit more robust. ;]Chandler Carruth2013-06-141-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, it only ever fired for zeros which formed null pointers. Now, hilariously, in C++98 this was almost anything. Including tricks like warning on the divisor in this code: typedef char c3[3]; size_t f(c3* ptr) { return (sizeof(ptr) / sizeof(*ptr)) / (size_t)(!(sizeof(ptr) % sizeof(*ptr))); } Why the RHS of the outer divide is a null pointer constant is a sordid tale of sorrow. Anyways, the committee fixed this for C++11 and onward as part of core isssue 903, and Richard recently implemented this fix causing the warning to go away here (and elsewhere). This patch restores the warning here and adds it for numerous other somewhat obvious gaffes: int g(int x) { return x / (int)(0.0); } The patch is essentially just using the full power of our constant folding in Clang to produce the warning, but insisting that it must fold to an *integer* which is zero so that we don't get false positives anywhere. llvm-svn: 183970
OpenPOWER on IntegriCloud