Commit Graph

28411 Commits

Author SHA1 Message Date
Ken Dyck 4731d5b65a Convert Alignment member to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125641
2011-02-16 02:05:21 +00:00
Ted Kremenek 64699befcd Add trivial buffer overflow checking in Sema.
llvm-svn: 125640
2011-02-16 01:57:07 +00:00
Ken Dyck af1c83fbe7 Convert NonVirtualSize to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125639
2011-02-16 01:52:01 +00:00
Ken Dyck a2d3dda041 Convert NonVirtualAlignment to CharUnits. No change in functionality
intended.

llvm-svn: 125638
2011-02-16 01:43:15 +00:00
Argyrios Kyrtzidis 034d68e97d [analyzer] AnalyzerFrontend is dependent on AnalyzerCheckers.
llvm-svn: 125637
2011-02-16 01:40:55 +00:00
Argyrios Kyrtzidis 9d4d4f9104 [analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker
  CFNumberCreateChecker
  NSAutoreleasePoolChecker
  CFRetainReleaseChecker
  ClassReleaseChecker

llvm-svn: 125636
2011-02-16 01:40:52 +00:00
Douglas Gregor 042465709f When searching for visible declarations (e.g., for code completion),
be sure to look at all of the Objective-C class declarations within a
@class. Fixes <rdar://problem/8876207>.

llvm-svn: 125635
2011-02-16 01:39:26 +00:00
Devang Patel 25468059e5 Simplify test to check an aggregate argument that has non trivial constructor or destructor.
This patch rewrites r125142.

llvm-svn: 125632
2011-02-16 01:11:51 +00:00
Douglas Gregor b5f1e46d30 When trying to provide a code completion item for a call to "super" in
Objective-C, also look in the categories and class extensions of our
superclasses. Fixes <rdar://problem/8853540>.

llvm-svn: 125628
2011-02-16 00:51:18 +00:00
John McCall bf9a86b50f Don't call objc_read_weak as part of emitting a block literal.
Nobody ever gave me a clear reason for why we were doing this, and
now it's apparently causing serious problems, so if *not* having this
causes problems, we get to solve them the right way this time.

llvm-svn: 125627
2011-02-16 00:49:34 +00:00
Fariborz Jahanian 6fd9435f6d Check for deprecated implementation unconditionally.
Warning and its note will be ignored in default case.

llvm-svn: 125621
2011-02-16 00:30:31 +00:00
Fariborz Jahanian 0c87d36d9d Fix typo (per Chris's comment).
llvm-svn: 125619
2011-02-16 00:14:11 +00:00
Argyrios Kyrtzidis c541ade850 Warn for missing terminating " or ' instead of error for gcc compatibility. Fixed rdar://8914293.
llvm-svn: 125616
2011-02-15 23:45:31 +00:00
Devang Patel 49e3348e56 Only c++ class arguments with non trivial constructor or destructor needs a reference.
C struct arguments do not need this adjustment.
This fixes 7 failures in callfuncs.exp from gdb testsuite.

llvm-svn: 125615
2011-02-15 23:36:28 +00:00
Argyrios Kyrtzidis a9215281de [analyzer] Use the new registration mechanism on some of the experimental internal checkers:
CastToStructChecker
  FixedAddressChecker
  PointerArithChecker
  PointerSubChecker

llvm-svn: 125612
2011-02-15 22:55:20 +00:00
Argyrios Kyrtzidis b2400924d9 [analyzer] Use the new registration mechanism on the IdempotentOperationChecker.
llvm-svn: 125611
2011-02-15 22:55:14 +00:00
John McCall 9743e8d84e Handle delayed access in local declarations. PR9229.
llvm-svn: 125609
2011-02-15 22:51:53 +00:00
Douglas Gregor 24bbc46208 Teach code completion to cope with block types written without a
prototype, e.g., ^() rather than ^(void). Fixes
<rdar://problem/8875712>.

llvm-svn: 125608
2011-02-15 22:37:09 +00:00
Rafael Espindola d62acb569c Add a hack to avoid adding '\01' to asm names when possible. It would be
better for clang to always compute the right name, but for now this hack
fixes PR9177 and lets us build firefox with LTO :-)

llvm-svn: 125607
2011-02-15 22:23:51 +00:00
John McCall 4d9f14234f Refactor CGRecordLayoutBuilder to use CharUnits more consistently.
llvm-svn: 125605
2011-02-15 22:21:29 +00:00
Douglas Gregor f34a6f0fef Implement a special code-completion pattern for "IBAction". Fixes
<rdar://problem/8767704>.

llvm-svn: 125604
2011-02-15 22:19:42 +00:00
Rafael Espindola 41febc658b Fix the distro name.
llvm-svn: 125601
2011-02-15 21:44:06 +00:00
Zhanyong Wan bc402abcc9 Moves FileManagerTest.cpp to unittests/Basic such that the unit test
directory structure matches the library structure.  Reviewed by jyasskin.

llvm-svn: 125600
2011-02-15 21:30:27 +00:00
Argyrios Kyrtzidis f81ff04ba3 [analyzer] Remove ObjCSelfInitCheck from AnalyzerOptions.
llvm-svn: 125599
2011-02-15 21:25:07 +00:00
Argyrios Kyrtzidis 2d3905ffac [analyzer] Use the new registration mechanism on some of the experimental checks. These are:
CStringChecker
   ChrootChecker
   MallocChecker
   PthreadLockChecker
   StreamChecker
   UnreachableCodeChecker

MallocChecker creates implicit dependencies between checkers and needs to be handled differently.

llvm-svn: 125598
2011-02-15 21:25:03 +00:00
Rafael Espindola 65941e50ef Fix include paths on 32 bit ubuntu 10.10.
Original patch by Jonas Bülow.

llvm-svn: 125597
2011-02-15 21:16:43 +00:00
Douglas Gregor 8003924d10 When code-completing within a list of declaration specifiers,
separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.

llvm-svn: 125594
2011-02-15 20:33:25 +00:00
Peter Collingbourne e91b2dbdf1 OpenCL: standardise naming of test cases
llvm-svn: 125590
2011-02-15 19:46:41 +00:00
Peter Collingbourne 5df20e02af Serialization/deserialization support for floating point #pragma
options, enabled OpenCL extensions and default FP_CONTRACT setting.

llvm-svn: 125589
2011-02-15 19:46:30 +00:00
Peter Collingbourne e87167b7d8 OpenCL: semantic analysis support for cl_khr_fp64 extension
llvm-svn: 125588
2011-02-15 19:46:23 +00:00
Douglas Gregor d39ae3eec8 When we encounter an Objective-C class name in an expression, followed
by the code completion token, treat this as a class message send where
the opening square bracket is missing. Fixes <rdar://problem/6970911>.

llvm-svn: 125587
2011-02-15 19:17:31 +00:00
Fariborz Jahanian 09948f1af6 In -fapple-kext mode, global object construction code
ends up in the text segment. // rdar://8825235.

llvm-svn: 125585
2011-02-15 18:54:46 +00:00
Douglas Gregor e061015de8 Emit in-class member function definitions that are marked
"used". Fixes <rdar://problem/8684363>.

llvm-svn: 125579
2011-02-15 18:11:42 +00:00
Argyrios Kyrtzidis 10b2368e9f Allow resolving headers from a PCH even after headers+PCH were moved to another path.
Store in PCH the directory that the PCH was originally created in.
If a header file is not found at the path that we expect it to be and the PCH file
was moved from its original location, try to resolve the file by assuming that
header+PCH were moved together and the header is in the same place relative to the PCH.

llvm-svn: 125576
2011-02-15 17:54:22 +00:00
Fariborz Jahanian d724a109cf Refactoring of code to issue warning on implemented
deprecated class and methods in objective-c.

llvm-svn: 125573
2011-02-15 17:49:58 +00:00
Douglas Gregor 9892e3545a Add missing CMake dependency
llvm-svn: 125566
2011-02-15 17:09:56 +00:00
Argyrios Kyrtzidis 6fa0d20a6f Fix the clang-wpa example.
llvm-svn: 125565
2011-02-15 16:54:12 +00:00
Argyrios Kyrtzidis f2ec88ea54 Initialize InlineCall in AnalyzerOptions.
llvm-svn: 125564
2011-02-15 16:54:07 +00:00
John McCall e3dc1707b5 Assorted cleanup:
- Have CGM precompute a number of commonly-used types
  - Have CGF copy that during initialization instead of recomputing them
  - Use TBAA info when initializing a parameter variable
  - Refactor the scalar ++/-- code

llvm-svn: 125562
2011-02-15 09:22:45 +00:00
Jeffrey Yasskin cd3858b103 Add CMake support to the clang unittests.
llvm-svn: 125561
2011-02-15 07:54:28 +00:00
Argyrios Kyrtzidis 4e52527c28 [analyzer] Reflect changes for tablegen'ing the checkers.
-Update tablegen files for checkers, use the tablegen class name for the checker class name.
-Update ClangSACheckersProvider to not look into hidden checker packages.

llvm-svn: 125560
2011-02-15 07:42:38 +00:00
Argyrios Kyrtzidis a6d04d541d [analyzer] Use the new registration mechanism on some of the internal checks. These are:
StackAddrLeakChecker
ObjCAtSyncChecker
UnixAPIChecker
MacOSXAPIChecker

The rest have/create implicit dependencies between checkers and need to be handled differently.

llvm-svn: 125559
2011-02-15 07:42:33 +00:00
John McCall 25849cab8b Return a declaration to the parser when creating a field in C++ so that
the parser will complete the declarator with a valid decl and thus trigger
delayed diagnostics for it.  It certainly looks like we were intentionally
returning null here, but I couldn't find any good reason for it, and there
wasn't a comment, so farewell to all that.

llvm-svn: 125556
2011-02-15 07:12:36 +00:00
John McCall 0217dfc2ba Perform zero-initialization of virtual base classes when emitting
a zero constant for a complete class.  rdar://problem/8424975

To make this happen, track the field indexes for virtual bases
in the complete object.  I'm curious whether we might be better
off making CGRecordLayoutBuilder *much* more reliant on
ASTRecordLayout;  we're currently duplicating an awful lot of the ABI
layout logic.

llvm-svn: 125555
2011-02-15 06:40:56 +00:00
Ted Kremenek c7bfdcd4f5 Fix memory leak in CFGBuilder resulting from tracking scope information using SmallVectors.
llvm-svn: 125550
2011-02-15 02:47:45 +00:00
Ken Dyck 7ad11e70b6 Convert RecordLayout::Alignment to CharUnits from bit units. No change in
functionality intended. 

llvm-svn: 125549
2011-02-15 02:32:40 +00:00
Ted Kremenek 4ea9004fe8 IdempotentOperationChecker: don't repeatedly recompute block reachability.
llvm-svn: 125548
2011-02-15 02:20:03 +00:00
Fariborz Jahanian d33ab8c635 Warn if method for a deprecated method is implemented.
Warn if class for a deprecated class is implemented.
Warn if category for a deprecated class is implemented.
All under control of -Wdeprecated-implementations.
// rdar://8973810.

llvm-svn: 125545
2011-02-15 00:59:30 +00:00
Chris Lattner 91c08ad14a update for ConstantVector API change.
llvm-svn: 125538
2011-02-15 00:14:06 +00:00
Ted Kremenek 05e63e0e37 Put "incomplete implementation" warning under a flag.
llvm-svn: 125535
2011-02-14 23:59:16 +00:00
John McCall fe9cf0abb7 Don't crash on hierarchy static_casts which appear in variable initializers.
PR9221.

llvm-svn: 125532
2011-02-14 23:21:33 +00:00
John McCall 2957e3ef49 Change the context correctly when instantiating a static data member definition.
llvm-svn: 125517
2011-02-14 20:37:25 +00:00
Oscar Fuentes c9987fbbfe Add current binary and source directories to the header search list
for all compiler invocations.

llvm-svn: 125514
2011-02-14 20:14:11 +00:00
Argyrios Kyrtzidis 2f9a5a46a5 Anger the CMake gods by updating 'clang.xcodeproj'.
llvm-svn: 125512
2011-02-14 20:09:57 +00:00
Argyrios Kyrtzidis f0619868ae Remove left-over #include.
llvm-svn: 125507
2011-02-14 19:02:35 +00:00
John McCall 909acf8209 Provide overload diagnostics when explicit casts involving class types fail.
PR8626.

llvm-svn: 125506
2011-02-14 18:34:10 +00:00
Chris Lattner dd68bd0a65 revert my ConstantVector patch, it seems to have made the llvm-gcc
builders unhappy.

llvm-svn: 125505
2011-02-14 18:16:09 +00:00
Argyrios Kyrtzidis 556c45e9c5 [analyzer] Overhauling of the checker registration mechanism.
-Checkers will be defined in the tablegen file 'Checkers.td'.
-Apart from checkers, we can define checker "packages" that will contain a collection of checkers.
-Checkers can be enabled with -analyzer-checker=<name> and disabled with -analyzer-disable-checker=<name> e.g:
	Enable checkers from 'cocoa' and 'corefoundation' packages except the self-initialization checker:
	-analyzer-checker=cocoa -analyzer-checker=corefoundation -analyzer-disable-checker=cocoa.SelfInit
-Introduces CheckerManager and CheckerProvider. CheckerProviders get the set of checker names to enable/disable and
 register them with the CheckerManager which will be the entry point for all checker-related functionality.

Currently only the self-initialization checker takes advantage of the new mechanism.

llvm-svn: 125503
2011-02-14 18:13:31 +00:00
Argyrios Kyrtzidis 4ec3cf9937 [analyzer] Remove ManagerRegistry which is not used. In the future we may load analyzer plugins dynamically but
registration through static constructors should be avoided.

llvm-svn: 125502
2011-02-14 18:13:17 +00:00
Argyrios Kyrtzidis 2ef5f3c1c5 [analyzer] Move include/clang/StaticAnalyzer/AnalysisConsumer.h -> lib/StaticAnalyzer/Frontend/AnalysisConsumer.h since
FrontendActions.cpp is the only user.

llvm-svn: 125501
2011-02-14 18:13:11 +00:00
Argyrios Kyrtzidis ae92c95d34 [analyzer] Move Checkers/FrontendActions.cpp -> Frontend/FrontendActions.cpp
llvm-svn: 125500
2011-02-14 18:13:06 +00:00
Argyrios Kyrtzidis ecd3334dac [analyzer] Introduce libclangStaticAnalyzerFrontend and move Checkers/AnalysisConsumer.cpp into Frontend lib.
llvm-svn: 125499
2011-02-14 18:13:01 +00:00
Ted Kremenek 3374e03344 Remove dead code in IdempotentOperationChecker.
llvm-svn: 125497
2011-02-14 18:05:07 +00:00
Ted Kremenek 5794ef6950 Fix edge case where we don't cull warnings in IdempotentOperationsChecker due to incomplete analysis of loops.
llvm-svn: 125495
2011-02-14 17:59:23 +00:00
Ted Kremenek a71d5d31a1 Use 'BitVector' instead of SmallPtrSet<CFGBlock*> in IdempotentOperationsChecker. No real functionality change.
llvm-svn: 125494
2011-02-14 17:59:20 +00:00
Jeffrey Yasskin 9170c73d26 Add support for the builtins used in gcc 4.4's <cmath> and <complex>
headers in C++0x mode.  Fixes PR9138.

Patch by John Bytheway!

llvm-svn: 125492
2011-02-14 17:02:48 +00:00
Ted Kremenek 9909df3b3a Handle 'UsingDirective' in CFGRecStmtDeclVisitor.
llvm-svn: 125491
2011-02-14 17:00:16 +00:00
Chris Lattner 2d9a7672db update for ConstantVector::get API change.
llvm-svn: 125488
2011-02-14 07:55:40 +00:00
John McCall c146582e60 When parsing an out-of-line member function declaration, we must delay
access-control diagnostics which arise from the portion of the declarator
following the scope specifier, just in case access is granted by
friending the individual method.  This can also happen with in-line
member function declarations of class templates due to templated-scope
friend declarations.

We were really playing fast-and-loose before with this sort of thing,
and it turned out to work because *most* friend functions are in file
scope.  Making us delay regardless of context exposed several bugs with
how we were manipulating delay.  I ended up needing a concept of a
context that's independent of the declarations in which it appears,
and then I actually had to make some things save contexts correctly,
but delay should be much cleaner now.

I also encapsulated all the delayed-diagnostics machinery in a single
subobject of Sema;  this is a pattern we might want to consider rolling
out to other components of Sema.

llvm-svn: 125485
2011-02-14 07:13:47 +00:00
Chris Lattner 18703d41f0 fix two broken links and some out of date writing, PR9174
llvm-svn: 125484
2011-02-14 06:42:50 +00:00
Peter Collingbourne cb26ef94d4 Add missing file
llvm-svn: 125478
2011-02-14 02:14:26 +00:00
Peter Collingbourne 7ce13fc940 OpenCL: add support for __kernel, kernel keywords and EXTENSION,
FP_CONTRACT pragmas.  Patch originally by ARM.

llvm-svn: 125475
2011-02-14 01:42:53 +00:00
Peter Collingbourne 564c0fa47a Move support for "#pragma STDC FP_CONTRACT" to Parser; add Sema actions
llvm-svn: 125474
2011-02-14 01:42:35 +00:00
Peter Collingbourne 3bffa52933 Make LexOnOffSwitch a Preprocessor member function
llvm-svn: 125473
2011-02-14 01:42:24 +00:00
Fariborz Jahanian 12834e19c1 Use hasSameType in one more, hopefully, last place.
llvm-svn: 125468
2011-02-13 20:11:42 +00:00
Fariborz Jahanian 4de45dc6a7 Some refactoring and using more modern APIs for
implementation of co/contra-variance objc++
block pointers. // rdar://8979379.

llvm-svn: 125467
2011-02-13 20:01:48 +00:00
John McCall 8322c3a197 Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead
of the individual iterator accessors.

llvm-svn: 125450
2011-02-13 04:07:26 +00:00
John McCall 2b3c5538fa Look through array types when deciding whether a field requires non-trivial
destruction in the destructor-aliases logic.  Fixes PR 9197.

llvm-svn: 125447
2011-02-13 00:46:43 +00:00
Fariborz Jahanian 42455ea935 Implement objective-c++'s block pointer type matching involving
types which are contravariance in argument types and covariance
in return types. // rdar://8979379.

llvm-svn: 125445
2011-02-12 19:07:46 +00:00
Ted Kremenek c059798756 Teach the IdempotentOperations checker to ignore property setters.
llvm-svn: 125443
2011-02-12 18:50:03 +00:00
Argyrios Kyrtzidis 9fdd25492c When reading the AST, delay loading of the redeclaration chain to avoid deeply nested calls.
Temporarily set the first (canonical) declaration as the previous one, which is the one that
matters, and mark the real previous DeclID to be loaded & attached later on.

Fixes rdar://8956193.

llvm-svn: 125434
2011-02-12 07:50:47 +00:00
Ted Kremenek ba6ead4bc0 Update static analyzer build to checker-255.
llvm-svn: 125432
2011-02-12 03:20:34 +00:00
Ted Kremenek 70aeefa17e Weaken the ObjCSelfInitChecker to only warn when one calls an 'init' method within an 'init' method. This is a temporary stop gap to avoid false positives while we investigate how to make it smarter.
llvm-svn: 125427
2011-02-12 03:03:54 +00:00
Ted Kremenek 395f1ac038 Add test case for <rdar://problem/6888289>.
llvm-svn: 125424
2011-02-12 01:25:04 +00:00
Ted Kremenek 10b5926e29 static analyzer: Also invalidate instance variables of a receiver in a message expression, just as we do with parameters.
Fixes <rdar://problem/8725041>.

llvm-svn: 125422
2011-02-12 01:01:31 +00:00
Ted Kremenek b1c392aa56 Don't emit a dead store for '++' operations unless it occurs with a return statement. We've never seen any other cases that were real bugs.
Fixes <rdar://problem/6962292>.

llvm-svn: 125419
2011-02-12 00:17:19 +00:00
Jeffrey Yasskin c498878e6d Add CMake dependencies so that LLVM_USED_LIBS order doesn't matter.
I also sorted the tools/driver dependencies since their order no
longer matters.

llvm-svn: 125417
2011-02-11 23:46:38 +00:00
Ted Kremenek 9865d7f0e6 Don't report dead stores on unreachable code paths. Fixes <rdar://problem/8405222>.
llvm-svn: 125415
2011-02-11 23:24:26 +00:00
Zhanyong Wan f3c0ff730b Uses llvm::sys::path instead of hand-rolled algorithm in FileManager.
Reviewed by dgregor.

llvm-svn: 125407
2011-02-11 21:25:35 +00:00
Ted Kremenek 6cc8f5d83c Add test case for PR 8646.
llvm-svn: 125401
2011-02-11 20:13:27 +00:00
Peter Collingbourne de32b20bdd Reject forbidden storage class specifiers in OpenCL. Patch by George Russell!
llvm-svn: 125399
2011-02-11 19:59:54 +00:00
Ted Kremenek 7b3f290d61 Remove RegionStoreManager::evalBinOp(), which is now handled by the SValBuilder.
llvm-svn: 125396
2011-02-11 19:48:19 +00:00
Ted Kremenek eddeba0dae Rename 'InvalidateRegions()' to 'invalidateRegions()'.
llvm-svn: 125395
2011-02-11 19:48:15 +00:00
Douglas Gregor 46c50012ca Rename the operation that loads a preprocessed entity from a given offset to indicate that we're loading from an offset, not an index, lest one be confused. No functionality change.
llvm-svn: 125394
2011-02-11 19:46:30 +00:00
Fariborz Jahanian 178259710a Fix a block sema bug where result type of initializer
is unqualified but its initialized is qualified.
This is for c only and fixes the imm. problem.
c++ is more involved and is wip.
// rdar://8979379

llvm-svn: 125386
2011-02-11 18:46:17 +00:00
Zhanyong Wan e1dd3e2c31 Improves Clang's virtual file handling.
This patch contains:

- making some of the existing comments more accurate in the presence
of virtual files/directories.

- renaming some private data members of FileManager to match their roles better.

- creating 'DirectorEntry's for the parent directories of virtual
files, such that we can tell whether two virtual files are from the
same directory.  This is useful for injecting virtual files whose
directories don't exist in the real file system.

- minor clean-ups and adding comments for class
FileManager::UniqueDirContainer and FileManager::UniqueFileContainer.

- adding statistics on virtual files to FileManager::PrintStats().

- adding unit tests to verify the existing and new behavior of FileManager.

llvm-svn: 125384
2011-02-11 18:44:49 +00:00
Douglas Gregor 6a5be93b81 Don't compare llvm::Optional<> objects directly; compare their
contents when it's safe. I just *love* C++ some days.

llvm-svn: 125378
2011-02-11 18:08:15 +00:00
NAKAMURA Takumi fc217469c2 InitHeaderSearch.cpp: [PR8298] Don't touch drive G: on Windows hosts!
llvm-svn: 125364
2011-02-11 05:25:56 +00:00
Ted Kremenek 5662dfefad Allow the 'Eng' entry in GRStateManager to be a (possibly null) pointer instead of a reference.
llvm-svn: 125362
2011-02-11 04:20:16 +00:00
Rafael Espindola 3968cd0f7b For consistency, use llvm::raw_ostream in the rest of the mangle api.
llvm-svn: 125360
2011-02-11 02:52:17 +00:00