Commit Graph

5136 Commits

Author SHA1 Message Date
Fariborz Jahanian 88cc2340de Renamed ObjCKVCRefExpr to ObjCImplctSetterGetterRefExpr.
Removed an unnecessary loop to get to setters incoming
argument. Added DoxyGen comments. Still more work
to do in this area (WIP).

llvm-svn: 79365
2009-08-18 20:50:23 +00:00
Anders Carlsson a192947509 Change ActOnReturnStmt to not take a FullExprArg. Instead, Sema will wrap the return expr inside a CXXExprWithTemporaries if needed.
llvm-svn: 79342
2009-08-18 16:11:00 +00:00
Zhongxing Xu 7864b9ea0c Remove unused parameter BugReporter due to previous patch.
llvm-svn: 79328
2009-08-18 08:58:41 +00:00
Zhongxing Xu 4c76dbc758 Now we can get the CFG from the ProgramPoint. No need to pass in the
BugReporter.

llvm-svn: 79327
2009-08-18 08:46:04 +00:00
Ted Kremenek 9b2c79de59 Enhance static analyzer diagnostics by introducing a new 'EnhancedBugReporter'
which allows custom checks to register callback creator functions for creating
BugReporterVisitor objects. This allows various checks to include diagnostics
such as 'assuming value is null' with little extra work. Eventually this API
should be refactored to be cleaner and more simple.

llvm-svn: 79302
2009-08-18 01:05:30 +00:00
David Chisnall 9f57c29053 Initial patch to support definitions of id and Class from headers in Objective-C code.
This currently breaks test/SemaObjC/id-isa-ref.m and issues some spurious warnings when you attempt to assign a struct objc_class* value to a Class variable.  The test case probably should fail as it's written, because without the definition of Class the compiler should not assume struct objc_class* is a valid receiver type, but it's left broken because it would be nice if we could get that passing too for the special case of isa.

Approved by snaroff.

llvm-svn: 79248
2009-08-17 16:35:33 +00:00
Zhongxing Xu a7a35bc2a6 Remove unused variable.
llvm-svn: 79229
2009-08-17 06:30:30 +00:00
Zhongxing Xu 5f078cb844 To make the analysis independent on the locally stored liveness and cfg
of GRStateManager and GRExprEngine, pass the initial location context
to the getInitialState() method.

llvm-svn: 79228
2009-08-17 06:19:58 +00:00
Anders Carlsson b80760bd78 Destroy bound temporaries.
llvm-svn: 79196
2009-08-16 17:50:25 +00:00
Chris Lattner 2ba5ca9d4f Improve the diagnostic emitted when an unused ObjC property getter
is found.  Instead of complaining about a generic "unused expr",
emit:
t.m:7:3: warning: property access result unused - getters should not have side effects

While objc property getters *could* have side effects, according to
the language best practices, they *shouldn't*.  Hopefully the
diagnostic now gets this across.

llvm-svn: 79192
2009-08-16 16:57:27 +00:00
Anders Carlsson 250aada4b9 AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
llvm-svn: 79176
2009-08-16 05:13:48 +00:00
Anders Carlsson bc4c107836 Move builtin call checking out into a separate function, make CheckFunctionCall and CheckBlockCall return bool instead. No intended functionality change.
llvm-svn: 79157
2009-08-16 01:56:34 +00:00
Eli Friedman c96d4963eb Implement __is_empty. Patch by Sean Hunt.
llvm-svn: 79143
2009-08-15 21:55:26 +00:00
Eli Friedman e99c9c5b60 Ignore -Wno-import.
llvm-svn: 79128
2009-08-15 19:28:53 +00:00
Zhongxing Xu e1190f73a9 Extend the ProgramPoint to include the context information LocationContext,
which is either a stack frame context of the function or a local scope 
context.

llvm-svn: 79072
2009-08-15 03:17:38 +00:00
John McCall deb8448690 Disable all recognition of main() in -ffreestanding. Addresses bug #4720.
llvm-svn: 79070
2009-08-15 02:09:25 +00:00
Ted Kremenek 08479ae7fe Change handling of attribute 'malloc' to only accept the attribute on function
declarations (and not function pointers). This is consistent with GCC. Accepting
this attribute on function pointers means that the attribute should be treated
as a type qualifier, which apparently is not what GCC does. We obviously can
change this later should we desire to enhance the 'malloc' attribute in this
way.

llvm-svn: 79060
2009-08-15 00:51:46 +00:00
Anders Carlsson e827123f08 Make the CXXDefaultArgExpr constructor protected and add a static Create function.
llvm-svn: 79013
2009-08-14 18:30:22 +00:00
Mike Stump bcf756cbac Deconflate virtual base offsets from non-virtual base offsets.
Deconflate a virtual base primary from a non-virtual base.

llvm-svn: 78971
2009-08-14 01:44:03 +00:00
Fariborz Jahanian bbd5e8c2cf More toward synthesizing copy assignments. SWIP.
llvm-svn: 78861
2009-08-12 23:34:46 +00:00
Fariborz Jahanian de7d4c264a Patch for synthesizing copy assignment operator.
WIP.

llvm-svn: 78841
2009-08-12 21:14:35 +00:00
Nate Begeman 4874592208 Transition the PCH support for ShuffleVectorExpr over to ASTContext allocation
llvm-svn: 78783
2009-08-12 02:28:50 +00:00
Zhongxing Xu 0d375cdcb1 More cleanups.
llvm-svn: 78782
2009-08-12 02:28:32 +00:00
Zhongxing Xu ccffe0953e Remove redundant forward declarations.
llvm-svn: 78781
2009-08-12 02:23:28 +00:00
Nate Begeman f485fb55d8 Fix a fixme by allocating ShuffleVectorExprs in the Context
llvm-svn: 78780
2009-08-12 02:10:25 +00:00
Fariborz Jahanian 3f8917abf6 Patch to warn if a property which is 'assign' by default
may not implement NSCopying protocol in -fobjc-gc[-only] mode.

llvm-svn: 78726
2009-08-11 22:02:25 +00:00
John McCall 2658c4e2d9 Add a FriendClassDecl type for holding declarations of friend types in
the AST, and create such declarations.

llvm-svn: 78719
2009-08-11 21:13:21 +00:00
Fariborz Jahanian b2197042b8 ir-gen support for anonymous union data member
copying in copy constructors and used in
default constructor's initializer list.

llvm-svn: 78700
2009-08-11 18:49:54 +00:00
Benjamin Kramer 9cd050ab07 LLVMContext is a class now.
llvm-svn: 78691
2009-08-11 17:46:57 +00:00
John McCall d1e9d835f3 Argument-dependent lookup for friend declarations. Add a new decl type,
FriendFunctionDecl, and create instances as appropriate.

The design of FriendFunctionDecl is still somewhat up in the air;  you can
befriend arbitrary types of functions --- methods, constructors, etc. ---
and it's not clear that this representation captures that very well.
We'll have a better picture when we start consuming this data in access
control.

llvm-svn: 78653
2009-08-11 06:59:38 +00:00
Douglas Gregor a16548e301 Refactor the template-instantiation logic for expressions into a
generic tree transformation (also used for recanonicalization) and a
small amount of template-instantiation-specific logic.

llvm-svn: 78645
2009-08-11 05:31:07 +00:00
Nate Begeman 5ec4b318e3 Take 2 on AltiVec-style vector initializers.
Fixes PR4704 problems

Addresses Eli's patch feedback re: ugly cast code

Updates all postfix operators to remove ParenListExprs.  While this is awful,
no better solution (say, in the parser) is obvious to me.  Better solutions
welcome.

llvm-svn: 78621
2009-08-10 23:49:36 +00:00
Anders Carlsson ed1674d971 Add a CastInfo struct that will be used for cast information when constructing cast expressions. Right now it only stores the cast kind, but in the future it might store conversion functions and constructors.
llvm-svn: 78599
2009-08-10 21:30:22 +00:00
Chris Lattner 30ba674391 fix a couple of problems with section attributes:
1. Passing something that isn't a string used to cause:
   "argument to annotate attribute was not a string literal"
  make it say "section attribute" instead.

2. Fix the location of the above message to point to the
   bad argument instead of the section token.

3. Implement rdar://4341926, by diagnosing invalid section
   specifiers in the frontend rather than letting them slip all
   the way to the assembler (a QoI win).

An example of #3 is that we used to produce something like this:

/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Expected comma after segment-name
/var/folders/n7/n7Yno9ihEm894640nJdSQU+++TI/-Tmp-//ccFPFGtT.s:2:Rest of line ignored. 1st junk character valued 46 (.).

Daniel improved clang to use llvm_report_error, so now we got:

$ clang t.c -c
fatal error: error in backend: Global variable 'x' has an invalid section specifier 'sadf': mach-o section specifier
      requires a segment and section separated by a comma.

with no loc info.  Now we get:

$ clang t.c -fsyntax-only
t.c:4:30: error: argument to 'section' attribute is not valid for this target: mach-o section specifier requires a segment
      and section separated by a comma
int x __attribute__((section("sadf")));
                             ^

which is nice :)

llvm-svn: 78586
2009-08-10 19:03:04 +00:00
Mike Stump 68f0d31f25 Add walking bases in reverse order.
llvm-svn: 78578
2009-08-10 18:21:22 +00:00
Daniel Dunbar 71f22e738a Use LLVM's new error handler API to report back end errors using Diagnostic.
For example,
--
ddunbar@giles:Frontend$ clang -c backend-errors.c
fatal error: error in backend: Global variable 'a' has an invalid section specifier
      'I AM, not, legal': mach-o section specifier uses an unknown section type.
--
compare to:
--
ddunbar@giles:Frontend$ gcc -c backend-errors.c
/var/folders/DQ/DQ8GT3++HESEzT1obWBynE+++TI/-Tmp-//cc45w2pq.s:2:Expected comma after segment-name
/var/folders/DQ/DQ8GT3++HESEzT1obWBynE+++TI/-Tmp-//cc45w2pq.s:2:Rest of line ignored. 1st junk character valued 77 (M).
--

Yay!

I am not tied to my wording choice, we could also go with "uncoverable error"
for the prefix, or just leave it off entirely.

llvm-svn: 78554
2009-08-10 03:40:28 +00:00
Daniel Dunbar 481fe50903 Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D    test/Sema/altivec-init.c
U    include/clang/Basic/DiagnosticSemaKinds.td
U    include/clang/AST/Expr.h
U    include/clang/AST/StmtNodes.def
U    include/clang/Parse/Parser.h
U    include/clang/Parse/Action.h
U    tools/clang-cc/clang-cc.cpp
U    lib/Frontend/PrintParserCallbacks.cpp
U    lib/CodeGen/CGExprScalar.cpp
U    lib/Sema/SemaInit.cpp
U    lib/Sema/Sema.h
U    lib/Sema/SemaExpr.cpp
U    lib/Sema/SemaTemplateInstantiateExpr.cpp
U    lib/AST/StmtProfile.cpp
U    lib/AST/Expr.cpp
U    lib/AST/StmtPrinter.cpp
U    lib/Parse/ParseExpr.cpp
U    lib/Parse/ParseExprCXX.cpp

llvm-svn: 78551
2009-08-10 03:01:36 +00:00
Ryan Flynn e64ffc277c warn, as gcc does, if __attribute__((malloc)) applied to function returning non-pointer type
llvm-svn: 78542
2009-08-09 22:36:29 +00:00
Ryan Flynn 1f1fdc070e map previously ignored __attribute((malloc)) to noalias attribute of llvm function's return
llvm-svn: 78541
2009-08-09 20:07:29 +00:00
Nate Begeman a96114ed08 AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector
initializer syntax used by OpenCL, so that vector literals are compatible
with macro arguments.

llvm-svn: 78535
2009-08-09 17:55:44 +00:00
Ryan Flynn 2f08571e4d PR4700 - remove shift by 0 warning
llvm-svn: 78488
2009-08-08 19:18:23 +00:00
Anders Carlsson 68e0b68289 Introduce a new PragmaPack attribute, and use it for #pragma pack. The PackedAttr now only represents __attribute__((packed)).
This is necessary because #pragma pack and __attribute__((packed)) have different semantics. No functionality change yet, but this lays the groundwork for fixing a record layout bug.

llvm-svn: 78483
2009-08-08 18:23:56 +00:00
Edward O'Callaghan c69169d175 Patch should implement packed enums - PR4098. Credit to Anders Johnsen.
llvm-svn: 78471
2009-08-08 14:36:57 +00:00
Anders Carlsson c5c57c3b86 Get rid of Stmt::Clone now that we can reference count statements instead.
llvm-svn: 78452
2009-08-08 02:50:17 +00:00
Douglas Gregor 2c742024ff Introduce reference counting for statements and expressions, using it
to allow sharing of nodes. Simplifies some aspects of template
instantiation, and fixes both PR3444 and <rdar://problem/6757457>.

llvm-svn: 78450
2009-08-08 01:41:12 +00:00
Anders Carlsson 8fc489da2a Add a CK_ArrayToPointerDecay cast kind.
llvm-svn: 78434
2009-08-07 23:48:20 +00:00
Anders Carlsson ec143777ba Add CK_ToUnion and use it for aggregate expression codegen.
llvm-svn: 78429
2009-08-07 23:22:37 +00:00
John McCall c7e8e795fa Just add global scope to the associated namespaces set instead of tracking it
separately.  Add the framework (currently unfed) for finding friend declarations
during argument-dependent lookup.

llvm-svn: 78414
2009-08-07 22:18:02 +00:00
Mike Stump d9687fded6 Add rbegin and rend for virtual bases, might come in handy some day.
llvm-svn: 78412
2009-08-07 21:44:39 +00:00
Mike Stump c266c6d797 Add ability to generate vcall offsets for primary virtual base.
llvm-svn: 78396
2009-08-07 19:00:50 +00:00