Ted Kremenek [Wed, 23 Jun 2010 22:08:00 +0000 (22:08 +0000)]
Add 'VisitEndAnalysis' callback to Checker class. This callback is called by GRExprEngine
when the worklist algorithm has terminated. This allows some checkers to do a post-analysis
phase after all paths have been analyzed.
Douglas Gregor [Tue, 22 Jun 2010 23:41:02 +0000 (23:41 +0000)]
Vector types are not arithmetic types, either. Note that we now ban
__real myvec and __imag myvec, since they aren't all that useful (it's
just an identity function) but we might want to use them in more
restricted cases in the future (e.g., "__real mycomplexvec" could
extract the real parts of a vector of complex numbers).
Douglas Gregor [Tue, 22 Jun 2010 23:13:52 +0000 (23:13 +0000)]
Teach Type::isRealType() that vector types are never real types. All
of the callers of isRealType() already assumed this, and one of them
(increment/decrement) mistakenly permitted increments of vector types
because of it.
Douglas Gregor [Tue, 22 Jun 2010 23:07:26 +0000 (23:07 +0000)]
Type Type::isRealFloatingType() that vectors are not floating-point
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++.
Douglas Gregor [Tue, 22 Jun 2010 22:12:46 +0000 (22:12 +0000)]
Change Type::isFloatingType() to reflect the actual definition of a
"floating type" in C, which does not include vector types. Introduce
Type::hasFloatingRepresentation() for the places where we want to know
whether the underlying representation is one or more floating-point
values. Remove some hacks we had where the former behavior of
Type::isFloatingType() was at odds with the language definition of the
term.
Ted Kremenek [Tue, 22 Jun 2010 19:05:10 +0000 (19:05 +0000)]
Don't assert on C++ casts that are currently not handled by the static analyzer.
Instead, halt the analysis of the current path, which is what we do in GRExprEngine::ProcessStmt
for all other C++ constructs not currently handled by the analyzer.
Douglas Gregor [Tue, 22 Jun 2010 16:52:27 +0000 (16:52 +0000)]
Don't allow vector conversions to sneak in under the guise of
floating-point conversions or floating-integral conversions. We
really, really, really need to make isFloatingType() and friends not
apply to vector types.
we would cache the tokens "a::b::" but then we would try to annotate them using the range "a::".
Before annotating them with the (invalid) C++ scope spec, set it to the range of "a::b::".
-Introduce PCHReader::ReadTemplateArgumentLoc()
-Introduce PCHWriter::AddTemplateArgumentLocInfo()
-Modify PCHWriter::AddTemplateArgumentLoc() to also write TemplateArgumentLoc's TemplateArgument
and move the existing calls of AddTemplateArgumentLoc() to AddTemplateArgumentLocInfo().
Make it easier to read/write the template part of FunctionDecl.
Introduce:
-FunctionDecl::getTemplatedKind() which returns an enum signifying what kind of templated
FunctionDecl it is.
-An overload of FunctionDecl::setFunctionTemplateSpecialization() which accepts arrays of
TemplateArguments and TemplateArgumentLocs
-A constructor to TemplateArgumentList which accepts an array of TemplateArguments.
Douglas Gregor [Mon, 21 Jun 2010 23:44:13 +0000 (23:44 +0000)]
Alter the internal representation of the condition variable in
if/while/switch/for statements to ensure that walking the children of
these statements actually works. Previously, we stored the condition
variable as a VarDecl. However, StmtIterator isn't able to walk from a
VarDecl to a set of statements, and would (in some circumstances) walk
beyond the end of the list of statements, cause Bad Behavior.
In this change, we've gone back to representing the condition
variables as DeclStmts. While not as memory-efficient as VarDecls, it
greatly simplifies iteration over the children.
Douglas Gregor [Mon, 21 Jun 2010 22:31:09 +0000 (22:31 +0000)]
When semantic analysis fail to introduce a class or class template,
just skip over the body of the class or class template: it's a
semantic disaster that's likely to cause invariants to break. Fixes
part of <rdar://problem/8104754>.
Tom Care [Mon, 21 Jun 2010 21:21:01 +0000 (21:21 +0000)]
Bug 7377: printf checking fails to flag some undefined behavior
http://llvm.org/bugs/show_bug.cgi?id=7377
Updated format string highlighting and fixits to take advantage of the new CharSourceRange class.
- Change HighlightRange to allow highlighting whitespace only in a CharSourceRange (for warnings about the ' ' (space) flag)
- Change format specifier range helper function to allow for half-open ranges (+1 to end)
- Enabled previously failing tests (FIXMEs/XFAILs removed)
- Small fixes and additions to format string test cases
M test/Sema/format-strings.c
M test/Sema/format-strings-fixit.c
M lib/Frontend/TextDiagnosticPrinter.cpp
M lib/Sema/SemaChecking.cpp
Ted Kremenek [Mon, 21 Jun 2010 20:48:56 +0000 (20:48 +0000)]
Add CXType support for querying the return type of Objective-C methods. This is done by
adding a clang_getCursorResultType() function (which complements clang_getResultType()).
Ted Kremenek [Mon, 21 Jun 2010 20:15:39 +0000 (20:15 +0000)]
Add CXType support for FunctionNoProto and FunctionProto types. This includes adding a new
function, clang_getResultType(), which returns the result type of the function type.
Jordy Rose [Mon, 21 Jun 2010 20:15:15 +0000 (20:15 +0000)]
When folding additive operations, convert the values to the same type. When assuming relationships, convert the integers to the same type as the symbol, at least for now.
Douglas Gregor [Mon, 21 Jun 2010 18:41:26 +0000 (18:41 +0000)]
Instantiations subject to an explicit template instantiation
declaration have default visibility even under
-fvisibility=hidden. Fixes <rdar://problem/8109763>.
Fixes a corner case bug whereby declaring and defining an extern variable in a
particular sequence causes its definition to not be generated in the object file.
(fixes radar 8071804).
Jordy Rose [Sun, 20 Jun 2010 04:56:29 +0000 (04:56 +0000)]
Adds analyzer support for idempotent and tautological binary operations such as "a*0" and "a+0". This is not very powerful, but does make the analyzer look a little smarter than it actually is.
Jordy Rose [Sun, 20 Jun 2010 04:30:57 +0000 (04:30 +0000)]
Casting to void* or any other pointer-to-sizeless type (e.g. function pointers) causes a divide-by-zero error. Simple fix: check if the pointee type size is 0 and bail out early if it is.
Chris Lattner [Fri, 18 Jun 2010 22:45:06 +0000 (22:45 +0000)]
introduce a new CharSourceRange class, and enhance the diagnostics routines
to use them instead of SourceRange. CharSourceRange is just a SourceRange
plus a bool that indicates whether the range has the end character resolved
or whether the end location is the start of the end token. While most of
the compiler wants to think of ranges that have ends that are the start of
the end token, the printf diagnostic stuff wants to highlight ranges within
tokens.
This is transparent to the diagnostic stuff. To start taking advantage of
the new capabilities, you can do something like this:
Diag(..) << CharSourceRange::getCharRange(Begin,End)
Tom Care [Fri, 18 Jun 2010 03:02:16 +0000 (03:02 +0000)]
Printf format strings: Added some more tests and fixed some minor bugs.
- 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
Douglas Gregor [Thu, 17 Jun 2010 23:14:26 +0000 (23:14 +0000)]
Given Decl::isUsed() a flag indicating when to consider the "used"
attribute as part of the calculation. Sema::MarkDeclReferenced(), and
a few other places, want only to consider the "used" bit to determine,
e.g, whether to perform template instantiation. Fixes a linkage issue
with Boost.Serialization.
objective-C++ IRGen: property reference as an
lvalue when performing a derived-to-base conversion.
Fixes radar 7501812. Added an executable test to
llvm-test suite.
Zhanyong Wan [Thu, 17 Jun 2010 20:56:31 +0000 (20:56 +0000)]
Improves RecursiveASTVisitor:
* refactors code in DEF_TRAVERSE_DECL() into
TraverseDeclContextHelper() to reduce code bloat and facilitate
reuse.
* makes the order of traversing a FunctionDecl (including its
subclasses)'s children more natural: before the function parameters
are visited after the function body; now they are visited after the
function type and before the function body.
* fixes a double count for function return type and arguments.