Commit Graph

23790 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis b5288de67c Refactor PCH reading/writing of template arguments passed to expressions.
llvm-svn: 106997
2010-06-28 09:31:48 +00:00
Argyrios Kyrtzidis ddf5f211d0 Fix PCH emitting/reading for template arguments that contain expressions.
llvm-svn: 106996
2010-06-28 09:31:42 +00:00
Argyrios Kyrtzidis 0b0369a6b3 Fix various bugs in recent commits for C++ PCH.
llvm-svn: 106995
2010-06-28 09:31:34 +00:00
Chandler Carruth 2d69ec7a72 Partial fix for PR7267 based on comments by John McCall on an earlier patch.
This is more targeted, as it simply provides toggle actions for the parser to
turn access checking on and off. We then use these to suppress access checking
only while we parse the template-id (included scope specifier) of an explicit
instantiation and explicit specialization of a class template. The
specialization behavior is an extension, as it seems likely a defect that the
standard did not exempt them as it does explicit instantiations.

This allows the very common practice of specializing trait classes to work for
private, internal types. This doesn't address instantiating or specializing
function templates, although those apparently already partially work.

The naming and style for the Action layer isn't my favorite, comments and
suggestions would be appreciated there.

llvm-svn: 106993
2010-06-28 08:39:25 +00:00
Jordy Rose 61176897ba Pointer comparisons (and pointer-pointer subtraction). Basically filling in SimpleSValuator::EvalBinOpLL().
llvm-svn: 106992
2010-06-28 08:26:15 +00:00
Chandler Carruth b6f991787b Suppress diagnosing access violations while looking up deallocation functions
much as we already do for allocation function lookup. Explicitly check access
for the function we actually select in one case that was previously missing,
but being caught behind the blanket diagnostics for all overload candidates.
This fixs PR7436.

llvm-svn: 106986
2010-06-28 00:30:51 +00:00
Rafael Espindola b1ef8ffb15 Use softfp for linux gnueabi, keep the warning for everything else.
llvm-svn: 106984
2010-06-27 18:29:21 +00:00
Anders Carlsson 3f48c603fb Correctly destroy reference temporaries with global storage. Remove ErrorUnsupported call when binding a global reference to a non-lvalue. Fixes PR7326.
llvm-svn: 106983
2010-06-27 17:52:15 +00:00
Anders Carlsson 18c205ecdf Add a CreateReferenceTemporary that will do the right thing for variables with global storage.
llvm-svn: 106982
2010-06-27 17:23:46 +00:00
Anders Carlsson 2969c8c69d Simplify CodeGenFunction::EmitReferenceBindingToExpr as a first step towards fixing PR7326.
llvm-svn: 106981
2010-06-27 16:56:04 +00:00
Anders Carlsson ca68d357d4 Reduce indentation.
llvm-svn: 106980
2010-06-27 15:24:55 +00:00
Chris Lattner 818efb64a3 misc tidying
llvm-svn: 106978
2010-06-27 07:40:06 +00:00
Chris Lattner 5e016ae983 finally get around to doing a significant cleanup to irgen:
have CGF create and make accessible standard int32,int64 and 
intptr types.  This fixes a ton of 80 column violations 
introduced by LLVMContextification and cleans up stuff a lot.

llvm-svn: 106977
2010-06-27 07:15:29 +00:00
Chris Lattner e000907e13 tidy up OrderGlobalInits
llvm-svn: 106976
2010-06-27 06:32:58 +00:00
Chris Lattner 055097f024 If coercing something from int or pointer type to int or pointer type
(potentially after unwrapping it from a struct) do it without going through
memory.  We now compile:

struct DeclGroup {
  unsigned NumDecls;
};

int foo(DeclGroup D) {
  return D.NumDecls;
}

into:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %coerce.dive = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %coerce.val.ii = trunc i64 %0 to i32            ; <i32> [#uses=1]
  store i32 %coerce.val.ii, i32* %coerce.dive
  %tmp = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp1 = load i32* %tmp                          ; <i32> [#uses=1]
  ret i32 %tmp1
}

instead of:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %tmp = alloca i64                               ; <i64*> [#uses=2]
  %coerce.dive = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  store i64 %0, i64* %tmp
  %1 = bitcast i64* %tmp to i32*                  ; <i32*> [#uses=1]
  %2 = load i32* %1, align 1                      ; <i32> [#uses=1]
  store i32 %2, i32* %coerce.dive
  %tmp1 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp2 = load i32* %tmp1                         ; <i32> [#uses=1]
  ret i32 %tmp2
}

... which is quite a bit less terrifying.

llvm-svn: 106975
2010-06-27 06:26:04 +00:00
Chris Lattner 895c52ba8b Same patch as the previous on the store side. Before we compiled this:
struct DeclGroup {
  unsigned NumDecls;
};

int foo(DeclGroup D) {
  return D.NumDecls;
}

to:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %tmp = alloca i64                               ; <i64*> [#uses=2]
  store i64 %0, i64* %tmp
  %1 = bitcast i64* %tmp to %struct.DeclGroup*    ; <%struct.DeclGroup*> [#uses=1]
  %2 = load %struct.DeclGroup* %1, align 1        ; <%struct.DeclGroup> [#uses=1]
  store %struct.DeclGroup %2, %struct.DeclGroup* %D
  %tmp1 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp2 = load i32* %tmp1                         ; <i32> [#uses=1]
  ret i32 %tmp2
}

which caused fast isel bailouts due to the FCA load/store of %2.  Now
we generate this just blissful code:

%struct.DeclGroup = type { i32 }

define i32 @_Z3foo9DeclGroup(i64) nounwind ssp noredzone {
entry:
  %D = alloca %struct.DeclGroup, align 4          ; <%struct.DeclGroup*> [#uses=2]
  %tmp = alloca i64                               ; <i64*> [#uses=2]
  %coerce.dive = getelementptr %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  store i64 %0, i64* %tmp
  %1 = bitcast i64* %tmp to i32*                  ; <i32*> [#uses=1]
  %2 = load i32* %1, align 1                      ; <i32> [#uses=1]
  store i32 %2, i32* %coerce.dive
  %tmp1 = getelementptr inbounds %struct.DeclGroup* %D, i32 0, i32 0 ; <i32*> [#uses=1]
  %tmp2 = load i32* %tmp1                         ; <i32> [#uses=1]
  ret i32 %tmp2
}

This avoids fastisel bailing out and is groundwork for future patch.
This reduces bailouts on CGStmt.ll to 911 from 935.

llvm-svn: 106974
2010-06-27 06:04:18 +00:00
Chris Lattner 1cd6698a7c improve CreateCoercedLoad a bit to generate slightly less awful
IR when handling X86-64 by-value struct stuff.  For example, we
use to compile this:

struct DeclGroup {
  unsigned NumDecls;
};

int foo(DeclGroup D);
void bar(DeclGroup *D) {
  foo(*D);
}

into:

define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) ssp nounwind {
entry:
  %D.addr = alloca %struct.DeclGroup*, align 8    ; <%struct.DeclGroup**> [#uses=2]
  %agg.tmp = alloca %struct.DeclGroup, align 4    ; <%struct.DeclGroup*> [#uses=2]
  %tmp3 = alloca i64                              ; <i64*> [#uses=2]
  store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr
  %tmp = load %struct.DeclGroup** %D.addr         ; <%struct.DeclGroup*> [#uses=1]
  %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1]
  %tmp2 = bitcast %struct.DeclGroup* %tmp to i8*  ; <i8*> [#uses=1]
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false)
  %0 = bitcast i64* %tmp3 to %struct.DeclGroup*   ; <%struct.DeclGroup*> [#uses=1]
  %1 = load %struct.DeclGroup* %agg.tmp           ; <%struct.DeclGroup> [#uses=1]
  store %struct.DeclGroup %1, %struct.DeclGroup* %0, align 1
  %2 = load i64* %tmp3                            ; <i64> [#uses=1]
  call void @_Z3foo9DeclGroup(i64 %2)
  ret void
}

which would cause fastisel to bail out due to the first class aggregate load %1.  With
this patch we now compile it into the (still awful):

define void @_Z3barP9DeclGroup(%struct.DeclGroup* %D) nounwind ssp noredzone {
entry:
  %D.addr = alloca %struct.DeclGroup*, align 8    ; <%struct.DeclGroup**> [#uses=2]
  %agg.tmp = alloca %struct.DeclGroup, align 4    ; <%struct.DeclGroup*> [#uses=2]
  %tmp3 = alloca i64                              ; <i64*> [#uses=2]
  store %struct.DeclGroup* %D, %struct.DeclGroup** %D.addr
  %tmp = load %struct.DeclGroup** %D.addr         ; <%struct.DeclGroup*> [#uses=1]
  %tmp1 = bitcast %struct.DeclGroup* %agg.tmp to i8* ; <i8*> [#uses=1]
  %tmp2 = bitcast %struct.DeclGroup* %tmp to i8*  ; <i8*> [#uses=1]
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp1, i8* %tmp2, i64 4, i32 4, i1 false)
  %coerce.dive = getelementptr %struct.DeclGroup* %agg.tmp, i32 0, i32 0 ; <i32*> [#uses=1]
  %0 = bitcast i64* %tmp3 to i32*                 ; <i32*> [#uses=1]
  %1 = load i32* %coerce.dive                     ; <i32> [#uses=1]
  store i32 %1, i32* %0, align 1
  %2 = load i64* %tmp3                            ; <i64> [#uses=1]
  %call = call i32 @_Z3foo9DeclGroup(i64 %2) noredzone ; <i32> [#uses=0]
  ret void
}

which doesn't bail out.  On CGStmt.ll, this reduces fastisel bail outs from 958 to 935,
and is the precursor of better things to come.

llvm-svn: 106973
2010-06-27 05:56:15 +00:00
Jordy Rose 7f8ea4d677 Implicitly compare symbolic expressions to zero when they're being used as constraints. Part of PR7491.
llvm-svn: 106972
2010-06-27 01:20:56 +00:00
Chris Lattner e01d966ce2 merge two tests.
llvm-svn: 106971
2010-06-27 01:08:03 +00:00
Chris Lattner 3fcc790cd8 Change IR generation for return (in the simple case) to avoid doing silly
load/store nonsense in the epilog.  For example, for:

int foo(int X) {
  int A[100];
  return A[X];
}

we used to generate:

  %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]
  store i32 %tmp1, i32* %retval
  %0 = load i32* %retval                          ; <i32> [#uses=1]
  ret i32 %0
}

which codegen'd to this code:

_foo:                                   ## @foo
## BB#0:                                ## %entry
	subq	$408, %rsp              ## imm = 0x198
	movl	%edi, 400(%rsp)
	movl	400(%rsp), %edi
	movslq	%edi, %rax
	movl	(%rsp,%rax,4), %edi
	movl	%edi, 404(%rsp)
	movl	404(%rsp), %eax
	addq	$408, %rsp              ## imm = 0x198
	ret

Now we generate:

  %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i64 %idxprom ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]
  ret i32 %tmp1
}

and:

_foo:                                   ## @foo
## BB#0:                                ## %entry
	subq	$408, %rsp              ## imm = 0x198
	movl	%edi, 404(%rsp)
	movl	404(%rsp), %edi
	movslq	%edi, %rax
	movl	(%rsp,%rax,4), %eax
	addq	$408, %rsp              ## imm = 0x198
	ret

This actually does matter, cutting out 2000 lines of IR from CGStmt.ll 
for example.

Another interesting effect is that altivec.h functions which are dead
now get dce'd by the inliner.  Hence all the changes to 
builtins-ppc-altivec.c to ensure the calls aren't dead.

llvm-svn: 106970
2010-06-27 01:06:27 +00:00
Chris Lattner 726b3d09cd reduce indentation
llvm-svn: 106967
2010-06-26 23:13:19 +00:00
Chris Lattner 6c5abe88bf Implement rdar://7530813 - collapse multiple GEP instructions in IRgen
This avoids generating two gep's for common array operations.  Before
we would generate something like:

  %tmp = load i32* %X.addr                        ; <i32> [#uses=1]
  %arraydecay = getelementptr inbounds [100 x i32]* %A, i32 0, i32 0 ; <i32*> [#uses=1]
  %arrayidx = getelementptr inbounds i32* %arraydecay, i32 %tmp ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]

Now we generate:

  %tmp = load i32* %X.addr                        ; <i32> [#uses=1]
  %arrayidx = getelementptr inbounds [100 x i32]* %A, i32 0, i32 %tmp ; <i32*> [#uses=1]
  %tmp1 = load i32* %arrayidx                     ; <i32> [#uses=1]

Less IR is better at -O0.

llvm-svn: 106966
2010-06-26 23:03:20 +00:00
Ted Kremenek f00eac5cff Allow '__extension__' to be analyzed in a lvalue context.
llvm-svn: 106964
2010-06-26 22:40:52 +00:00
Chris Lattner 57ce97151f minor cleanup: don't emit the base of an array subscript until after
we're done diddling around with the index stuff.  Use a cheaper type
comparison.

llvm-svn: 106963
2010-06-26 22:40:46 +00:00
Chris Lattner 431bef4409 fix inc/dec to honor -fwrapv and -ftrapv, implementing PR7426.
llvm-svn: 106962
2010-06-26 22:18:28 +00:00
Chris Lattner 05dc78c096 move scalar inc/dec codegen into ScalarExprEmitter instead
of being in CGF.  No functionality change.

llvm-svn: 106961
2010-06-26 22:09:34 +00:00
Chris Lattner fa20e95043 use more efficient type comparison predicates.
llvm-svn: 106958
2010-06-26 21:52:32 +00:00
Chris Lattner 0bf27620f0 Fix unary minus to trap on overflow with -ftrapv, refactoring binop
code so we can use it from VisitUnaryMinus.

llvm-svn: 106957
2010-06-26 21:48:21 +00:00
Chris Lattner 51924e517b Implement support for -fwrapv, rdar://7221421
As part of this, pull together trapv handling into the same enum.

This also add support for NSW multiplies.

This also makes PCH disagreement on overflow behavior silent, since it
really doesn't matter except for warnings and codegen (no macros get 
defined etc).

llvm-svn: 106956
2010-06-26 21:25:03 +00:00
Chris Lattner 217e056e40 implement rdar://7432000 - signed negate should codegen as NSW.
While I'm in there, adjust pointer to member adjustments as well.

llvm-svn: 106955
2010-06-26 20:27:24 +00:00
Chris Lattner 30c924b3e8 Implement support for #pragma message, patch by Michael Spencer!
llvm-svn: 106950
2010-06-26 17:11:39 +00:00
Anders Carlsson 04775f8413 Change EmitReferenceBindingToExpr to take a decl instead of a boolean.
llvm-svn: 106949
2010-06-26 16:35:32 +00:00
Anders Carlsson 709ef8e46c Add function for mangling reference temporaries.
llvm-svn: 106948
2010-06-26 16:09:40 +00:00
Charles Davis f4db33cbdf Mangle pointer and (lvalue) reference types in the Microsoft C++ Mangler.
Also, fix mangling of throw specs. Turns out MSVC totally ignores throw
specs when mangling names.

llvm-svn: 106937
2010-06-26 03:50:05 +00:00
Daniel Dunbar 69a5af21e4 Remove cruft that I didn't intend to commit.
llvm-svn: 106932
2010-06-26 00:31:14 +00:00
Bob Wilson f11a38dcce Add a missing dependency to try to fix a buildbot failure.
It complained with:

llvm[5]: Building Clang arm_neon.h.inc with tblgen
cp: cannot create regular file `/build/buildbot-llvm/clang-x86_64-linux-selfhost-rel/llvm.obj.2/Release/lib/clang/2.0/include/arm_neon.h': No such file or directory

llvm-svn: 106922
2010-06-26 00:03:23 +00:00
Ted Kremenek 58f61ec1de Relax assertion since non-pod C++ classes are not aggregates, but still can appear in this context.
llvm-svn: 106919
2010-06-25 23:51:38 +00:00
Ted Kremenek a2a27d65a5 Add support for CXXRecordDecl in CFGRecStmtDeclVisitor.
llvm-svn: 106918
2010-06-25 23:51:34 +00:00
Daniel Dunbar d7e887fb7f clang: Derive version name from LLVM unless specified explicitly. This means
clang is now clang 2.8.

llvm-svn: 106914
2010-06-25 23:34:47 +00:00
Jordy Rose c3bcc36a0b When a constant size array is casted to another type, its length should be scaled as well.
llvm-svn: 106911
2010-06-25 23:23:04 +00:00
Ted Kremenek da42d523cf Add dead stores C++ test case that was previously asserting due to an
invalid source range for CXXNewExpr.

llvm-svn: 106904
2010-06-25 22:48:52 +00:00
Ted Kremenek abb1f91325 Use TypeSourceInfo to help determine the SourceRange of a CXXNewExpr. This fixes several
cases where we generated an invalid SourceRange for this expression.  Thanks to John McCall
for helping me figure this out.

llvm-svn: 106903
2010-06-25 22:48:49 +00:00
Fariborz Jahanian d3a476b976 Try making BuildBot happy again.
llvm-svn: 106898
2010-06-25 22:32:31 +00:00
Fariborz Jahanian 07b0a6e4d6 Test case for pr7490.
llvm-svn: 106887
2010-06-25 21:08:10 +00:00
Ted Kremenek fe97a1ac65 Add "checker caching" to GRExprEngine::CheckerVisit to progressively build
a winowed list of checkers that actually do something for a given StmtClass.
As the number of checkers grows, this may potentially significantly reduce
the number of checkers called at any one time.  My own measurements show that
for the ~20 registered Checker objects, only ~5 of them respond at any one time
to a give statement.  While this isn't a net performance win right now (there
is a minor slowdown on sqlite.3) this improvement does greatly improve debugging
when stepping through the checkers used to evaluate a given statement.

llvm-svn: 106884
2010-06-25 20:59:31 +00:00
Ted Kremenek 76abf19ea6 Fix -analyze-display-progress (once again), this time with an additional regression test.
llvm-svn: 106883
2010-06-25 20:59:24 +00:00
Fariborz Jahanian b66b08ef01 Minor change to my last patch to fix PR7490.
llvm-svn: 106875
2010-06-25 20:01:13 +00:00
Eric Christopher 17c7b89054 Translate numbers properly.
llvm-svn: 106873
2010-06-25 19:04:52 +00:00
Fariborz Jahanian d5202e0926 IRGen for trivial initialization of dynamiccaly allocated
array of other done c++ objects. Fixes PR7490.

llvm-svn: 106869
2010-06-25 18:26:07 +00:00
Tom Care 375387d1f8 Change RegionStoreManager::Retrieve to infer the type of a symbolic region from the context when it is not already available.
llvm-svn: 106868
2010-06-25 18:22:31 +00:00
Daniel Dunbar 283fe3d07a build: Get CLANG_VERSION from Version.inc instead of depending on VER file directly.
llvm-svn: 106864
2010-06-25 17:33:49 +00:00
Daniel Dunbar c3275c5440 build: Add a generated Version.inc file instead of duplicating information.
llvm-svn: 106863
2010-06-25 17:33:46 +00:00
Argyrios Kyrtzidis b1d38e3f4a Support NonTypeTemplateParmDecl for PCH.
llvm-svn: 106860
2010-06-25 16:25:09 +00:00
Argyrios Kyrtzidis 03e5e0467c Make PCHWriter::FlushStmts() robust. If we added null Stmts, reading them back got messed up.
llvm-svn: 106859
2010-06-25 16:25:02 +00:00
Argyrios Kyrtzidis f0f7a792d7 Support DependentTemplateSpecializationType and ElaboratedType for PCH.
llvm-svn: 106858
2010-06-25 16:24:58 +00:00
Argyrios Kyrtzidis dc9ca0afa8 Add forgotten breaks in case statements.
llvm-svn: 106857
2010-06-25 16:24:51 +00:00
Benjamin Kramer 9aa0d39443 A bug I've introduced in STDIN handling surfaced a few broken tests, fix them.
Lexer/hexfloat.cpp is now XFAIL'd, I'd appreciate if someone could look into it.

llvm-svn: 106840
2010-06-25 12:48:07 +00:00
Argyrios Kyrtzidis 58e01ad26f Support UnresolvedLookupExpr for PCH.
llvm-svn: 106832
2010-06-25 09:03:34 +00:00
Argyrios Kyrtzidis b8d3c63820 Support UnresolvedMemberExpr for PCH.
llvm-svn: 106831
2010-06-25 09:03:26 +00:00
Argyrios Kyrtzidis 6ba1bb5dec Print source location when we encounter unhandled statement during PCH writing.
llvm-svn: 106830
2010-06-25 09:03:12 +00:00
Chris Lattner 4d57fe4404 I don't know when I committed this, but it's probably a "bad thing".
llvm-svn: 106821
2010-06-25 05:00:29 +00:00
Chandler Carruth f40c42f2cd Implement dependent alignment attribute support. This is a bit gross given the
current attribute system, but it is enough to handle class templates which
specify parts of their alignment in terms of their template parameters.

This also replaces the attributes test in SemaTemplate with one that actually
tests working attributes instead of broken ones. I plan to add more tests here
for non-dependent attributes in a subsequent patch.

Thanks to John for walking me through some of this. =D

llvm-svn: 106818
2010-06-25 03:22:07 +00:00
Fariborz Jahanian ad356a14f9 Add comment for my last patch.
llvm-svn: 106813
2010-06-25 00:05:45 +00:00
John Thompson ceebdf1fc6 Fixed another double-char in PPC-specific asm constraints.
llvm-svn: 106812
2010-06-25 00:02:05 +00:00
John Thompson 07a61a41c8 Added PPC-specific asm constraints, PS3 configuration changes.
llvm-svn: 106806
2010-06-24 22:44:13 +00:00
Eric Christopher ca10da8839 Remove HAS_TLS define.
llvm-svn: 106786
2010-06-24 20:41:41 +00:00
Fariborz Jahanian 4f9c9d6591 Fixes a regression when redeclaration of a global satic
is an extern local to a function. Radar 8125274.

llvm-svn: 106773
2010-06-24 18:50:41 +00:00
Fariborz Jahanian b13ddbada1 Renamed selactor-expr-lvalue.mm to selector-expr-lvalue.mm.
Thanks Daniel D.

llvm-svn: 106758
2010-06-24 16:40:16 +00:00
Ted Kremenek 87f475a329 Return null pointer instead of 'false' (fixes clang warning).
llvm-svn: 106755
2010-06-24 16:26:12 +00:00
Zhongxing Xu facf8a8e74 Add check for illegal whence argument of fseek.
llvm-svn: 106742
2010-06-24 13:36:41 +00:00
Zhongxing Xu a7e5dd6c3a Should return stateNotNull.
llvm-svn: 106741
2010-06-24 13:09:02 +00:00
Zhongxing Xu ae45144d81 Let StreamChecker::CheckNullStream() return a GRState after successful check.
llvm-svn: 106738
2010-06-24 12:52:28 +00:00
Benjamin Kramer 322ab26387 Don't depend on system headers in clang -cc1 tests.
The constant was copied from clang's limits.h.

llvm-svn: 106732
2010-06-24 11:06:12 +00:00
Argyrios Kyrtzidis bfcacee9b3 Support a couple more C++ Exprs for PCH.
llvm-svn: 106727
2010-06-24 08:57:31 +00:00
Argyrios Kyrtzidis 30d98f3d9e Fix broken de/serialization for a couple of C++ Exprs.
llvm-svn: 106726
2010-06-24 08:57:09 +00:00
Eric Christopher 03256c32ff More clang support for darwin tls. Add a __has_feature macro and
target specific preprocessor define as well.

llvm-svn: 106715
2010-06-24 02:02:00 +00:00
Fariborz Jahanian 9b5528d278 Patch to correctly mangle block helper functions
when block literal is declared inside a ctor/dtor.
Fixes radr 8096995.

llvm-svn: 106700
2010-06-24 00:08:06 +00:00
Ted Kremenek 574f304631 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.

llvm-svn: 106689
2010-06-23 22:08:00 +00:00
Duncan Sands d3e231eb3c Add parentheses suggested by gcc.
llvm-svn: 106668
2010-06-23 19:34:52 +00:00
Daniel Dunbar b016d6c3d8 Revert "Tweak tests to hopefully fix include of limits.h on win32.", tweak fails on linux.
llvm-svn: 106661
2010-06-23 18:31:33 +00:00
Daniel Dunbar a99a3c108f Driver: Add make variable to allow disabling default integrated assembler, till
all the kinks are worked out.

llvm-svn: 106641
2010-06-23 18:15:13 +00:00
Ted Kremenek 7fe8e2d770 Add USR tests for ObjC class extensions.
llvm-svn: 106640
2010-06-23 18:10:30 +00:00
Daniel Dunbar 08748457b9 Tweak tests to hopefully fix include of limits.h on win32.
llvm-svn: 106639
2010-06-23 18:06:20 +00:00
Sebastian Redl 1fc3bdc61e Add isArrayType() to CanProxy's forwarders.
llvm-svn: 106629
2010-06-23 15:57:03 +00:00
Argyrios Kyrtzidis 818c5db054 Support C++ class template specializations and partial specializations for PCH.
llvm-svn: 106625
2010-06-23 13:48:30 +00:00
Argyrios Kyrtzidis fe6ba881b6 Modify ClassTemplateSpecializationDecl and ClassTemplatePartialSpecializationDecl to allow PCH read/write.
llvm-svn: 106624
2010-06-23 13:48:23 +00:00
Chris Lattner 37141f4fb4 improve altivec vector bool/pixel support, patch by Anton Yartsev
with several tweaks by me.

llvm-svn: 106619
2010-06-23 06:00:24 +00:00
Chris Lattner b48a2d5d2f polish the -finstrument-functions implementation, patch by Nelson Elhage!
llvm-svn: 106618
2010-06-23 05:21:28 +00:00
Zhongxing Xu 2213aa360a add comments.
llvm-svn: 106617
2010-06-23 02:12:00 +00:00
Zhongxing Xu 93cef8665c add comments.
llvm-svn: 106616
2010-06-23 02:06:56 +00:00
Ted Kremenek 2a33a0deef Correctly construct an ElementRegion for alloca() + pointer arithmetic. Fixes analyzer
crash reported in PR 7450.

llvm-svn: 106609
2010-06-22 23:58:31 +00:00
Douglas Gregor 689999da1f String literals enclosed in parentheses are still string
literals. Fixes PR7488.

llvm-svn: 106607
2010-06-22 23:47:37 +00:00
Douglas Gregor 769ba3e50c Make c++ and C++ valid extensions for C++ source files, from Seth Cantrell!
llvm-svn: 106602
2010-06-22 23:43:22 +00:00
Douglas Gregor a3208f9e7c 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).

llvm-svn: 106601
2010-06-22 23:41:02 +00:00
Fariborz Jahanian 3bf0ded346 Patch to provide separate ASTs for multiple ObjC class extension
declarations (implements radar 7928731).

llvm-svn: 106597
2010-06-22 23:20:40 +00:00
Douglas Gregor c646d13054 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.

llvm-svn: 106596
2010-06-22 23:13:52 +00:00
Douglas Gregor 49b4d73451 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++.

llvm-svn: 106595
2010-06-22 23:07:26 +00:00
Daniel Dunbar adef9327fe Support -mios-version-min= as an alias for -miphoneos-version-min=.
llvm-svn: 106587
2010-06-22 22:27:12 +00:00
Douglas Gregor 4ffbad1904 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.

llvm-svn: 106584
2010-06-22 22:12:46 +00:00
Daniel Dunbar a91c0ba88a Driver: Remove some dead code left around after a refactoring. Found by the
Clang static analyzer!

llvm-svn: 106568
2010-06-22 20:18:18 +00:00
Ted Kremenek 55081f9317 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.

llvm-svn: 106561
2010-06-22 19:05:10 +00:00
Fariborz Jahanian a9f90275cc Trying to make BuildBot happy again (related to PR7431).
llvm-svn: 106553
2010-06-22 17:08:32 +00:00
Argyrios Kyrtzidis 6e57c35513 Read/write CXXDeleteExpr from/to PCH.
llvm-svn: 106552
2010-06-22 17:07:59 +00:00
Douglas Gregor db48cf3c31 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.

llvm-svn: 106551
2010-06-22 16:52:27 +00:00
Fariborz Jahanian 7966aff294 Fixes a problem in generation of meta-data for
category implementation whereby property list was missing.
NeXt ObjC runtime (radar 8093297).

llvm-svn: 106550
2010-06-22 16:33:55 +00:00
Anders Carlsson ea836bc41c Switch over to the new caching version of getMangledName.
llvm-svn: 106549
2010-06-22 16:16:50 +00:00
Anders Carlsson 2e2f4d2e6d Add a new variant of getMangledName that caches the mangling for decls.
llvm-svn: 106547
2010-06-22 16:05:32 +00:00
Anders Carlsson 16d9f1788e Add GlobalDecl::getCanonicalDecl.
llvm-svn: 106546
2010-06-22 16:00:14 +00:00
Douglas Gregor a46d66122f When we ask for the enumerators of an EnumDecl, make sure we get them even if we have a EnumDecl that is not the definition of the enumeration
llvm-svn: 106541
2010-06-22 14:45:56 +00:00
Douglas Gregor c9ea2d5a67 In C++, allow a declaration of an enum to follow a definition of that
enum as a GNU extension.

llvm-svn: 106540
2010-06-22 14:26:35 +00:00
Argyrios Kyrtzidis 75000b6814 Fix PR7180.
For

void f( a:🅱️:c );

we would cache the tokens "a:🅱️:" 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:🅱️:".

llvm-svn: 106536
2010-06-22 11:30:04 +00:00
Argyrios Kyrtzidis 69da4a8f07 Support emitting/reading function templates to/from PCH.
llvm-svn: 106534
2010-06-22 09:55:07 +00:00
Argyrios Kyrtzidis ae85e2414c -Introduce PCHReader::ReadTemplateArgumentLoc()
-Introduce PCHWriter::AddTemplateArgumentLocInfo()
-Modify PCHWriter::AddTemplateArgumentLoc() to also write TemplateArgumentLoc's TemplateArgument
  and move the existing calls of AddTemplateArgumentLoc() to AddTemplateArgumentLocInfo().

llvm-svn: 106533
2010-06-22 09:54:59 +00:00
Argyrios Kyrtzidis cb6f346873 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.

llvm-svn: 106532
2010-06-22 09:54:51 +00:00
Benjamin Kramer 1e63c74f60 Silence warning about C++-style comments.
llvm-svn: 106531
2010-06-22 09:29:44 +00:00
Zhongxing Xu 4505747979 Add a bunch of stream APIs to SteamChecker.
llvm-svn: 106530
2010-06-22 07:50:21 +00:00
Douglas Gregor ef4a2a2b54 Apply array-to-pointer decay when instantiating a MemberExpr. Fixes
PR7405, patch by Kyle Lippincott!

llvm-svn: 106523
2010-06-22 02:41:05 +00:00
Douglas Gregor de049cdbe6 Attempt to fix test
llvm-svn: 106522
2010-06-22 02:17:07 +00:00
Fariborz Jahanian 469b200321 Per Chris's comment, remove another static (this one
is a static comparator operator).

llvm-svn: 106511
2010-06-22 00:23:08 +00:00
Chris Lattner 3c77a355e0 implement support for -finstrument-functions, patch by Nelson
Elhage!

llvm-svn: 106507
2010-06-22 00:03:40 +00:00
Douglas Gregor 27b98eae80 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. 

Fixes the remainder of <rdar://problem/8104754>.

llvm-svn: 106504
2010-06-21 23:44:13 +00:00
Fariborz Jahanian c9fec975e6 Avoid using a local static for providing lexical
order of priorotized global object initializations.

llvm-svn: 106503
2010-06-21 23:31:29 +00:00
Douglas Gregor 143d367ecf Zero out a stale pointer
llvm-svn: 106497
2010-06-21 22:46:46 +00:00
Douglas Gregor 9377c8230b 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>.

llvm-svn: 106496
2010-06-21 22:31:09 +00:00
Ted Kremenek e4e9941ae7 Update checker build.
llvm-svn: 106495
2010-06-21 22:25:24 +00:00
Fariborz Jahanian 2990e3a502 Test case for PR7431 by Nico Weber.
llvm-svn: 106494
2010-06-21 22:21:57 +00:00
Fariborz Jahanian 9adb2e646c In fragile-abi (32bit mode abi) generate global symbol
objc_category_name_xxx for each category implementation.
(fixes PR7431) patch by Nico Weber.

llvm-svn: 106492
2010-06-21 22:05:18 +00:00
Fariborz Jahanian 89bdd14f2f In supporting init-priority, globals with the same init_priority must be
emitted in the order in which they are seen (still radar 8076356).

llvm-svn: 106485
2010-06-21 21:27:42 +00:00
Tom Care 3f272b853f 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

llvm-svn: 106480
2010-06-21 21:21:01 +00:00
Anders Carlsson 280e61f148 Fix an Obj-C++ miscompile when calling an Obj-C method that returns a C++ reference.
llvm-svn: 106477
2010-06-21 20:59:55 +00:00
Ted Kremenek c62ab8d064 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()).

llvm-svn: 106473
2010-06-21 20:48:56 +00:00
Chris Lattner b5c9a04a2c accept and ignore two more gcc warning flags.
llvm-svn: 106472
2010-06-21 20:40:48 +00:00
Ted Kremenek c150887fef 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.

llvm-svn: 106459
2010-06-21 20:15:39 +00:00
Jordy Rose 79404afc1c 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.
llvm-svn: 106458
2010-06-21 20:15:15 +00:00
Jordy Rose 3d85888d4e If a nonnull argument evaluates to UnknownVal, don't warn (and don't crash).
llvm-svn: 106456
2010-06-21 20:08:28 +00:00
Fariborz Jahanian 090e4e5773 Use more efficient API of SmallVector/array_pod_sort
for sorting (radar 8076356).

llvm-svn: 106453
2010-06-21 19:49:38 +00:00
Ted Kremenek d34da45a83 Add clang_getCursorType() support for @property declarations.
llvm-svn: 106451
2010-06-21 19:41:40 +00:00
Fariborz Jahanian 9f2a4eed0d IRGen for implementation of init-priority attribute.
Test case will be checked in llvm test suite.
(finishes off radar 8076356).

llvm-svn: 106441
2010-06-21 18:45:05 +00:00
Douglas Gregor 5dd34744c5 Instantiations subject to an explicit template instantiation
declaration have default visibility even under
-fvisibility=hidden. Fixes <rdar://problem/8109763>.

llvm-svn: 106440
2010-06-21 18:41:26 +00:00
Fariborz Jahanian cc99b3ca9e 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).

llvm-svn: 106424
2010-06-21 16:08:37 +00:00
Argyrios Kyrtzidis a35c8e4092 Combine ClassTemplateDecl's PreviousDeclaration with CommonPtr, as in FunctionTemplateDecl.
llvm-svn: 106412
2010-06-21 10:57:41 +00:00
Nate Begeman ed48c857dc Implement remaining codegen for NEON, all operations should now work.
llvm-svn: 106407
2010-06-20 23:05:28 +00:00
Argyrios Kyrtzidis 41d4562da2 Support PCH emitting/reading of using declarations.
llvm-svn: 106404
2010-06-20 14:40:59 +00:00
Benjamin Kramer 22a544bc82 Add braces to avoid an ambiguous else, fixing a GCC warning.
llvm-svn: 106403
2010-06-20 10:20:36 +00:00
Jordy Rose 895c899142 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.
llvm-svn: 106402
2010-06-20 04:56:29 +00:00
Jordy Rose 2dd9b02cc8 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.
llvm-svn: 106401
2010-06-20 04:30:57 +00:00
Argyrios Kyrtzidis e1224c8aba Cure for Doug's insomnia.
llvm-svn: 106394
2010-06-19 19:58:34 +00:00
Argyrios Kyrtzidis 26b72453f7 Include a hack to allow loading of templated CXXRecordDecls and test template reading from PCH.
llvm-svn: 106393
2010-06-19 19:29:21 +00:00
Argyrios Kyrtzidis 95c04caf92 Initial support for reading templates from PCH.
llvm-svn: 106392
2010-06-19 19:29:09 +00:00
Argyrios Kyrtzidis 106caf92cd Initial support for writing templates to PCH.
llvm-svn: 106391
2010-06-19 19:28:53 +00:00
Anton Korobeynikov cc50b7d7d5 More AltiVec support.
Patch by Anton Yartsev!

llvm-svn: 106387
2010-06-19 09:47:18 +00:00
Chris Lattner 40ad0a2893 add a libs-only target to the clang makefile, patch by Sunay Ismail
in PR7397

llvm-svn: 106386
2010-06-19 06:35:25 +00:00
Eli Friedman c96b2496fc Fix for PR7415: refactor CodeGenModule::MayDeferGeneration and make it less
conservative for static variables in templated classes.

llvm-svn: 106385
2010-06-19 06:24:06 +00:00
Chris Lattner 87233f785b Fix PR7097, a bad interaction between -fno-use-cxa-atexit and
-mconstructor-aliases by using a WeakVH instead of a raw pointer.

llvm-svn: 106384
2010-06-19 05:52:45 +00:00
Fariborz Jahanian 0bf5ee74c4 More Sema Check and a test case for init_priority attr.
(radar 8076356).

llvm-svn: 106350
2010-06-18 23:14:53 +00:00
Jordy Rose c0fe8429f2 Fold additive constants, and support comparsions of the form $sym+const1 <> const2
llvm-svn: 106339
2010-06-18 22:49:11 +00:00
Chris Lattner ed8b6b799d 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)

llvm-svn: 106338
2010-06-18 22:45:06 +00:00
Douglas Gregor 7ba0c3fd55 A trivial fix for a test case that's too horrible to commit. Fixes
<rdar://problem/8108088>.

llvm-svn: 106328
2010-06-18 22:12:56 +00:00
Fariborz Jahanian ef5f621215 Implements Sema part of init_priority(priority) attribute
(radar 8076356) - wip.

llvm-svn: 106322
2010-06-18 21:44:06 +00:00
Douglas Gregor 8fba4f22ce Don't complain about missing field initializers when the initializer
list is completely empty, from Lasse Kärkkäinen! Fixes PR7413.

llvm-svn: 106320
2010-06-18 21:43:10 +00:00
Douglas Gregor 77e274fbc6 Merge the "regparm" attribute from a previous declaration of a
function to redeclarations of that function. Fixes PR7025.

llvm-svn: 106317
2010-06-18 21:30:25 +00:00
Gabor Greif 11614bcfe2 John called for a less surprising cast
llvm-svn: 106277
2010-06-18 10:11:35 +00:00
Charles Davis 108f5a2748 Mangle tag types (unions, structs, classes, enums) in the Microsoft C++ Mangler.
Also, test that static members with default visibility in a struct have the
right mangling.

llvm-svn: 106276
2010-06-18 07:51:00 +00:00
Tom Care 6e4ea2db7f 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

llvm-svn: 106275
2010-06-18 03:02:16 +00:00
Zhongxing Xu e96a9132b8 Add null stream check for more APIs.
llvm-svn: 106274
2010-06-18 02:47:46 +00:00
Alexis Hunt 31d8c14385 Rewrite comment to make my intentions slightly more clear.
llvm-svn: 106272
2010-06-18 02:14:45 +00:00
Ted Kremenek 520f47b66f Change two static variables into instance variables of ASTContext. This allows us to have multiple copies
of ASTContext at the same time.

llvm-svn: 106258
2010-06-18 00:31:04 +00:00
Douglas Gregor ebada077d9 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.

llvm-svn: 106252
2010-06-17 23:14:26 +00:00
Fariborz Jahanian 64cda8b5f3 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.

llvm-svn: 106247
2010-06-17 23:00:29 +00:00
Tom Care 9eee328dac Bug 7394 - Fixed toString representation of Precisions in format strings.
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp

llvm-svn: 106245
2010-06-17 22:55:40 +00:00
Fariborz Jahanian 6fdb139cdd Do not treat @selector as lvalue (unlike g++).
Patch by Nico Weber (pr7390).

llvm-svn: 106242
2010-06-17 21:45:48 +00:00
Zhanyong Wan cae2ea48fe 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.

Reviewed by chandlerc and csilvers.

llvm-svn: 106236
2010-06-17 20:56:31 +00:00
Fariborz Jahanian 9240f3dac7 Objective-c++ IRGen. Support for @selector expression as
an lvalue. Fixes PR7390.

llvm-svn: 106235
2010-06-17 19:56:20 +00:00
Tom Care b49ec6907b 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

llvm-svn: 106233
2010-06-17 19:00:27 +00:00
Douglas Gregor ffa20398a6 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.

llvm-svn: 106224
2010-06-17 16:03:49 +00:00
Douglas Gregor 630dec57a2 Use UnaryOperator as the representation of dependent expressions when
no overloaded operators were found in scope, mirroring what we already
do for BinaryOperator.

llvm-svn: 106222
2010-06-17 15:46:20 +00:00
Douglas Gregor 0552291859 Update CMake build system for ARM NEON generation.
llvm-svn: 106220
2010-06-17 15:17:41 +00:00
Craig Silverstein 8985debaaf 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.

Reviewed by chandlerc.

llvm-svn: 106218
2010-06-17 13:40:37 +00:00
Peter Collingbourne 49e7de1ff1 Fix typo (test commit)
llvm-svn: 106217
2010-06-17 12:39:05 +00:00
Gabor Greif 2cd6c7bd70 fix some more gcc3.4 constness warnings
llvm-svn: 106216
2010-06-17 11:29:31 +00:00
Gabor Greif ccd89b4419 use typedef to make hack more transparent and also appease gcc3.4 constness warning
llvm-svn: 106215
2010-06-17 10:59:08 +00:00
Argyrios Kyrtzidis e9b76afe4f Make sure the caching mechanism in Parser::ParseLexedMethodDefs is robust against the parser reading too few tokens.
llvm-svn: 106214
2010-06-17 10:52:22 +00:00
Argyrios Kyrtzidis 355094ef06 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.

llvm-svn: 106213
2010-06-17 10:52:18 +00:00
Argyrios Kyrtzidis fa533e7652 Don't ast-print the builtin __[u]int128_t.
llvm-svn: 106212
2010-06-17 10:52:11 +00:00
Charles Davis 8c02c13e19 Mangle operator names in the Microsoft C++ Mangler.
llvm-svn: 106211
2010-06-17 06:47:31 +00:00
Ted Kremenek 5df037e808 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.

llvm-svn: 106210
2010-06-17 04:21:37 +00:00
Ted Kremenek 35bf264f00 Include the bug description in the report hash so that we can emit multiple bugs of the same
type at the same location.

llvm-svn: 106209
2010-06-17 04:21:27 +00:00
Nate Begeman 35f4c1c6b1 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.

llvm-svn: 106208
2010-06-17 04:17:01 +00:00
Nate Begeman dbafec1f3e Remove last of the bool shifts for MS VC++, patch by dimitry andric
llvm-svn: 106206
2010-06-17 02:26:59 +00:00
Alexis Hunt 9fcdabe20f Comment Attr.td so people have a better understanding of what goes on.
Also removed the unused Aliases member.

llvm-svn: 106202
2010-06-17 01:51:32 +00:00
Ted Kremenek 98008a47a0 Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.
llvm-svn: 106196
2010-06-17 01:12:20 +00:00
Ted Kremenek 24c8e4f245 Per conversation with Doug, remove two assertions in ParseLexedMethodDefs() that
didn't indicate violated invariants but that we weren't recovering well.

llvm-svn: 106195
2010-06-17 00:59:17 +00:00
Alexis Hunt 849bccafe0 Fix yet another CMake typo. I'm not quite sure how this succeeded locally now.
llvm-svn: 106193
2010-06-17 00:51:27 +00:00
Alexis Hunt 367f638f04 Fix a typo in the previous commit I thought I'd fixed, but apparently didn't.
llvm-svn: 106189
2010-06-17 00:42:32 +00:00
Alexis Hunt c675ec09f0 Update CMake build for new attribute changes.
llvm-svn: 106188
2010-06-17 00:37:02 +00:00
Ted Kremenek 17504bea33 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.

This fixes PR 7383.

llvm-svn: 106184
2010-06-17 00:24:44 +00:00
Ted Kremenek 648ef7a2d7 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.

llvm-svn: 106183
2010-06-17 00:24:42 +00:00
Ted Kremenek 70c090822d Correctly return early from BasicStoreManager::iterBindings() when the BindingsHandler returns false.
llvm-svn: 106182
2010-06-17 00:24:37 +00:00
Douglas Gregor 428119e39a 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>.

llvm-svn: 106175
2010-06-16 23:45:56 +00:00
Alexis Hunt 344393e9cf 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.

llvm-svn: 106172
2010-06-16 23:43:53 +00:00