summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Since the enum values for each arch's builtins overlap, it is not ↵Nate Begeman2010-06-081-4/+33
| | | | | | appropriate to check them when compiling or other archs. Fixes a problem where compiling for NEON would use x86 sema rules. llvm-svn: 105593
* Extend __builtin_shufflevector to expose the full power of the llvm ↵Nate Begeman2010-06-081-28/+38
| | | | | | shufflevector instruction. This means it can now be used for vector truncation and concatenation. This will be used for the ARM NEON implementation. llvm-svn: 105589
* Preserve more information from a block's original function declarator, if oneJohn McCall2010-06-041-1/+1
| | | | | | | was given. Remove some unnecessary accounting from BlockScopeInfo. Handle typedef'ed function types until such time as we decide not. llvm-svn: 105478
* Tell the string literal parser when it's not permitted to emitDouglas Gregor2010-05-261-2/+3
| | | | | | | | diagnostics. That would be while we're parsing string literals for the sole purpose of producing a diagnostic about them. Fixes <rdar://problem/8026030>. llvm-svn: 104684
* Rearchitect -Wconversion and -Wsign-compare. Instead of computing themJohn McCall2010-05-061-130/+256
| | | | | | | | | | | | | | "bottom-up" when implicit casts and comparisons are inserted, compute them "top-down" when the full expression is finished. Makes it easier to coordinate warnings and thus implement -Wconversion for signedness conversions without double-warning with -Wsign-compare. Also makes it possible to realize that a signedness conversion is okay because the context is performing the inverse conversion. Also simplifies some logic that was trying to calculate the ultimate comparison/result type and getting it wrong. Also fixes a problem with the C++ explicit casts which are often "implemented" in the AST with a series of implicit cast expressions. llvm-svn: 103174
* optimize builtin_isnan/isinf to not do an extraneous extension fromChris Lattner2010-05-061-1/+14
| | | | | | | float -> double (which happens because they are modelled as int(...) functions), and add a testcase for isinf. llvm-svn: 103167
* Add FunctionDecl::isVariadic() to match BlockDecl::isVariadic() and ↵Ted Kremenek2010-04-291-8/+3
| | | | | | | | ObjCMethodDecl::isVariadic(). Do some minor refactoring along the way. llvm-svn: 102635
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-281-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* Actually produce base paths for CastExprs of kind CK_DerivedToBase.Anders Carlsson2010-04-241-1/+2
| | | | llvm-svn: 102259
* isValue is set to false by default.Anders Carlsson2010-04-241-2/+1
| | | | llvm-svn: 102246
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-1/+2
| | | | llvm-svn: 102218
* Remove the argument number from the constant integer diagnostic.Eric Christopher2010-04-191-1/+1
| | | | | | Update all of the testcases accordingly. llvm-svn: 101795
* Consolidate most of the integer constant expression builtin requirementEric Christopher2010-04-171-68/+50
| | | | | | | | checking into a single function and use that throughout. Remove some now unnecessary diagnostics and update tests with now more accurate diagnostics. llvm-svn: 101610
* Collapse the three separate initialization paths inDouglas Gregor2010-04-161-3/+1
| | | | | | | | | | | | | | | | | | TryStaticImplicitCast (for references, class types, and everything else, respectively) into a single invocation of InitializationSequence. One of the paths (for class types) was the only client of Sema::TryInitializationByConstructor, which I have eliminated. This also simplified the interface for much of the cast-checking logic, eliminating yet more code. I've kept the representation of C++ functional casts with <> 1 arguments the same, despite the fact that I hate it. That fix will come soon. To satisfy my paranoia, I've bootstrapped + tested Clang with these changes. llvm-svn: 101549
* Expand the argument diagnostics for too many arguments and giveEric Christopher2010-04-161-6/+11
| | | | | | | | both number seen and number expected. Finishes fixing PR6501. llvm-svn: 101442
* Expand argument diagnostic for too few arguments to give the numberEric Christopher2010-04-161-11/+19
| | | | | | | | of arguments both seen and expected. Fixes PR6501. llvm-svn: 101441
* Teach -Wsign-compare to treat 1 << blah as "idiomatically non-negative".John McCall2010-04-071-0/+11
| | | | | | Fixes a spurious warning in LLVM. llvm-svn: 100595
* Do not mark the destructor of a function parameter's type. Fixes PR6709.Douglas Gregor2010-03-261-4/+0
| | | | llvm-svn: 99615
* Remove support for nand atomic builtins. They are inconsistently implemented inDaniel Dunbar2010-03-251-15/+9
| | | | | | | gcc, and the common expectation seems to be that they are unused. If and when someone cares we can add them back with well documented demantics. llvm-svn: 99522
* Fix two bugs in format-string checking:Ted Kremenek2010-03-251-19/+17
| | | | | | | | | (1) Do not assume the data arguments start after the format string (2) Do not use the fact that a function is variadic to treat it like a va_list printf function Fixes PR 6697. llvm-svn: 99480
* Refactor CFG-based warnings in Sema to be run by a worked object called ↵Ted Kremenek2010-03-201-274/+0
| | | | | | | | | | | | | | | AnalysisBasedWarnings. This object controls when the warnings are executed, allowing the client code in Sema to selectively disable warnings as needed. Centralizing the logic for analysis-based warnings allows us to optimize when and how they are run. Along the way, remove the redundant logic for the 'check fall-through' warning for blocks; now the same logic is used for both blocks and functions. llvm-svn: 99085
* Promote enum types during -Wsign-compare. Fixes some spurious warnings,John McCall2010-03-191-0/+5
| | | | | | mostly during conditional expressions. llvm-svn: 98975
* Let SourceManager::getBufferData return StringRef instead of a pair of two ↵Benjamin Kramer2010-03-161-5/+4
| | | | | | const char*. llvm-svn: 98630
* Give SourceManager a Diagnostic object with which to report errors,Douglas Gregor2010-03-161-2/+3
| | | | | | and start simplifying the interfaces in SourceManager that can fail. llvm-svn: 98594
* Introduce a new BufferResult class to act as the return type ofDouglas Gregor2010-03-151-1/+4
| | | | | | | | | | | | | | SourceManager's getBuffer() (and similar) operations. This abstract can be used to force callers to cope with errors in getBuffer(), such as missing files and changed files. Fix a bunch of callers to use the new interface. Add some very basic checks for file consistency (file size, modification time) into ContentCache::getBuffer(), although these checks don't help much until we've updated the main callers (e.g., SourceManager::getSpelling()). llvm-svn: 98585
* Warn about comparing an unsigned expression with 0 in tautological ways.John McCall2010-03-111-6/+39
| | | | | | Patch by mikem! llvm-svn: 98279
* Keep an explicit stack of function and block scopes, each element ofDouglas Gregor2010-03-011-0/+1
| | | | | | | | | | | | | | | | | | | | which has the label map, switch statement stack, etc. Previously, we had a single set of maps in Sema (for the function) along with a stack of block scopes. However, this lead to funky behavior with nested functions, e.g., in the member functions of local classes. The explicit-stack approach is far cleaner, and we retain a 1-element cache so that we're not malloc/free'ing every time we enter a function. Fixes PR6382. Also, tweaked the unused-variable warning suppression logic to look at errors within a given Scope rather than within a given function. The prior code wasn't looking at the right number-of-errors count when dealing with blocks, since the block's count would be deallocated before we got to ActOnPopScope. This approach works with nested blocks/functions, and gives tighter error recovery. llvm-svn: 97518
* Fix crasher caused by setting a bit in a possibly empty bitvector whileTed Kremenek2010-02-271-1/+6
| | | | | | doing printf format string checking. This is a recent regression. llvm-svn: 97318
* For printf format string checking, add support for positional format strings.Ted Kremenek2010-02-271-20/+53
| | | | | | Along the way, coelesce some of the diagnostics. llvm-svn: 97297
* For printf format string checking, move the tracking of the data argument ↵Ted Kremenek2010-02-261-28/+55
| | | | | | | | | index out of Sema and into analyze_printf::ParseFormatString(). Also use a bitvector to determine what arguments have been covered (instead of just checking to see if the last argument consumed is the max argument). This is prep. for support positional arguments (an IEEE extension). llvm-svn: 97248
* Don't assert on compound assignment operators that operate in FP types whenJohn McCall2010-02-231-3/+15
| | | | | | the result is integral. Fixes <rdar://problem/7676608>. llvm-svn: 96970
* Move the rest of the unreachable code analysis from libSemaTed Kremenek2010-02-231-201/+14
| | | | | | to libAnalysis (with only the error reporting in libSema). llvm-svn: 96893
* Simplify check for basic block with a CXXTryStmt terminator.Ted Kremenek2010-02-231-3/+2
| | | | llvm-svn: 96892
* Start moving some of the logic for the unreachable code analysis out of libSemaTed Kremenek2010-02-231-46/+15
| | | | | | and into libAnalysis. llvm-svn: 96872
* Convert use of std::queue to llvm::SmallVector and fix buildbot.Ted Kremenek2010-02-231-30/+33
| | | | llvm-svn: 96855
* Use SmallVectorImpl::iterator.Ted Kremenek2010-02-231-4/+2
| | | | llvm-svn: 96848
* Simplify logic for determining values of 'ReturnsVoid' and 'HasNoReturn' flags.Ted Kremenek2010-02-231-9/+7
| | | | | | No functionality change. llvm-svn: 96847
* Rename argument so the name reflects what it's doing.Benjamin Kramer2010-02-161-8/+9
| | | | llvm-svn: 96342
* Refactor the logic for printf argument type-checking into ↵Ted Kremenek2010-02-161-100/+59
| | | | | | | | | | analyze_printf::ArgTypeResult. Implement printf argument type checking for '%s'. Fixes <rdar://problem/3065808>. llvm-svn: 96310
* Add Sema support for __builtin_fpclassify by extending the existing check ↵Benjamin Kramer2010-02-151-9/+14
| | | | | | for __builtin_isinf and friends. Part of PR6083. llvm-svn: 96291
* Uncomment lines I never meant to have left commented in a commit.Ted Kremenek2010-02-111-3/+3
| | | | llvm-svn: 95906
* Patch by Cristian Draghici:Ted Kremenek2010-02-111-2/+34
| | | | | | | | | | | | Enhance the printf format string checking when using the format specifier flags ' ', '0', '+' with the 'p' or 's' conversions (since they are nonsensical and undefined). This is similar to GCC's checking. Also warning when a precision is used with the 'p' conversin specifier, since it has no meaning. llvm-svn: 95869
* Convert tabs to spaces.Ted Kremenek2010-02-101-12/+12
| | | | llvm-svn: 95756
* Don't diagnose missing noreturns for uninstantiated templates. Fixes PR6247.Anders Carlsson2010-02-061-3/+4
| | | | llvm-svn: 95487
* Standardize the parsing of function type attributes in a way thatJohn McCall2010-02-051-1/+2
| | | | | | | | | | | | follows (as conservatively as possible) gcc's current behavior: attributes written on return types that don't apply there are applied to the function instead, etc. Only parse CC attributes as type attributes, not as decl attributes; don't accepet noreturn as a decl attribute on ValueDecls, either (it still needs to apply to other decls, like blocks). Consistently consume CC/noreturn information throughout codegen; enforce this by removing their default values in CodeGenTypes::getFunctionInfo(). llvm-svn: 95436
* Move ParseFormatString() and FormatStringHandler back into the ↵Ted Kremenek2010-02-041-8/+9
| | | | | | analyze_printf namespace. llvm-svn: 95324
* Mark dtors for parameter variables and eliminate some redundant type munging.John McCall2010-02-021-2/+3
| | | | llvm-svn: 95079
* Access control for implicit destructor calls. Diagnostic could be orders ofJohn McCall2010-02-021-0/+3
| | | | | | magnitude clearer. llvm-svn: 95078
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-2/+1
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Use early return as suggested by Cristian Draghici.Ted Kremenek2010-02-011-12/+9
| | | | llvm-svn: 94994
OpenPOWER on IntegriCloud