summaryrefslogtreecommitdiffstats
path: root/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.Richard Smith2012-04-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154886 91177308-0d34-0410-b5e6-96231b3b80d8
* Add an AttributedStmt type to represent a statement with C++11 attributesRichard Smith2012-04-141-1/+5
| | | | | | | | | | attached. Since we do not support any attributes which appertain to a statement (yet), testing of this is necessarily quite minimal. Patch by Alexander Kornienko! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154723 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove the unused, unmaintained, incomplete 'Index' library.Douglas Gregor2012-04-131-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154672 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] PCH deserialization optimization.Anna Zaks2012-04-121-61/+32
| | | | | | | | | | | | | | | | We should not deserialize unused declarations from the PCH file. Achieve this by storing the top level declarations during parsing (HandleTopLevelDecl ASTConsumer callback) and analyzing/building a call graph only for those. Tested the patch on a sample ObjC file that uses PCH. With the patch, the analyzes is 17.5% faster and clang consumes 40% less memory. Got about 10% overall build/analyzes time decrease on a large Objective C project. A bit of CallGraph refactoring/cleanup as well.. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154625 91177308-0d34-0410-b5e6-96231b3b80d8
* Include lambda capture init expressions in CFG.Ted Kremenek2012-04-121-1/+17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154611 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix CFGBuilder to not include the body of a LambdaExpr in the CFG of the ↵Ted Kremenek2012-04-121-3/+5
| | | | | | enclosing function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154607 91177308-0d34-0410-b5e6-96231b3b80d8
* Do not crash in the callgraph construction when encountering deleted ↵Ted Kremenek2012-04-051-1/+2
| | | | | | function definitions. Fixes <rdar://problem/11178609>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154081 91177308-0d34-0410-b5e6-96231b3b80d8
* clang/lib/Analysis/CFG.cpp: Get rid of early insertion of placeholder to the ↵NAKAMURA Takumi2012-03-251-7/+4
| | | | | | map. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153407 91177308-0d34-0410-b5e6-96231b3b80d8
* clang/lib/Analysis/CFG.cpp: Fix memory leak since r153297.NAKAMURA Takumi2012-03-251-2/+5
| | | | | | evaluateAsBooleanConditionNoCache(S) might update the map and invalidate the iterator. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153406 91177308-0d34-0410-b5e6-96231b3b80d8
* [CFG] Cache boolean evaluations of expressions to avoid multiple re-evaluationsArgyrios Kyrtzidis2012-03-231-7/+66
| | | | | | | | | | during construction of branches for chained logical operators. This makes -fsyntax-only for test/Sema/many-logical-ops.c about 32x times faster. With measuring SemaExpr.cpp I see differences below the noise level. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153297 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix broken CFG when an initializer is a statement expression that starts ↵Ted Kremenek2012-03-221-5/+15
| | | | | | with a while loop (PR 12325). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153242 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Malloc: Utter the name of the leaked variable.Anna Zaks2012-03-211-2/+0
| | | | | | | | | | | | | | | Specifically, we use the last store of the leaked symbol in the leak diagnostic. (No support for struct fields since the malloc checker doesn't track those yet.) + Infrastructure to track the regions used in store evaluations. This approach is more precise than iterating the store to obtain the region bound to the symbol, which is used in RetainCount checker. The region corresponds to what is uttered in the code in the last store and we do not rely on the store implementation to support this functionality. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153212 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix crash when querying the CFG reported when using the thread safety analysisTed Kremenek2012-03-191-1/+1
| | | | | | | on code using multi-dimensional arrays. Fix by DeLesley Hutchins, and reported in PR 12271. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153067 91177308-0d34-0410-b5e6-96231b3b80d8
* Kill cocoa::deriveNamingConvention and cocoa::followsFundamentalRule. They ↵Jordy Rose2012-03-171-40/+0
| | | | | | | | | are now just simple wrappers around method families, and method decls can cache method family lookups. Also, no one is using them right now. The one difference between ObjCMethodDecl::getMethodFamily and Selector::getMethodFamily is that the former will do some additional sanity checking, and since CoreFoundation types don't look like Objective-C objects, an otherwise interesting method will get a method family of OMF_None. Future clients that use method families should consider how they want to handle CF types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153000 91177308-0d34-0410-b5e6-96231b3b80d8
* Support '%p' format specifier with block pointers.Ted Kremenek2012-03-151-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152839 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix dereference of end iterator. Spotted by ASan.Matt Beaumont-Gay2012-03-141-1/+3
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152738 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] Refactor CallGraph to use Recursive AST visitor whenAnna Zaks2012-03-131-36/+32
| | | | | | collecting function Decls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152651 91177308-0d34-0410-b5e6-96231b3b80d8
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-112-2/+2
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152536 91177308-0d34-0410-b5e6-96231b3b80d8
* Replace a map of boolean values with a set.Benjamin Kramer2012-03-101-14/+8
| | | | | | No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152494 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove BlockDeclRefExpr and introduce a bit on DeclRefExpr toJohn McCall2012-03-103-28/+11
| | | | | | | | track whether the referenced declaration comes from an enclosing local context. I'm amenable to suggestions about the exact meaning of this bit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152491 91177308-0d34-0410-b5e6-96231b3b80d8
* [analyzer] fix regression in analyzer of NOT actually aborting on Stmts it ↵Ted Kremenek2012-03-101-1/+10
| | | | | | | | | | | | doesn't understand. We registered as aborted, but didn't treat such cases as sinks in the ExplodedGraph. Along the way, add basic support for CXXCatchStmt, expanding the set of code we actually analyze (hopefully correctly). Fixes: <rdar://problem/10892489> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152468 91177308-0d34-0410-b5e6-96231b3b80d8
* CallGraph: Add getNode() method, constify.Anna Zaks2012-03-091-0/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152439 91177308-0d34-0410-b5e6-96231b3b80d8
* -Wformat-non-iso: warn about positional arguments (pr12017)Hans Wennborg2012-03-091-0/+3
| | | | | | | | | This renames the -Wformat-non-standard flag to -Wformat-non-iso, rewords the current warnings a bit (pointing out that a format string is not supported by ISO C rather than being "non standard"), and adds a warning about positional arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152403 91177308-0d34-0410-b5e6-96231b3b80d8
* Call Graph: Only the root node is allowed to have an invalid Decl*.Anna Zaks2012-03-081-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152350 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove stray semi-colon.Daniel Dunbar2012-03-081-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152331 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a basic CallGraph to Analysis.Anna Zaks2012-03-082-0/+208
| | | | | | | | | | The final graph contains a single root node, which is a parent of all externally available functions(and 'main'). As well as a list of Parentless/Unreachable functions, which are either truly unreachable or are unreachable due to our analyses imprecision. The analyzer checkers debug.DumpCallGraph or debug.ViewGraph can be used to look at the produced graph. Currently, the graph is not very precise, for example, it entirely skips edges resulted from ObjC method calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152272 91177308-0d34-0410-b5e6-96231b3b80d8
* AST representation for user-defined literals, plus just enough of semanticRichard Smith2012-03-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | analysis to make the AST representation testable. They are represented by a new UserDefinedLiteral AST node, which is a sugared CallExpr. All semantic properties, including full CodeGen support, are achieved for free by this representation. UserDefinedLiterals can never be dependent, so no custom instantiation behavior is required. They are mangled as if they were direct calls to the underlying literal operator. This matches g++'s apparent behavior (but not its actual mangling, which is broken for literal-operator-ids). User-defined *string* literals are now fully-operational, but the semantic analysis is quite hacky and needs more work. No other forms of user-defined literal are created yet, but the AST support for them is present. This patch committed after midnight because we had already hit the quota for new kinds of literal yesterday. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152211 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix horrific CFG bug where '@autoreleasepool' would be put in a dangling ↵Ted Kremenek2012-03-061-0/+10
| | | | | | block in the CFG. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152163 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread safety analysis: expand set of expressions that can be used to denote ↵DeLesley Hutchins2012-03-021-6/+50
| | | | | | locks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151956 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread safety analysis: handle CFG blocks which call functions marked as ↵DeLesley Hutchins2012-03-021-0/+4
| | | | | | noreturn. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151944 91177308-0d34-0410-b5e6-96231b3b80d8
* Move llvm/ADT/SaveAndRestore.h -> llvm/Support/SaveAndRestore.h.Argyrios Kyrtzidis2012-03-013-3/+3
| | | | | | Needs llvm update. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151829 91177308-0d34-0410-b5e6-96231b3b80d8
* Move "clang/Analysis/Support/SaveAndRestore.h" to "llvm/ADT/SaveAndRestore.h"Argyrios Kyrtzidis2012-02-273-3/+3
| | | | | | | | to make it more widely available. Depends on llvm commit r151564 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151566 91177308-0d34-0410-b5e6-96231b3b80d8
* Warn about non-standard format strings (pr12017)Hans Wennborg2012-02-221-0/+71
| | | | | | | | | This adds the -Wformat-non-standard flag (off by default, enabled by -pedantic), which warns about non-standard things in format strings (such as the 'q' length modifier, the 'S' conversion specifier, etc.) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151154 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread-safety analysis: Disable checking inside constructors, destructors, ↵DeLesley Hutchins2012-02-161-6/+24
| | | | | | lock, and unlock functions git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150701 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread-Safety: added support for 'this' as a lock expression.DeLesley Hutchins2012-02-161-3/+7
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150700 91177308-0d34-0410-b5e6-96231b3b80d8
* Format string analysis: give 'q' its own enumerator.Hans Wennborg2012-02-163-6/+16
| | | | | | | | | This is in preparation for being able to warn about 'q' and other non-standard format string features. It also allows us to print its name correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150697 91177308-0d34-0410-b5e6-96231b3b80d8
* Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg2012-02-152-12/+18
| | | | | | | | | | | | | | | | | This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType() only fix a conversion specification enough that Clang wouldn't warn about it, as opposed to always changing it to use the "canonical" conversion specifier. (PR11975) This preserves the user's choice of conversion specifier in cases like: printf("%a", (long double)1); where we previously suggested "%Lf", we now suggest "%La" printf("%x", (long)1); where we previously suggested "%ld", we now suggest "%lx". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150578 91177308-0d34-0410-b5e6-96231b3b80d8
* Tweak format string checking to work with %@ and ObjC toll-free bridging. ↵Ted Kremenek2012-02-061-3/+17
| | | | | | <rdar://problem/10814120> git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149907 91177308-0d34-0410-b5e6-96231b3b80d8
* Basic: import OwningPtr<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149798 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread safety analysis:Richard Smith2012-02-031-13/+83
| | | | | | | | | | | | | * When we detect that a CFG block has inconsistent lock sets, point the diagnostic at the location where we found the inconsistency, and point a note at somewhere the inconsistently-locked mutex was locked. * Fix the wording of the normal (non-loop, non-end-of-function) case of this diagnostic to not suggest that the mutex is going out of scope. * Fix the diagnostic emission code to keep a warning and its note together when sorting the diagnostics into source location order. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149669 91177308-0d34-0410-b5e6-96231b3b80d8
* Thread safety analysis: at a CFG join point between a block terminating in aRichard Smith2012-02-031-0/+39
| | | | | | | | 'continue' and another block, prefer the lockset from the other block, and diagnose the 'continue' block as being the end of a loop. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149666 91177308-0d34-0410-b5e6-96231b3b80d8
* Format string warnings: don't a.k.a. wchar_t with wchar_t.Hans Wennborg2012-01-311-1/+1
| | | | | | | | | | | This fixes the case where Clang would output: error: format specifies type 'wchar_t *' (aka 'wchar_t *') ArgTypeResult::getRepresentativeTypeName needs to take into account that wchar_t can be a built-in type (as opposed to in C, where it is a typedef). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149387 91177308-0d34-0410-b5e6-96231b3b80d8
* [CFG] Removed unused local variable.Erik Verbruggen2012-01-311-2/+0
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149385 91177308-0d34-0410-b5e6-96231b3b80d8
* Let %S, %ls, %C match 16bit types in NSStrings.Nico Weber2012-01-311-3/+10
| | | | | | | | As discussed at http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120130/052200.html git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149325 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix NSLog format string checking for %@.Ted Kremenek2012-01-252-1/+4
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148885 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach scanf/printf checking about '%Ld' and friends (a GNU extension). ↵Ted Kremenek2012-01-243-4/+18
| | | | | | Fixes PR 9466. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148859 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert various template unreachability code I committed accidentally.David Blaikie2012-01-241-8/+9
| | | | | | r148774, r148775, r148776, r148777 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148780 91177308-0d34-0410-b5e6-96231b3b80d8
* More fixes/tests.David Blaikie2012-01-241-2/+2
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148777 91177308-0d34-0410-b5e6-96231b3b80d8
* Support undefined dependent bases.David Blaikie2012-01-241-7/+6
| | | | git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148775 91177308-0d34-0410-b5e6-96231b3b80d8
* Handle thread safety attributes on functions with separate definitions and ↵DeLesley Hutchins2012-01-201-24/+25
| | | | | | declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148599 91177308-0d34-0410-b5e6-96231b3b80d8