aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
AgeCommit message (Collapse)Author
2010-07-16Hook up warning for an incomplete scanlist in scanf format strings.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Add the main scanf-parsing logic that I meant to include in my previous commit.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108502 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Add missing header file.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108501 91177308-0d34-0410-b5e6-96231b3b80d8
2010-07-16Add most of the boilerplate support for scanf format string checking. This ↵Ted Kremenek
includes handling the parsing of scanf format strings and hooking the checking into Sema. Most of this checking logic piggybacks on what was already there for checking printf format strings, but the checking logic has been refactored to support both. What is left to be done is to support argument type checking in format strings and of course fix the usual tail of bugs that will follow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108500 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Type Type::isRealFloatingType() that vectors are not floating-pointDouglas Gregor
types, updating callers of both isFloatingType() and isRealFloatingType() accordingly. Caught at least one issue where we allowed one to declare a vector of vectors (!), along with cleaning up the standard-conversion logic for C++. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106595 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18Printf format strings: Added some more tests and fixed some minor bugs.Tom Care
- Precision toStrings shouldn't print a dot when they have no value. - Length of char length modifier is now returned correctly. - Added several fixit tests. Note: fixit tests are currently broken due to a bug in HighlightRange. Marking as XFAIL for now. M test/Sema/format-strings-fixit.c M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Bug 7394 - Fixed toString representation of Precisions in format strings.Tom Care
M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106245 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Bug 7377: Fixed several bad printf format string bugs.Tom Care
- Added warning for undefined behavior when using field specifier - Added warning for undefined behavior when using length modifier - Fixed warnings for invalid flags - Added warning for ignored flags - Added fixits for the above warnings - Fixed accuracy of detecting several undefined behavior conditions - Receive normal warnings in addition to security warnings when using %n - Fix bug where '+' flag would remain on unsigned conversion suggestions Summary of changes: - Added expanded tests - Added/expanded warnings - Added position info to OptionalAmounts for fixits - Extracted optional flags to a wrapper class with position info for fixits - Added several methods to validate a FormatSpecifier by component, each checking for undefined behavior - Fixed conversion specifier checking to conform to C99 standard - Added hooks to detect the invalid states in CheckPrintfHandler::HandleFormatSpecifier Note: warnings involving the ' ' (space) flag are temporarily disabled until whitespace highlighting no longer triggers assertions. I will make a post about this on cfe-dev shortly. M test/Sema/format-strings.c M include/clang/Basic/DiagnosticSemaKinds.td M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp M lib/Sema/SemaChecking.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17Update CMake build for new attribute changes.Sean Hunt
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106188 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Extend format string type-checking to include '%p'. Fixes remaining cases ↵Ted Kremenek
PR 4468. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106151 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-11Small fixes regarding printf fix suggestions.Tom Care
- Added some handling of flags that become invalid when changing the conversion specifier. - Changed fixit behavior to remove unnecessary length modifiers. - Separated some tests out and added some comments. modified: lib/Analysis/PrintfFormatString.cpp test/Sema/format-strings-fixit.c git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105807 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09Fix a typo that breaks the GCC build. Turns out that Clang isn'tDouglas Gregor
diagnosing this code as an error when it should, so I've filed http://llvm.org/bugs/show_bug.cgi?id=7325. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105683 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09Added FixIt support to printf format string checking.Tom Care
- Refactored LengthModifier to be a class. - Added toString methods in all member classes of FormatSpecifier. - FixIt suggestions keep user specified flags unless incorrect. Limitations: - The suggestions are not conversion specifier sensitive. For example, if we have a 'pad with zeroes' flag, and the correction is a string conversion specifier, we do not remove the flag. Clang will warn us on the next compilation. A test/Sema/format-strings-fixit.c M include/clang/Analysis/Analyses/PrintfFormatString.h M lib/Analysis/PrintfFormatString.cpp M lib/Sema/SemaChecking.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105680 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08Makefiles: Set Clang CPP compiler flags in a single location, instead of ↵Daniel Dunbar
scattered throughout the project Makefiles. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105638 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-08Makefile: Switch Clang Makefiles to always include the top-level Clang Makefile.Daniel Dunbar
- This eliminates most dependencies on how Clang is installed relative to LLVM. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105637 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-04Assignments to reference variables shouldn't kill the variable.Jordy Rose
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105452 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-03Make addStmt always add stmt. Delegate other cases to Visit() directly.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105384 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-03CFG: add all LHS of assingments as lvalue. This improves support for C++ ↵Zhongxing Xu
reference. Patch by Jordy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105383 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-30Convert DeclNodes to use TableGen.Sean Hunt
The macros required for DeclNodes use have changed to match the use of StmtNodes. The FooFirst enumerator constants have been named firstFoo to match usage elsewhere. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105165 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-21Fix crash in CFG construction for 'break' statements appearing in statement ↵Ted Kremenek
expressions within the increment code of a for loop. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104375 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-13Don't add a null successor to a CFGBlock when the contents of an ↵Ted Kremenek
@synchronized statement is empty. Fixes <rdar://problem/7979430>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103717 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-05Unbreak CMake build.Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103077 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Add null check in CFGBuilder::VisitStmt() to make CFG constructionTed Kremenek
more resilient to bad code. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102793 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29Fix CFG crasher involving statement expressions reported in PR 6938.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102576 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14Use direct assignment instead of user defined conversion.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13CFGBuilder: always add C++ member call expr as block-level expr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Fix CFG bug where bases of member expressions were not always evaluated in a ↵Ted Kremenek
lvalue context. Fixes <rdar://problem/7813989>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Fix bug in AddStmtChoice:asLValue() where 'AsLValueNotAlwaysAdd' would not ↵Ted Kremenek
be treated as indicating an lvalue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100965 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-11Sort visitor methods. No functionality change.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30the big refactoring bits of PR3782.Rafael Espindola
This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Be a bit more consistent in using operator->Rafael Espindola
This patch moves some methods from QualType to Type and changes the users to use -> instead of . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25Fix '+=' accumulation error when parsing numeric amounts in a format string.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99479 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Only perform CFG-based warnings on 'static inline' functions thatTed Kremenek
are called (transitively) by regular functions/blocks within a translation untion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-12Allow users to set CPPFLAGS and CXXFLAGS on the make command line.Jeffrey Yasskin
Tested: make CPPFLAGS=-m64 CXXFLAGS=-m64 -j8 && (cd tools/clang;make test) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98399 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-10When computing in AnalysisContext the variables referencedTed Kremenek
by a block, also look at the contained blocks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98111 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03Simplify code a bit and remove unneeded semicolons.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97654 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-03Fix an algorithmic bug in LiveVariables pointed out by Zhongxing.Ted Kremenek
If an initializer in a DeclStmt references the declared variable, that extends the liveness of that variable. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97624 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02[CFG]Ted Kremenek
After discussion with Zhongxing, don't force the initializer of DeclStmts to be block-level expressions. This led to some interesting fallout: [UninitializedValues] Always visit the initializer of DeclStmts (do not assume they are block-level expressions). [BasicStore] With initializers of DeclStmts no longer block-level expressions, this causes self-referencing initializers (e.g. 'int x = x') to no longer cause the initialized variable to be live before the DeclStmt. While this is correct, it caused BasicStore::RemoveDeadBindings() to prune off the values of these variables from the initial store (where they are set to uninitialized). The fix is to back-port some (and only some) of the lazy-binding logic from RegionStore to BasicStore. Now the default values of local variables are determined lazily as opposed to explicitly initialized. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97591 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02Register all parameters even if they didn't occur in the function body.Zhongxing Xu
We may query their liveness because they are added to store when passing argument values. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97562 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-01Allow a '0' precision in format strings (as the man page says it is okay).Ted Kremenek
Fixes <rdar://problem/7700339>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97482 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-27For printf format string checking, add support for positional format strings.Ted Kremenek
Along the way, coelesce some of the diagnostics. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97297 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26For printf format string checking, move the tracking of the data argument ↵Ted Kremenek
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). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24Always add CallExpr as block-level expression. Inline-based interproceduralZhongxing Xu
analysis needs this. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24Add support for '%C' and '%S' printf conversion specifiers.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97005 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23Move the rest of the unreachable code analysis from libSemaTed Kremenek
to libAnalysis (with only the error reporting in libSema). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-23Start moving some of the logic for the unreachable code analysis out of libSemaTed Kremenek
and into libAnalysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96872 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22Revert "Simplify code: Succ is guaranteed to be not NULL.", which turns out toDaniel Dunbar
not be guaranteed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96782 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-22Simplify code: Succ is guaranteed to be not NULL.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96772 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-17Add a utility method.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96471 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16Refactor the logic for printf argument type-checking into ↵Ted Kremenek
analyze_printf::ArgTypeResult. Implement printf argument type checking for '%s'. Fixes <rdar://problem/3065808>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96310 91177308-0d34-0410-b5e6-96231b3b80d8