Francois Pichet [Fri, 25 Nov 2011 01:10:54 +0000 (01:10 +0000)]
In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside a friend function definition at class scope.
Basically we have to look into the parent *lexical* DeclContext for friend functions at class scope. That's because calling GetParent() return the namespace or file DeclContext.
This fixes all remaining cases of "Unqualified lookup into dependent bases of class templates" when parsing MFC code with clang.
Richard Trieu [Wed, 23 Nov 2011 22:32:32 +0000 (22:32 +0000)]
Add feature to diagnostics that will provide more information on function
pointer mismatch. Cases covered are: initialization, assignment, and function
arguments. Additional text will give the extra information about the nature
of the mismatch: different classes for member functions, wrong number of
parameters, different parameter type, different return type, and function
qualifier mismatch.
[libclang] Fix operations (token annotation, getting cursor, etc.) with a file region
inside an objc container that "contains" other file-level declarations.
When getting the array of file-level declarations that overlap with a file region,
we failed to report that the region overlaps with an objc container, if
the container had other file-level declarations declared lexically inside it.
Fix this by marking such declarations as "isTopLevelDeclInObjCContainer" in the AST
and handling them appropriately.
Richard Smith [Mon, 21 Nov 2011 19:36:32 +0000 (19:36 +0000)]
Add driver arguments -ftemplate-depth=N and -fconstexpr-depth=N, with the same
semantics and defaults as the corresponding g++ arguments. The historical g++
argument -ftemplate-depth-N is kept for compatibility, but modern g++ versions
no longer document that option.
Add -cc1 argument -fconstexpr-depth N to implement the corresponding
functionality.
Teach the driver about failure result files, which are compilation
output files that are valid regardless of whether the compilation
succeeded or failed (but not if we crash). Add depfiles to the
failure result file list.
Benjamin Kramer [Sat, 19 Nov 2011 10:24:49 +0000 (10:24 +0000)]
Driver: Remove the signal number from the "command failed" diagnostic.
- With the current implementation of sys::Program this always printed "2".
- The command execution code will output the right number anyway (including the signal name).
Ted Kremenek [Fri, 18 Nov 2011 04:32:13 +0000 (04:32 +0000)]
Refine placement of LangOptions object in CompilerInvocation by adding a new baseclass CompilerInvocationBase with a custom copy constructor. This ensures that whenever the CompilerInvocation object's copy constructor is used we always clone the LangOptions object.
Eli Friedman [Fri, 18 Nov 2011 03:47:20 +0000 (03:47 +0000)]
Fix the meaning of an "empty" record for the case of a zero-length array. Use isEmptyRecord for arguments on x86-32; there are structs of size 0 which don't count as empty.
Eli Friedman [Fri, 18 Nov 2011 01:25:50 +0000 (01:25 +0000)]
Simplify code for returning a struct for Darwin x86-32 ABI. Use a better type for a function returning a struct containing only a pointer. Handle the edge case of a struct containing only a float or double plus some dead padding instead of asserting.
-For indexDeclaration, also pass the declaration attributes as an array of cursors.
-Rename CXIndexOpt_OneRefPerFile -> CXIndexOpt_SuppressRedundantRefs, and only pass
a reference if a declaration/definition does not exist in the file.
-Other fixes.
Anna Zaks [Thu, 17 Nov 2011 23:07:28 +0000 (23:07 +0000)]
[analyzer] Do not conjure a symbol when we need to propagate taint.
When the solver and SValBuilder cannot reason about symbolic expressions (ex: (x+1)*y ), the analyzer conjures a new symbol with no ties to the past. This helps it to recover some path-sensitivity. However, this breaks the taint propagation.
With this commit, we are going to construct the expression even if we cannot reason about it later on if an operand is tainted.
Ted Kremenek [Thu, 17 Nov 2011 23:01:24 +0000 (23:01 +0000)]
Make 'LangOptions' in CompilerInvocation a heap-allocated, reference counted object. I discovered that llvm::RefCountedBase<T> has
a bug where the reference count is copied in the copy constructor, which means that there were cases when the CompilerInvocation
objects created by ASTUnit were actually leaked. When I fixed that bug locally, it showed that a whole bunch of code assumed
that the LangOptions object that was part of CompilerInvocation was still alive. By making it heap-allocated and reference counted,
we can keep it around after the CompilerInvocation object goes away.
As part of this change, change CompilerInvocation:getLangOptions() to return a pointer, acting as another clue that this
object may outlive the CompilerInvocation object.
This commit doesn't fix the CompilerInvocation leak itself. That will come when I commit the fix to llvm::RefCountedBase<T> to
mainline LLVM.
Ted Kremenek [Thu, 17 Nov 2011 23:01:17 +0000 (23:01 +0000)]
Simplify crash cleanup logic in ASTUnit::LoadFromCommandLine() by zeroing out two IntrusiveRefCnt pointers after we have assigned their respective values into fields of ASTUnit.
Douglas Gregor [Thu, 17 Nov 2011 22:44:56 +0000 (22:44 +0000)]
When making a suggestion regarding which module to load rather than
preprocess/parse a header, report back with an actual module (which
may be a submodule) rather than just the name of the module.
Douglas Gregor [Thu, 17 Nov 2011 22:09:43 +0000 (22:09 +0000)]
Add the notion of "framework" modules to module maps. Framework
modules (obviously) describe frameworks, and understand the header
layout of frameworks.
Francois Pichet [Thu, 17 Nov 2011 03:44:24 +0000 (03:44 +0000)]
In Microsoft mode, make "Unqualified lookup into dependent bases of class templates" works inside default argument instantiation.
This is a little bit tricky because during default argument instantiation the CurContext points to a CXXMethodDecl but we can't use the keyword this or have an implicit member call generated.
This fixes 2 errors when parsing MFC code with clang.
Douglas Gregor [Thu, 17 Nov 2011 01:41:17 +0000 (01:41 +0000)]
When we're loading a framework header, first try to turn the framework
into a module. This module can either be loaded from a module map in
the framework directory (which isn't quite working yet) or inferred
from an umbrella header (which does work, and replaces the existing
hack).
Daniel Dunbar [Thu, 17 Nov 2011 00:36:53 +0000 (00:36 +0000)]
tests/Driver/darwin-ld.c: Get rid of the "splatter" test case. We have enough
other coverage that actually properly checks features such that this test is not
really adding value anymore.
Daniel Dunbar [Wed, 16 Nov 2011 23:22:07 +0000 (23:22 +0000)]
build/make/compiler-rt: Don't attempt to build compiler-rt runtime libraries
when cross compiling under the current organization.
- See verbose comment for explanation, justification, and how to fix.
Douglas Gregor [Wed, 16 Nov 2011 23:02:25 +0000 (23:02 +0000)]
A module with an umbrella header assumes that all of the headers in
the umbrella header's directory and its subdirectories are part of the
module (that's why it's an umbrella). Make sure that these headers are
considered to be part of the module for lookup purposes.
Bob Wilson [Wed, 16 Nov 2011 21:32:23 +0000 (21:32 +0000)]
Fix Neon builtin pointer argument checking for "sret" builtins.
The code for checking Neon builtin pointer argument types was assuming that
there would only be one pointer argument. But, for vld2-4 builtins, the first
argument is a special sret pointer where the result will be stored. So,
instead of scanning all the arguments to find a pointer, have TableGen figure
out the index of the pointer argument that needs checking. That's better than
scanning all the arguments regardless. <rdar://problem/10448804>
Jim Goodnow II [Wed, 16 Nov 2011 20:29:27 +0000 (20:29 +0000)]
Fixed crash with initializer lists and unnamed bitfields in the RegionStore
Manager. Added test to ensure proper binding of initialized values.
This patch fixes PR11249.
Douglas Gregor [Wed, 16 Nov 2011 20:05:18 +0000 (20:05 +0000)]
Implement (de-)serialization of the buffer contents for an overridden
file in the source manager. This allows us to properly create and use
modules described by module map files without umbrella headers (or
with incompletely umbrella headers). More generally, we can actually
build a PCH file that makes use of file -> buffer remappings, which
could be useful in libclang in the future.
Anna Zaks [Wed, 16 Nov 2011 19:58:17 +0000 (19:58 +0000)]
[analyzer] Catch the first taint propagation implied buffer overflow.
Change the ArrayBoundCheckerV2 to be more aggressive in reporting buffer overflows
when the offset is tainted. Previously, we did not report bugs when the state was
underconstrained (not enough information about the bound to determine if there is
an overflow) to avoid false positives. However, if we know that the buffer
offset is tainted - comes in from the user space and can be anything, we should
report it as a bug.
+ The very first example of us catching a taint related bug.
This is the only example we can currently handle. More to come...
Anna Zaks [Wed, 16 Nov 2011 19:58:10 +0000 (19:58 +0000)]
[analyzer] Adding basic building blocks for taint propagation.
TaintTag.h will contain definitions of different taint kinds and their properties.
TaintManager will be responsible for implementing taint specific operations, storing taint.
ProgramState will provide API to add/remove taint.
Anna Zaks [Wed, 16 Nov 2011 19:57:55 +0000 (19:57 +0000)]
[analyzer] Factor getCalleeName to the checker context.
many checkers are trying to get a name of the callee when visiting
a CallExpr, so provide a convenience API.
Chandler Carruth [Wed, 16 Nov 2011 19:29:07 +0000 (19:29 +0000)]
Stop claiming that Visual Studio 2005 is a viable basis for building
Clang. It isn't any more, and we're not going to twist the code around
to make it work.
Douglas Gregor [Wed, 16 Nov 2011 17:04:00 +0000 (17:04 +0000)]
When building a module from a module map that isn't simply an umbrella
header, create our own in-memory buffer to parse all of the
appropriate headers, and use that to build the module. This isn't
end-to-end testable yet; that's coming next.
Richard Smith [Wed, 16 Nov 2011 07:18:12 +0000 (07:18 +0000)]
Fix PR11385: A pointer constant expression which has been cast via an integer is
not safely derived. Don't allow lvalue-to-rvalue conversions on the result of
dereferencing such a pointer.