Chris Lattner [Thu, 29 Jul 2010 18:13:09 +0000 (18:13 +0000)]
fix rdar://8251384, another case where we could access beyond the
end of a struct. This improves the case when the struct being passed
contains 3 floats, either due to a struct or array of 3 things. Before
we'd generate this IR for the testcase:
Chris Lattner [Thu, 29 Jul 2010 17:49:08 +0000 (17:49 +0000)]
start setting up infrastructure for passing multi-floats
as <2 x float> instead of as double. The backend isn't ready
yet, but infrastructure in the frontend can come up.
Chris Lattner [Thu, 29 Jul 2010 17:40:35 +0000 (17:40 +0000)]
rename Get8ByteTypeAtOffset -> GetINTEGERTypeAtOffset to
make it clear that this function should only return a type
that the codegen will classify the same as an INTEGER type.
Chris Lattner [Thu, 29 Jul 2010 17:04:54 +0000 (17:04 +0000)]
fix PR7742 / rdar://8250764, a miscompilation of struct
return where the struct has a base but no fields. This
was because the x86-64 abi logic was checking the wrong
predicate in one place.
This was introduced in r91874, which was a fix for PR5831,
which lacked a CHECK line, so I verified and added it.
This patch refactors much of the common code in ClassTemplateDecl and
FunctionTemplateDecl into a common base class RedeclarableTemplateDecl
together with support functions in a template class RedeclarableTemplate.
The patch also includes similar refactoring for these classes' PCH
reader and writer implementations.
Douglas Gregor [Thu, 29 Jul 2010 16:05:45 +0000 (16:05 +0000)]
When taking the address of a value of Objective-C object type (e.g.,
one because we're referencing a variable of type NSString &), the
resulting type is an ObjCObjectPointerType.
Douglas Gregor [Thu, 29 Jul 2010 15:18:02 +0000 (15:18 +0000)]
Allow a looser form of compatibility checking (which ignores
qualifiers) when checking a K&R function definition against a previous
prototype. Fixes <rdar://problem/8193107>.
Chris Lattner [Thu, 29 Jul 2010 06:26:06 +0000 (06:26 +0000)]
Kill off the 'coerce' ABI passing form. Now 'direct' and 'extend' always
have a "coerce to" type which often matches the default lowering of Clang
type to LLVM IR type, but the coerce case can be handled by making them
not be the same.
This simplifies things and fixes issues where X86-64 abi lowering would
return coerce after making preferred types exactly match up. This caused
us to compile:
define <4 x float> @foo(<4 x float> %X.coerce) nounwind {
entry:
%retval = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%coerce = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=2]
%X.addr = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
store <4 x float> %X.coerce, <4 x float>* %coerce
%X = load <4 x float>* %coerce ; <<4 x float>> [#uses=1]
store <4 x float> %X, <4 x float>* %X.addr
%tmp = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1]
%tmp1 = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1]
%add = fadd <4 x float> %tmp, %tmp1 ; <<4 x float>> [#uses=1]
store <4 x float> %add, <4 x float>* %retval
%0 = load <4 x float>* %retval ; <<4 x float>> [#uses=1]
ret <4 x float> %0
}
Now we get:
define <4 x float> @foo(<4 x float> %X) nounwind {
entry:
%X.addr = alloca <4 x float>, align 16 ; <<4 x float>*> [#uses=3]
store <4 x float> %X, <4 x float>* %X.addr
%tmp = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1]
%tmp1 = load <4 x float>* %X.addr ; <<4 x float>> [#uses=1]
%add = fadd <4 x float> %tmp, %tmp1 ; <<4 x float>> [#uses=1]
ret <4 x float> %add
}
Chris Lattner [Thu, 29 Jul 2010 04:41:05 +0000 (04:41 +0000)]
sink preferred type stuff lower. It's possible that this might
improve codegen for vaarg or something, because its codepath is
getting preferred types now.
Chris Lattner [Thu, 29 Jul 2010 02:31:05 +0000 (02:31 +0000)]
dissolve some more complexity: make the x86-64 abi lowering code
compute its own preferred types instead of having CGT compute
them then pass them (circuituously) down into ABIInfo.
Chris Lattner [Thu, 29 Jul 2010 02:16:43 +0000 (02:16 +0000)]
now that ABIInfo depends on CGT, it has trivial access to such
things as TargetData, ASTContext, LLVMContext etc. Stop passing
them through so many APIs.
Check for an invalid SourceLocation in clang_getCursor(). This avoids a possible assertion failure in SourceManager in the call to Lexer::GetBeginningOfToken(). Fixes <rdar://problem/8244873>.
Augment RegionStore::BindStruct() to bind symbolicated struct values. This fixes a false path issue reported in <rdar://problem/8243408> and also spurs another cause where the idempotent operations checker fires.
Douglas Gregor [Wed, 28 Jul 2010 23:59:57 +0000 (23:59 +0000)]
Don't set out-of-line template specialization/definition information
for AST nodes that aren't actually out-of-line (i.e., require a
nested-name-specifier). Fixes <rdar://problem/8204126>.
Chris Lattner [Wed, 28 Jul 2010 23:47:21 +0000 (23:47 +0000)]
pass argument vectors in a type that corresponds to the user type if
possible. This improves the example to pass <4 x float> instead of
<2 x double> but we still get awful code, and still don't get the
return value right.
Chris Lattner [Wed, 28 Jul 2010 22:15:08 +0000 (22:15 +0000)]
fix PR7714 by not referencing off the end of a struct when passed by value in
x86-64 abi. This also improves codegen as well. Some refactoring is needed of
this code.
Douglas Gregor [Wed, 28 Jul 2010 21:50:18 +0000 (21:50 +0000)]
When performing code completion for a case statement in a switch whose
condition is not of enumeration type, provide code-completion results
containing all values of integral or enumeral type.
Sebastian Redl [Wed, 28 Jul 2010 21:07:02 +0000 (21:07 +0000)]
Add a test case for tentative definitions in chained PCH. Fix a bug that completely messed up source locations and thus caused a crash whenever a diagnostic was emitted in chained PCH files.
Douglas Gregor [Wed, 28 Jul 2010 18:22:12 +0000 (18:22 +0000)]
The grammar for GNU typeof in C requires an expression to be
parenthesized, unlike in C++, e.g.,
C has: typeof ( expression)
C++ has: typeof unary-expression
So, once we've parsed a parenthesized expression after typeof, we
should only go on to parse the postfix expression suffix if we're in
C++. Fixes <rdar://problem/8237491>.
Add proper callbacks for DeclStmt -- we weren't recursing on
the decls. This was just an oversight before; one we didn't
catch because lots of information in a DeclStmt was also being
traversed (redundantly) elsewhere.
Once DeclStmt was cleaned up, I could clean up some of the
redundant traversals found elswhere as well -- in particular,
traversing the declarations inside a function as part of the
function callback (instead of as part of the CompoundExpr
callback that constitutes the body of the function). The old
way was really weird, and led to some parts of local variable
declarations (but not all) being visited twice. That is now
resolved. I also was able to simplify the traversers for
IfStmt/WhileStmt/etc, which used to have redundant calls to
work around the fact DeclStmt wasn't working properly.
While in the area, I fixed up a few more recursion-ordering
issues. I try to hold to the principle that
RecursiveASTVisitor visits objects in the source code in the
same order they're typed. So the return-type of a variable
comes before the variable-name. This still isn't perfect, but
we're closer to that.
Daniel Dunbar [Wed, 28 Jul 2010 15:40:33 +0000 (15:40 +0000)]
Preprocessor: Add support for '#pragma clang __debug crash' and '#pragma clang
__debug overflow_stack'.
- For testing crash reporting stuff... you'd think I could just use some C++
code but Doug keeps fixing stuff!
Douglas Gregor [Wed, 28 Jul 2010 15:14:14 +0000 (15:14 +0000)]
Enable expression transformations in the current-instantiation
rebuilder, i.e., remove a silly short-sighted hack from long
ago. Thanks to Abramo Bagnara for the test case/bug report!
Douglas Gregor [Wed, 28 Jul 2010 14:49:07 +0000 (14:49 +0000)]
When a nested-name-specifier refers into a current instantiation that has
dependent bases, construct a dependent nested-name-specifier rather
than complaining that the name could not be found within the current
instantiation itself. Fixes PR7725.
John McCall [Wed, 28 Jul 2010 01:07:35 +0000 (01:07 +0000)]
When creating a jump destination, its scope should be the scope of the
enclosing normal cleanup, not the top of the EH stack. I'm *really*
surprised this hasn't been causing more problems.
Tom Care [Tue, 27 Jul 2010 23:30:21 +0000 (23:30 +0000)]
Added some false positive checking to UnreachableCodeChecker
- Allowed reporting of dead macros
- Added path walking function to search for false positives in conditional statements
- Updated some affected tests
- Added some false positive test cases
Merge PCHWriterDecl.cpp's isRequiredDecl and CodeGenModule::MayDeferGeneration into a new function,
DeclIsRequiredFunctionOrFileScopedVar.
This function is part of the public CodeGen interface since it's essentially a CodeGen predicate that is also
needed by the PCH mechanism to determine whether a decl needs to be deserialized during PCH loading for codegen purposes.
This fixes current (and avoids future) codegen-from-PCH bugs.
Finesse 'idempotent operations' analyzer issues to include the opcode of the binary operator for clearer error reporting. Also remove the 'Idempotent operation' prefix in messages; it's redundant since the bug type is the same.
Jordy Rose [Tue, 27 Jul 2010 01:37:31 +0000 (01:37 +0000)]
Groundwork for C string length tracking. Currently only handles the length of constant string literals, which is not too helpful, and only calls to strlen() are checked.
Douglas Gregor [Tue, 27 Jul 2010 00:27:13 +0000 (00:27 +0000)]
Implement -fno-validate-pch at the -cc1 level, which suppresses most
of the usual consistency checks used to determine when a precompiled
header is incompatible with the translation unit it's being loaded
into.
Enable this option when loading a precompiled preamble, because the
preamble loader will be performing all of this checking itself. Enable
the preamble-based test now that it's working.
This option is also useful for debugging Clang's PCH
(<rdar://problem/7532213>).
Sebastian Redl [Tue, 27 Jul 2010 00:17:23 +0000 (00:17 +0000)]
- Fix recording of offsets of types in dependent PCHs.
- Stop reading in (and thus deserializing) every declaration in the TU when creating a dependent PCH.
- Switch the storage of a decl context's lexical declarations to a blob containing the IDs instead of a record. This is the only sane way of supporting update records later on.
Douglas Gregor [Mon, 26 Jul 2010 23:54:23 +0000 (23:54 +0000)]
When remapping a virtual file, also make an entry for the file with
its absolute path on disk. Also, introduce a fun test for the
precompiled preamble, which almost works...