summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Format string checking: selectively ignore implicit casts to 'int'Ted Kremenek2010-02-011-6/+17
| | | | | | | | when checking if the format specifier matches the type of the data argument and the length modifier indicates the data type is 'char' or 'short'. llvm-svn: 94992
* Fix for PR5185. C99 [*] VLA notation should be disallowed in function ↵Sam Weinig2010-02-011-0/+14
| | | | | | definitions. llvm-svn: 94972
* Add basic type checking of format string conversion specifiers and their ↵Ted Kremenek2010-01-301-6/+63
| | | | | | arguments. Thanks to Cristian Draghici for his help with this patch! llvm-svn: 94864
* Be a little more permissive than C99: allow 'unsigned' to be used forTed Kremenek2010-01-291-2/+6
| | | | | | | the field width and precision of a format specifier instead of just 'int'. This matches GCC, and fixes <rdar://problem/6079850>. llvm-svn: 94856
* Switch Sema over to using the new implementation of format stringTed Kremenek2010-01-291-268/+39
| | | | | | | | | checking. It passes all existing tests, and the diagnostics have been refined to provide better range information (we now highlight individual format specifiers) and more precise wording in the diagnostics. llvm-svn: 94837
* Alternate format string checking: issue warnings for incomplete format ↵Ted Kremenek2010-01-291-12/+19
| | | | | | | | | | specifiers. In addition, move ParseFormatString() and FormatStringHandler() from the clang::analyze_printf to the clang namespace. Hopefully this will resolve some link errors on Linux. llvm-svn: 94794
* Alternate format string checking: issue a warning for invalid conversion ↵Ted Kremenek2010-01-291-8/+27
| | | | | | specifiers. llvm-svn: 94792
* Alternate format string checking: check for excess data arguments.Ted Kremenek2010-01-291-0/+11
| | | | llvm-svn: 94787
* Alternate format string checking: check if the number of format specifiers ↵Ted Kremenek2010-01-291-0/+12
| | | | | | exceeds the number of arguments. llvm-svn: 94785
* Alternate format string checking: warn of '%n' as being potentially insecure.Ted Kremenek2010-01-291-1/+11
| | | | llvm-svn: 94782
* Add precision/field width checking to AlternateCheckPrintfString().Ted Kremenek2010-01-291-3/+68
| | | | llvm-svn: 94774
* Start fleshing out Sema::AlternateCheckPrintfString():Ted Kremenek2010-01-281-0/+94
| | | | | | | | | | - Add an anonymous class 'CheckPrintfHandler' which will do the checking of specific format specifiers - Add checking for using the '@' conversion specifier outside an ObjC string literal - Add checking for null characters within the string llvm-svn: 94761
* Add placeholder function in Sema for new format string checking logic.Ted Kremenek2010-01-281-1/+18
| | | | | | | | This function will use the format string parsing logic in libAnalysis, and once it is shown to be better than the current implementation it will replace AlternateCheckPrintfString() entirely. llvm-svn: 94721
* Fix 80 col violation.Ted Kremenek2010-01-281-1/+3
| | | | llvm-svn: 94717
* Remove invalid conversion specifiers from format string checking.Ted Kremenek2010-01-281-5/+0
| | | | llvm-svn: 94707
* Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek2010-01-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | (1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. llvm-svn: 94406
* Wire up the new range reporting for unreachable code.Mike Stump2010-01-211-6/+16
| | | | llvm-svn: 94118
* Improve unreachable code warnings with respect to dead member andMike Stump2010-01-211-0/+12
| | | | | | dead array references. llvm-svn: 94115
* Improve unreachable code warnings for with respect to dead functional casts ↵Mike Stump2010-01-211-0/+5
| | | | | | in C++. llvm-svn: 94106
* Improve unreachable code warnings for with respect to c-style casts.Mike Stump2010-01-211-0/+5
| | | | llvm-svn: 94094
* Improve unreachable code warnings for with respect to ? :.Mike Stump2010-01-211-4/+15
| | | | llvm-svn: 94093
* Improve unreachable code warnings for with respect to compoundMike Stump2010-01-211-0/+6
| | | | | | assignments. llvm-svn: 94086
* Improve unreachable code warnings with respect to dead binary andMike Stump2010-01-211-6/+20
| | | | | | unary operators. llvm-svn: 94084
* Speed up compilation by avoiding generating exceptional edges fromMike Stump2010-01-211-2/+36
| | | | | | | | | | | | | CallExprs as those edges help cause a n^2 explosion in the number of destructor calls. Other consumers, such as static analysis, that would like to have more a more complete CFG can select the inclusion of those edges as CFG build time. This also fixes up the two compilation users of CFGs to be tolerant of having or not having those edges. All catch code is assumed be to live if we didn't generate the exceptional edges for CallExprs. llvm-svn: 94074
* Move some recent checking code into SemaChecking instead.Mike Stump2010-01-211-0/+430
| | | | llvm-svn: 94067
* Roll out ASTContext::getTypeSizeInChars(), replacing instances ofKen Dyck2010-01-111-1/+2
| | | | | | | | | | "ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits ones as appropriate. Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, fromQuantity(), and getQuantity() for clarity. llvm-svn: 93153
OpenPOWER on IntegriCloud