summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* -Wformat: better handling of qualifiers on pointer argumentsHans Wennborg2012-07-312-3/+16
| | | | | | | Warn about using pointers to const-qualified types as arguments to scanf. Ignore the volatile qualifier when checking if types match. llvm-svn: 161052
* Make -Wformat check the argument type for %n.Hans Wennborg2012-07-302-0/+13
| | | | | | | This makes Clang check that the corresponding argument for "%n" in a format string is a pointer to int. llvm-svn: 160966
* Make -Wformat walk the typedef chain when looking for size_t, etc.Hans Wennborg2012-07-273-30/+38
| | | | | | | | | | | | | | Clang's -Wformat fix-its currently suggest using "%zu" for values of type size_t (in C99 or C++11 mode). However, for a type such as std::vector<T>::size_type, it does not notice that type is actually typedeffed to size_t, and instead suggests a format for the underlying type, such as "%lu" or "%u". This commit makes the format string fix mechanism walk the typedef chain so that it notices if the type is size_t, even if that isn't "at the top". llvm-svn: 160886
* clang/lib: [CMake] Update tblgen'd dependencies.NAKAMURA Takumi2012-07-271-0/+1
| | | | llvm-svn: 160851
* clang/lib: [CMake] Reformat, alphabetize lists.NAKAMURA Takumi2012-07-271-1/+1
| | | | llvm-svn: 160850
* Final piece of core issue 1330: delay computing the exception specification ofRichard Smith2012-07-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a defaulted special member function until the exception specification is needed (using the same criteria used for the delayed instantiation of exception specifications for function temploids). EST_Delayed is now EST_Unevaluated (using 1330's terminology), and, like EST_Uninstantiated, carries a pointer to the FunctionDecl which will be used to resolve the exception specification. This is enabled for all C++ modes: it's a little faster in the case where the exception specification isn't used, allows our C++11-in-C++98 extensions to work, and is still correct for C++98, since in that mode the computation of the exception specification can't fail. The diagnostics here aren't great (in particular, we should include implicit evaluation of exception specifications for defaulted special members in the template instantiation backtraces), but they're not much worse than before. Our approach to the problem of cycles between in-class initializers and the exception specification for a defaulted default constructor is modified a little by this change -- we now reject any odr-use of a defaulted default constructor if that constructor uses an in-class initializer and the use is in an in-class initialzer which is declared lexically earlier. This is a closer approximation to the current draft solution in core issue 1351, but isn't an exact match (but the current draft wording isn't reasonable, so that's to be expected). llvm-svn: 160847
* [analyzer] Don't crash on implicit statements inside initializers.Jordan Rose2012-07-261-1/+9
| | | | | | | | | | | | | | | | | | | Our BugReporter knows how to deal with implicit statements: it looks in the ParentMap until it finds a parent with a valid location. However, since initializers are not in the body of a constructor, their sub-expressions are not in the ParentMap. That was easy enough to fix in AnalysisDeclContext. ...and then even once THAT was fixed, there's still an extra funny case of Objective-C object pointer fields under ARC, which are initialized with a top-level ImplicitValueInitExpr. To catch these cases, PathDiagnosticLocation will now fall back to the start of the current function if it can't find any other valid SourceLocations. This isn't great, but it's miles better than a crash. (All of this is only relevant when constructors and destructors are being inlined, i.e. under -cfg-add-initializers and -cfg-add-implicit-dtors.) llvm-svn: 160810
* [analyzer] Variables with destructors are live until the destructor is run.Jordan Rose2012-07-261-0/+6
| | | | | | | Test case in the next commit, which enables destructors under certain circumstances. llvm-svn: 160805
* When a && or || appears as the condition of a ?:, perform appropriateRichard Smith2012-07-241-10/+13
| | | | | | | | | short-circuiting when building the CFG. Also be sure to skip parens before checking for the && / || special cases. Finally, fix some crashes in CFG printing in the presence of calls to destructors for array of array of class type. llvm-svn: 160691
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160622
* Add a reverse iterator to DeclStmt, and use it when building a CFG.Jordan Rose2012-07-201-5/+4
| | | | | | | The CFG creates dummy DeclStmts with one Decl per statement, and it has to do so from last to first in order to build the graph correctly. llvm-svn: 160560
* Simplify UninitializedValues.cpp by removing logic to handle the previous ↵Ted Kremenek2012-07-191-142/+25
| | | | | | | | (imprecise) representation of '&&' and '||' in the CFG. This is no longer needed, and greatly simplifies the code. llvm-svn: 160494
* Teach CFG construction about destructors resulting from references to array ↵Ted Kremenek2012-07-181-5/+4
| | | | | | types. Fixes crash in <rdar://problem/11671507>. llvm-svn: 160424
* Uninitialized variables: two little changes:Richard Smith2012-07-171-1/+3
| | | | | | | * Treat compound assignment as a use, at Jordy's request. * Always add compound assignments into the CFG, so we can correctly diagnose the use in 'return x += 1;' llvm-svn: 160334
* -Wuninitialized: Split the classification of DeclRefExprs as initialization orRichard Smith2012-07-171-228/+223
| | | | | | | | | | use out of TransferFunctions, and compute it in advance rather than on-the-fly. This allows us to handle compound assignments with DeclRefExprs on the RHS correctly, and also makes it trivial to treat const& function parameters as not initializing the argument. The patch also makes both of those changes. llvm-svn: 160330
* Refine CFG so that '&&' and '||' don't lead to extra confluence points when ↵Ted Kremenek2012-07-141-150/+232
| | | | | | | | | | | | | | | | | | used in a branch, but instead push the terminator for the branch down into the basic blocks of the subexpressions of '&&' and '||' respectively. This eliminates some artifical control-flow from the CFG and results in a more compact CFG. Note that this patch only alters the branches 'while', 'if' and 'for'. This was complex enough for one patch. The remaining branches (e.g., do...while) can be handled in a separate patch, but they weren't immediately tackled because they were less important. It is possible that this patch introduces some subtle bugs, particularly w.r.t. to destructor placement. I've tried to audit these changes, but it is also known that the destructor logic needs some refinement in the area of '||' and '&&' regardless (i.e., their are known bugs). llvm-svn: 160218
* Hoist CFG builder logic for '&&' and '||' into helper method. No ↵Ted Kremenek2012-07-141-40/+45
| | | | | | funcationlity change. llvm-svn: 160217
* Remove unused method declaration.Ted Kremenek2012-07-141-1/+0
| | | | llvm-svn: 160216
* Sort prototypes. No functionality change.Ted Kremenek2012-07-141-19/+18
| | | | llvm-svn: 160215
* PR13360: When deciding the earliest point which inevitably leads to anRichard Smith2012-07-131-14/+19
| | | | | | | uninitialized variable use, walk back over branches where we've reached all the non-null successors, not just cases where we've reached all successors. llvm-svn: 160206
* Thread safety analysis: impove handling of trylock expressions.DeLesley Hutchins2012-07-101-1/+40
| | | | llvm-svn: 160018
* Implement AST classes for comments, a real parser for Doxygen comments and aDmitri Gribenko2012-07-061-0/+1
| | | | | | | | | | | | | | very simple semantic analysis that just builds the AST; minor changes for lexer to pick up source locations I didn't think about before. Comments AST is modelled along the ideas of HTML AST: block and inline content. * Block content is a paragraph or a command that has a paragraph as an argument or verbatim command. * Inline content is placed within some block. Inline content includes plain text, inline commands and HTML as tag soup. llvm-svn: 159790
* Thread-safety analysis: eliminate false positives in case where the definitionDeLesley Hutchins2012-07-051-183/+188
| | | | | | | duplicates attributes on the declaration. Also eliminates a false negative in ReleasableMutexLock. Fixing this bug required some refactoring. llvm-svn: 159780
* Drop the ASTContext.h include from DeclFriend.h and DeclTemplate.h.Benjamin Kramer2012-07-041-0/+1
| | | | llvm-svn: 159723
* Drop the ASTContext.h include from Stmt.h and fix up transitive users.Benjamin Kramer2012-07-042-0/+2
| | | | | | | | | | | | | | This required moving the ctors for IntegerLiteral and FloatingLiteral out of line which shouldn't change anything as they are usually called through Create methods that are already out of line. ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector and make it independent from ASTContext.h Pass the StorageAllocator directly to AccessedEntity so it doesn't need to have a definition of ASTContext around. llvm-svn: 159718
* Thread safety analysis: improve handling of smart pointers.DeLesley Hutchins2012-07-031-0/+19
| | | | llvm-svn: 159679
* Thread Safety Analysis: handle expressions involving temporaries,DeLesley Hutchins2012-07-031-8/+14
| | | | | | e.g. ExprWithCleanups. llvm-svn: 159674
* -Wuninitialized: assume that an __attribute__((returns_twice)) function mightRichard Smith2012-07-021-0/+18
| | | | | | | initialize any variable. This is extremely conservative, but is sufficient for now. llvm-svn: 159620
* Thread safety analysis: fixed bug that occurs when very silly peopleDeLesley Hutchins2012-07-021-14/+33
| | | | | | | use scoped_lockable without putting unlock_function on the destructor. llvm-svn: 159609
* Thread safety analysis: fixed incorrect error message at the end of a ↵DeLesley Hutchins2012-07-021-6/+15
| | | | | | locks_required function. llvm-svn: 159607
* Thread safety analysis: don't warn in case of duplicate annotation.DeLesley Hutchins2012-07-021-8/+11
| | | | llvm-svn: 159606
* Thread Safety Analysis: turn off checking within trylock functions.DeLesley Hutchins2012-07-021-0/+6
| | | | llvm-svn: 159601
* Bail out the LiveVariables analysis when the CFG is very large, asTed Kremenek2012-07-021-0/+5
| | | | | | | | | we are encountering some scalability issues with memory usage. The appropriate long term fix is to make the analysis more scalable, but this will at least prevent the analyzer swapping when analyzing very large functions. llvm-svn: 159578
* Thread safety analysis: support release() function on scopedDeLesley Hutchins2012-06-281-20/+44
| | | | | | lockable objects. llvm-svn: 159387
* Thread safety analysis: implement lock_returned attribute.DeLesley Hutchins2012-06-251-46/+88
| | | | llvm-svn: 159152
* Thread safety analysis: fixes a bug in which locksets are not handledDeLesley Hutchins2012-06-221-44/+50
| | | | | | | | properly if there is a join point in the control flow graph that involves a trylock. Also changes the source locations of some warnings to be more consistent. llvm-svn: 159008
* Remove a goofy CMake hack and use the standard CMake facilities toChandler Carruth2012-06-211-4/+12
| | | | | | | | | express library-level dependencies within Clang. This is no more verbose really, and plays nicer with the rest of the CMake facilities. It should also have no change in functionality. llvm-svn: 158888
* -Wuninitialized bugfix: when entering the scope of a variable with noRichard Smith2012-06-161-0/+12
| | | | | | | initializer, it is uninitialized, even if we may be coming from somewhere where it was initialized. llvm-svn: 158611
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-062-2/+2
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Remove unused private member variables found by clang's new ↵Benjamin Kramer2012-06-061-4/+3
| | | | | | -Wunused-private-field. llvm-svn: 158086
* Zap the /Za compiler switch from MSVC projects, the option is considered ↵Francois Pichet2012-06-061-2/+2
| | | | | | | | harmful even by Microsoft people and clang won't build using the MSVC 2012 RC if not removed. Only 1 minor code change was necessary: can't use cdecl as variable name anymore. llvm-svn: 158063
* Make suggestions for mismatched enum arguments to printf/scanf.Jordan Rose2012-06-042-0/+9
| | | | llvm-svn: 157962
* Teach printf/scanf about enums with fixed underlying types.Jordan Rose2012-06-041-0/+6
| | | | llvm-svn: 157961
* static analyzer: add inlining support for directly called blocks.Ted Kremenek2012-06-011-14/+27
| | | | llvm-svn: 157833
* Suggest '%@' for Objective-C objects in ObjC format strings.Jordan Rose2012-05-301-1/+23
| | | | llvm-svn: 157716
* Split a chunk of -Wconditional-uninitialized warnings out into a separate flag,Richard Smith2012-05-251-6/+134
| | | | | | | | | | | -Wsometimes-uninitialized. This detects cases where an explicitly-written branch inevitably leads to an uninitialized variable use (so either the branch is dead code or there is an uninitialized use bug). This chunk of warnings tentatively lives within -Wuninitialized, in order to give it more visibility to existing Clang users. llvm-svn: 157458
* Some cleanups around the uninitialized variables warning, and a FIXME. No ↵Richard Smith2012-05-241-22/+18
| | | | | | functional change. llvm-svn: 157440
* Make -Wformat accept printf("%hhx", c); with -funsigned-charHans Wennborg2012-05-081-2/+1
| | | | | | | | | For "%hhx", printf expects an unsigned char. This makes Clang accept a 'char' argument for that also when using -funsigned-char. This fixes PR12761. llvm-svn: 156388
* Fix handling of wint_t - we can't assume wint_t is purely an integer ↵James Molloy2012-05-041-10/+10
| | | | | | | | | | | | promotion of wchar_t - they may differ in signedness. Teach ASTContext about WIntType, and have it taken from TargetInfo like WCharType. Should fix test/Sema/format-strings.c for ARM, with the exception of one subtest which will fail if wint_t and wchar_t are the same size and wint_t is signed, wchar_t is unsigned. There'll be a followup commit to fix that. Reviewed by Chandler and Hans at http://llvm.org/reviews/r/8 llvm-svn: 156165
* Add -Wimplicit-fallthrough warning flag, which warns on fallthrough betweenRichard Smith2012-05-031-3/+0
| | | | | | | | | | | | cases in switch statements. Also add a [[clang::fallthrough]] attribute, which can be used to suppress the warning in the case of intentional fallthrough. Patch by Alexander Kornienko! The handling of C++11 attribute namespaces in this patch is temporary, and will be replaced with a cleaner mechanism in a subsequent patch. llvm-svn: 156086
OpenPOWER on IntegriCloud