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.
Tom Care [Thu, 17 Jun 2010 19:00:27 +0000 (19:00 +0000)]
Bug 7377: Fixed several bad printf format string bugs.
- 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
Douglas Gregor [Thu, 17 Jun 2010 16:03:49 +0000 (16:03 +0000)]
When pushing a copy of the TypeLoc information for a dependent
template specialization type, copy the location information but use
the new type. Fixes PR7385.
Douglas Gregor [Thu, 17 Jun 2010 15:46:20 +0000 (15:46 +0000)]
Use UnaryOperator as the representation of dependent expressions when
no overloaded operators were found in scope, mirroring what we already
do for BinaryOperator.
Some fixes to type-visiting -- a few places where the type-name was
explicitly typed in the source, but we weren't recursing on it. One
is new <type>, the other is <type>() (eg int()).
I also fixed the initializer parsing to parse on the syntactic
initializer list, not the semantic. Usually they'll be identical, so
this won't affect much in practice, but keeps the AST as a syntax-tree
visitor.
Make sure parens/braces/brackets are correctly balanced.
In a line like:
(;
the semicolon leaves Parser:ParenCount unbalanced (it's 1 even though we stopped looking for a right paren).
This may affect later parsing and result in bad recovery for parsing errors.
Ted Kremenek [Thu, 17 Jun 2010 04:21:37 +0000 (04:21 +0000)]
Tweak stack address checker to report multiple cases where globals may reference stack memory.
Also refactor the diagnostics so that we print out the kind of stack memory returned.
Nate Begeman [Thu, 17 Jun 2010 04:17:01 +0000 (04:17 +0000)]
Generate arm_neon.inc in include/clang/Basic, which provides:
1. builtins definitions for BuiltinsARM.def
2. intrinsic validation code for SemaChecking
Unsure as to whether this is the best way to handle the make dependencies or not.
Ted Kremenek [Thu, 17 Jun 2010 00:59:17 +0000 (00:59 +0000)]
Per conversation with Doug, remove two assertions in ParseLexedMethodDefs() that
didn't indicate violated invariants but that we weren't recovering well.
Ted Kremenek [Thu, 17 Jun 2010 00:24:44 +0000 (00:24 +0000)]
Rework StackAddrLeakChecker to find stores of stack memory addresses to global variables
by inspecting the Store bindings instead of iterating over all the global variables
in a translation unit. By looking at the store directly, we avoid cases where we cannot
directly load from the global variable, such as an array (which can result in an assertion failure)
and it also catches cases where we store stack addresses to non-scalar globals.
Also, but not iterating over all the globals in the translation unit, we maintain cache
locality, and the complexity of the checker becomes restricted to the complexity of the
analyzed function, and doesn't scale with the size of the translation unit.
Ted Kremenek [Thu, 17 Jun 2010 00:24:42 +0000 (00:24 +0000)]
Implement RegionStoreManager::iterBindings(). This implementation only returns the base region in
the binding key instead of the region + offset. It isn't clear if this is the best semantics, but most
clients will likely only care about simple bindings, or bindings to a particular variable. We can
refine later if necessary.
Douglas Gregor [Wed, 16 Jun 2010 23:45:56 +0000 (23:45 +0000)]
When parsing cached C++ method declarations/definitions, save the
"previous token" location at the end of the class definition. This
eliminates a badly-placed error + Fix-It when the ';' following a
class definition is missing. Fixes <rdar://problem/8066414>.
Sean Hunt [Wed, 16 Jun 2010 23:43:53 +0000 (23:43 +0000)]
Implement first TD-based usage of attributes.
Currently, there are two effective changes:
- Attr::Kind has been changed to attr::Kind, in a separate namespace
rather than the Attr class. This is because the enumerator needs to
be visible to parse.
- The class definitions for the C++0x attributes other than aligned are
generated by TableGen.
The specific classes generated by TableGen are controlled by an array in
TableGen (see the accompanying commit to the LLVM repository). I will be
expanding the amount of code generated as I develop the new attributes system
while initially keeping it confined to these attributes.