summaryrefslogtreecommitdiffstats
path: root/clang/Sema/SemaChecking.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Make a major restructuring of the clang tree: introduce a top-levelChris Lattner2008-03-151-802/+0
| | | | | | | | | | lib dir and move all the libraries into it. This follows the main llvm tree, and allows the libraries to be built in parallel. The top level now enforces that all the libs are built before Driver, but we don't care what order the libs are built in. This speeds up parallel builds, particularly incremental ones. llvm-svn: 48402
* Added TODO.Ted Kremenek2008-03-031-0/+3
| | | | llvm-svn: 47843
* Use IgnoreParenCasts.Anders Carlsson2008-02-131-9/+1
| | | | llvm-svn: 47041
* Move IgnoreParenCasts to be a method on Expr.Chris Lattner2008-02-131-3/+3
| | | | llvm-svn: 47040
* Get rid of bogus warnings when the second argument in va_start is either an ↵Anders Carlsson2008-02-111-3/+13
| | | | | | implicit cast expr or a paren expr. llvm-svn: 46950
* Fixed typo introduced by r46133 that caused -Wfloat-equal to break.Ted Kremenek2008-01-171-1/+1
| | | | llvm-svn: 46134
* Added method Expr::IgnoreParens(), which returns the first non-ParenExpr Expr*.Ted Kremenek2008-01-171-2/+2
| | | | | | | Refactored the use of this method into both the Sema module and Analysis module, which were using their own static functions that did the same thing. llvm-svn: 46129
* Substituted all instances of the string "Objc" for "ObjC". This fixesTed Kremenek2008-01-071-2/+2
| | | | | | | some naming inconsistencies in the names of classes pertaining to Objective-C support in clang. llvm-svn: 45715
* Don't attribute in file headers anymore. See llvmdev for theChris Lattner2007-12-291-2/+2
| | | | | | discussion of this change. llvm-svn: 45410
* various cleanups. Use IgnoreParenCasts instead of inlined versions.Chris Lattner2007-12-281-29/+7
| | | | llvm-svn: 45382
* unindent cases in a switch stmt, no functionality change.Chris Lattner2007-12-281-191/+188
| | | | llvm-svn: 45381
* Change Sema::ActOnCallExpr to construct the CallExpr early and put it intoChris Lattner2007-12-281-78/+66
| | | | | | | | | | | | and OwningPtr instead of constructing only after all of sema is done. This has a couple of effects: 1. it fixes memory leaks from all the error cases in sema 2. it simplifies the code significantly. The cost of this is that the error case now new's and delete's an expr where it did not before, but we don't care about the perf of the error case. llvm-svn: 45380
* More objective-c typechecking stuff. This is work in progress and more patchesFariborz Jahanian2007-12-201-2/+5
| | | | | | are due to arrive. llvm-svn: 45244
* implement semantic analysis for __builtin_islessequal and friends.Chris Lattner2007-12-201-9/+46
| | | | llvm-svn: 45239
* simplify some code.Chris Lattner2007-12-201-5/+8
| | | | llvm-svn: 45235
* refactor some code that handles sema of direct function calls.Chris Lattner2007-12-191-51/+61
| | | | llvm-svn: 45234
* Fixe bogus error for variable argument methods. ↵Steve Naroff2007-12-181-1/+1
| | | | | | Sema::ObjcGetTypeForMethodDefinition() wasn't preserving the isVariadic boolean. Another fix is to avoid synthsizing the function decl entirely, however this is a separate issue that I don't want to deal with now. Also added a FIXME to Sema::CheckFunctionCall(), which is currently emitting a bogus warning. llvm-svn: 45146
* Modified format-string checking to not emit a warning when all of theTed Kremenek2007-12-171-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | following hold: (1) A vprintf-like function is called that takes the argument list via a via_list argument. (2) The format string is a non-literal that is the parameter value of the enclosing function, e.g: void logmessage(const char *fmt,...) { va_list ap; va_start(ap,fmt); fprintf(fmt,ap); // Do not emit a warning. } In the future this special case will be enhanced to consult the "format" attribute attached to a function declaration instead of just allowing a blank check for all function parameters to be used as format strings to vprintf-like functions. This will happen when more support for attributes becomes available. llvm-svn: 45114
* Format string checker: asprintf does not pass argumnents via va_list.Ted Kremenek2007-12-171-1/+1
| | | | llvm-svn: 45110
* Simplified setting up Method's scope before generating AST for its nody.Fariborz Jahanian2007-12-041-5/+7
| | | | llvm-svn: 44576
* GCC has an extension where the left hand side of the ? : operator can be ↵Anders Carlsson2007-11-301-8/+12
| | | | | | omitted. Handle this in a few more places. llvm-svn: 44462
* Enhanced implementation of -Wfloat-equal to check for comparisons againstTed Kremenek2007-11-291-0/+18
| | | | | | | | | | floating-point literals that are represented exactly by the APFloat in FloatingLiteral. For such literals, we do not emit a warning since such checks are often performed in real code to see if a variable has changed from its original value. This heuristic clearly can lead to false negatives, but the hope is it will significantly reduce false positives to help make the compiler flag more useful. llvm-svn: 44424
* Moved logic for -Wfloat-equal to SemaChecking.cpp.Ted Kremenek2007-11-251-0/+37
| | | | | | | | | Moved utility functions IgnoreParen and friends to be static inline functions defined in SemaUtil.h. Added SemaUtil.h to Xcode project. llvm-svn: 44312
* Added notion of '*' specified format width/specifiers when checkingTed Kremenek2007-10-121-4/+41
| | | | | | | | | printf format strings. Added type checking to see if the matching width/precision argument was of type 'int'. Thanks to Anders Carlsson for reporting this missing feature. llvm-svn: 42933
* Add some more diagnostics for va_start, fix tests so they pass with these ↵Anders Carlsson2007-10-121-0/+31
| | | | | | new diags. llvm-svn: 42917
* Printf argument checking now supports dynamically-passed precisionTed Kremenek2007-10-121-1/+6
| | | | | | specifiers. llvm-svn: 42886
* Fix 80 col violations.Chris Lattner2007-08-301-1/+1
| | | | llvm-svn: 41611
* Fixed return-of-stack-address checker to correctly handle stack/globalTed Kremenek2007-08-281-5/+6
| | | | | | | | | | | | | | | | | variables that have a pointer type, or arrays that contain pointers. This fixes a crash on the following code: int *h[3]; int **foo(int i) { return &(h[i]); } This bug was reported by Keith Bauer (thanks!). llvm-svn: 41546
* Updated checker for "return of address of stack variable" to look forTed Kremenek2007-08-271-4/+6
| | | | | | | | | | implicit casts from T to T& at the topmost part of the return-value expression. This checking may be needed within EvalAddr later on. We'll wait until test cases show this kind of logic is necessary (as more C++ features are implemented in clang). llvm-svn: 41493
* Fix %p format checking, patch by Keith Bauer.Chris Lattner2007-08-261-1/+1
| | | | llvm-svn: 41454
* For warnings like this:Chris Lattner2007-08-261-1/+2
| | | | | | | | | | t.c:3:9: warning: invalid conversion '%B' printf("%B\a\n", p); ~~~~~~ ^ Don't beep the console or print the newline. llvm-svn: 41453
* Fix the test/Sema/format-strings.c regression. This code should be refactored.Chris Lattner2007-08-251-1/+13
| | | | llvm-svn: 41398
* Fix the regression on test/Sema/cfstring.cChris Lattner2007-08-251-4/+9
| | | | llvm-svn: 41396
* Modified ArraySubscriptExpr to have accessors getLHS and getRHS in additionTed Kremenek2007-08-201-15/+20
| | | | | | | | | | | | | to getBase and getIdx. getBase and getIdx now return a "normalized" view of the expression (e.g., always "A[4]" instead of possibly "4[A]"). getLHS and getRHS return the expressions with syntactic fidelity to the original source code. Also modified client code of ArraySubscriptExpr, including the AST dumper and pretty printer, the return-stack value checker, and the LLVM code generator. llvm-svn: 41180
* Added extra semantic checking to do basic detection ofTed Kremenek2007-08-171-2/+227
| | | | | | | | "return of stack addresses." ParseReturnStmt now calls CheckReturnStackAddr to determine if the expression in the return statement evaluates to an address of a stack variable. If so, we issue a warning. llvm-svn: 41141
* Return true in case of error, which is what other functions do.Anders Carlsson2007-08-171-4/+4
| | | | llvm-svn: 41140
* Add initial support for constant CFStrings.Anders Carlsson2007-08-171-2/+49
| | | | llvm-svn: 41136
* Added support for additional format string checking for the printfTed Kremenek2007-08-141-29/+263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | family of functions. Previous functionality only included checking to see if the format string was a string literal. Now we check parse the format string (if it is a literal) and perform the following checks: (1) Warn if: number conversions (e.g. "%d") != number data arguments. (2) Warn about missing format strings (e.g., "printf()"). (3) Warn if the format string is not a string literal. (4) Warn about the use se of '%n' conversion. This conversion is discouraged for security reasons. (5) Warn about malformed conversions. For example '%;', '%v'; these are not valid. (6) Warn about empty format strings; e.g. printf(""). Although these can be optimized away by the compiler, they can be indicative of broken programmer logic. We may need to add additional support to see when such cases occur within macro expansion to avoid false positives. (7) Warn if the string literal is wide; e.g. L"%d". (8) Warn if we detect a '\0' character WITHIN the format string. Test cases are included. llvm-svn: 41076
* Added "id_idx" parameter to CheckPrintfArguments. This will be usedTed Kremenek2007-08-101-3/+4
| | | | | | | by CheckPrintfArguments to determine if a given printf function accepts a va_arg argument. llvm-svn: 41008
* initial support for checking format strings, patch by Ted Kremenek:Chris Lattner2007-08-101-0/+90
"I've coded up some support in clang to flag warnings for non-constant format strings used in calls to printf-like functions (all the functions listed in "man fprintf"). Non-constant format strings are a source of many security exploits in C/C++ programs, and I believe are currently detected by gcc using the flag -Wformat-nonliteral." llvm-svn: 41003
OpenPOWER on IntegriCloud