Commit Graph

28648 Commits

Author SHA1 Message Date
Peter Collingbourne 14a552b2d7 Move CompilerInstance::LLVMContext and LLVMContext ownership to CodeGenAction
This removes the final dependency edge from any lib outside of CodeGen
to core.  As a result we can, and do, trim the dependency on core
from libclang, PrintFunctionNames, the unit tests and c-index-test.
While at it, review and trim other unneeded dependencies.

llvm-svn: 125820
2011-02-18 02:25:12 +00:00
Peter Collingbourne 3ae6caaf1b Move TargetInfo::adjustInlineAsmType to TargetCodeGenInfo
llvm-svn: 125819
2011-02-18 02:24:56 +00:00
Douglas Gregor 9543c40df1 When we're creating an expression for an integral template argument of
enumeration type, we were generating an integer literal implicitly
casted to the appropriate enumeration type. However, later checks on
that expression would strip the implicit cast.

This commit tweaks the lame hack, by creating an explicit cast instead
of an implicit cast. The right answer is to introduce a 
SubstNonTypeTemplateParmExpr expression that acts like the substituted
result. I'll investigate that soon.

llvm-svn: 125818
2011-02-18 02:12:44 +00:00
Chris Lattner 43e7f31f11 implement basic support for __label__. I wouldn't be shocked if there are
bugs from other clients that don't expect to see a LabelDecl in a DeclStmt,
but if so they should be easy to fix.

This implements most of PR3429 and rdar://8287027

llvm-svn: 125817
2011-02-18 02:08:43 +00:00
Chris Lattner 4ba77fa976 rename test
llvm-svn: 125816
2011-02-18 02:05:32 +00:00
Argyrios Kyrtzidis 951e22e2c9 Handle UsingDecl in CFGRecStmtDeclVisitor.
llvm-svn: 125814
2011-02-18 01:44:17 +00:00
Chris Lattner ebb5c6c717 Switch labels over to using normal name lookup, instead of their
own weird little DenseMap.  Hey look, we now emit unused label
warnings deterministically, amazing.

llvm-svn: 125813
2011-02-18 01:27:55 +00:00
Francois Pichet f9e7f09c84 Unbreak the MSVC build
std::make_pair is unreliable under MSVC 2010.

Ref: http://stackoverflow.com/questions/2691680/why-does-visual-studio-2010-throw-this-error-with-boost-1-42-0
llvm-svn: 125811
2011-02-18 01:25:16 +00:00
Chris Lattner 0f79084117 break testcase over multiple lines to make it easier to read.
llvm-svn: 125810
2011-02-18 01:25:14 +00:00
Chris Lattner d12b480e29 handle labeldecls.
llvm-svn: 125806
2011-02-18 00:52:55 +00:00
Chris Lattner 60f844916c make block bodies handle undefined labels just like functions.
llvm-svn: 125799
2011-02-17 23:58:47 +00:00
Chris Lattner fb59c7c7d8 improve support for big endian targets, fixing PR8171, patch
by Heikki Kultala!

llvm-svn: 125784
2011-02-17 22:09:58 +00:00
Oscar Fuentes 79b52bfc46 CMake: updated source file list.
llvm-svn: 125783
2011-02-17 22:07:39 +00:00
Ted Kremenek 48d9626055 Add -Warray-bounds test showing how the warning currently interoperates with macros.
llvm-svn: 125781
2011-02-17 21:40:51 +00:00
Argyrios Kyrtzidis 57d736fd46 [analyzer] Use the new registration mechanism for the debugging info "checks".
The relative checker package is 'debug':

'-dump-live-variables' is replaced by '-analyzer-checker=debug.DumpLiveVars'
'-cfg-view' is replaced by '-analyzer-checker=debug.ViewCFG'
'-cfg-dump' is replaced by '-analyzer-checker=debug.DumpCFG'

llvm-svn: 125780
2011-02-17 21:39:39 +00:00
Argyrios Kyrtzidis af45aca670 [analyzer] Use the new registration mechanism on the non-path-sensitive-checkers:
DeadStoresChecker
  ObjCMethSigsChecker
  ObjCUnusedIvarsChecker
  SizeofPointerChecker
  ObjCDeallocChecker
  SecuritySyntaxChecker

llvm-svn: 125779
2011-02-17 21:39:33 +00:00
Argyrios Kyrtzidis 24ffc08f39 [analyzer]
-Introduce CheckerV2, a set of templates for convenient declaration & registration of checkers.
 Currently useful just for checkers working on the AST not the path-sensitive ones.
-Enhance CheckerManager to actually collect the checkers and turn it into the entry point for
 running the checkers.
-Use the new mechanism for the LLVMConventionsChecker.

llvm-svn: 125778
2011-02-17 21:39:24 +00:00
Argyrios Kyrtzidis 507ff53e39 [analyzer] Pass CheckerManager to the registration functions.
llvm-svn: 125777
2011-02-17 21:39:17 +00:00
Chandler Carruth 1af88f12a3 Enhance the array bounds checking to work for several other constructs,
especially C++ code, and generally expand the test coverage.

Logic adapted from a patch by Kaelyn Uhrain <rikka@google.com> and
another Googler.

llvm-svn: 125775
2011-02-17 21:10:52 +00:00
Chandler Carruth 2a666fc2c7 Clean up the style of this function to match the conventions in the rest
of Clang, and reflows the code a bit to make it easier to read.

llvm-svn: 125773
2011-02-17 20:55:08 +00:00
Chris Lattner d28cc8113b add a fixme
llvm-svn: 125772
2011-02-17 20:54:00 +00:00
Chris Lattner cab02a60d2 Step #2/N of __label__ support: keep pushing LabelDecl forward,
making them be template instantiated in a more normal way and 
make them handle attributes like other decls.

This fixes the used/unused label handling stuff, making it use
the same infrastructure as other decls.

llvm-svn: 125771
2011-02-17 20:34:02 +00:00
Chris Lattner 50c3c1316a Inline LocalInstantiationScope::getInstantiationOf into its one
client, making room for future hacking.

llvm-svn: 125770
2011-02-17 19:47:42 +00:00
Chris Lattner 15a776fff7 remove some defensive code: LocalInstantiationScope::getInstantiationOf
and findInstantiationOf can never return null, even on invalid code.

llvm-svn: 125769
2011-02-17 19:38:27 +00:00
Chris Lattner bdc1a42aef remove some dead overloads.
llvm-svn: 125768
2011-02-17 19:37:28 +00:00
Douglas Gregor d6f8124c9c Eliminate the internal command-line option for viewing inheritance in C++ classes, since it's only really worked for the trivial cases anyway due to lame pseudo-parsing of the class name. The viewInheritance() function is still available for use in the debugger, where this is far more useful
llvm-svn: 125762
2011-02-17 19:04:40 +00:00
John McCall e6be5e1c0d Remove the "conditional save" hashtables from IR generation.
llvm-svn: 125761
2011-02-17 19:02:56 +00:00
Douglas Gregor 428d75ffd9 The internal -fdump-record-layouts flag already dumps the layout when it was computed; no need to do so again at the end of the translation unit
llvm-svn: 125760
2011-02-17 18:59:06 +00:00
Argyrios Kyrtzidis 9d5235d527 When building StaticAnalyzer/Frontend add -I "<Checkers build dir>" to allow Checkers.inc to be
included without '..', thus being compatible with build systems of *BSDs.

Patch by Joerg Sonnenberger!

llvm-svn: 125758
2011-02-17 18:40:33 +00:00
Douglas Gregor 65f57fe6ea Replace a FIXME with a comment describing why we did what we did
llvm-svn: 125757
2011-02-17 18:32:37 +00:00
Douglas Gregor e5de7013c7 Remove the last virtual member function from the Decl hierarchy,
reducing the size of all declarations by one pointer. For a 64-bit
Clang parsing Cocoa.h, this saves ~630k of memory (about 3.5% of
ASTContext's memory usage for this header).

llvm-svn: 125756
2011-02-17 18:14:32 +00:00
Douglas Gregor b494173c93 Devirtualize TagDecl::completeDefinition().
llvm-svn: 125755
2011-02-17 18:06:05 +00:00
Douglas Gregor fe590dfa84 Devirtualize DeclaratorDecl::getInnerLocStart() and TagDecl::getInnerLocStart().
llvm-svn: 125754
2011-02-17 17:39:40 +00:00
Fariborz Jahanian 5fc74804a6 Improve diagnostics on missing property decl.
llvm-svn: 125752
2011-02-17 17:30:05 +00:00
Douglas Gregor a991f3a4e9 Devirtualize NamedDecl::getNameForDiagnostic().
llvm-svn: 125751
2011-02-17 17:23:19 +00:00
Douglas Gregor 0215459c37 Devirtualize RedeclarableTemplateDecl::newCommon().
llvm-svn: 125750
2011-02-17 17:10:20 +00:00
Chandler Carruth 22c7a79a1d Implement a sub-group of -Wconversion: -Wliteral-conversion. This
specifically targets literals which are implicitly converted, a those
are more often unintended and trivial to fix. This can be especially
helpful for diagnosing what makes 'const int x = 1e6' not an ICE.

Original patch authored by Jim Meehan with contributions from other
Googlers and a few cleanups from myself.

llvm-svn: 125745
2011-02-17 11:05:49 +00:00
John McCall c07a0c7e48 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
NAKAMURA Takumi 49ddc3646f lib/Frontend/InitHeaderSearch.cpp: Add mingw-w64's include paths.
llvm-svn: 125743
2011-02-17 08:51:47 +00:00
NAKAMURA Takumi 31ea2f14bc Triple::MinGW64 is deprecated and removed. We can use Triple::MinGW32 instead.
No one uses *-mingw64. mingw-w64 is represented as {i686|x86_64}-w64-mingw32.

llvm-svn: 125742
2011-02-17 08:51:38 +00:00
NAKAMURA Takumi 029d74b264 Fix whitespace.
llvm-svn: 125741
2011-02-17 08:50:50 +00:00
Douglas Gregor 133edddd82 Devirtualize Decl::getNextRedeclaration().
llvm-svn: 125740
2011-02-17 08:47:29 +00:00
Chandler Carruth 712563bba4 Implement -Wenum-compare, which warns when comparing two enums of
different types. We omit the warning when the enum types are anonymous.
Unlike GCC, this warning does not distinguish between C++ and C/ObjC for
controling whether it is on by default, it is always on by default.

Original patch contributed by Richard Trieu (@ Google), I fixed some
style issues, and cleaned it up for submission.

llvm-svn: 125739
2011-02-17 08:37:06 +00:00
Douglas Gregor 5ee06f02f9 Simple little optimization to Decl::getCanonicalDecl(), eliminating some heavyweight machinery and indirection that we don't need
llvm-svn: 125737
2011-02-17 08:14:56 +00:00
Douglas Gregor 00716e8bd3 Devirtualize Decl::getSourceRange()
llvm-svn: 125736
2011-02-17 08:12:32 +00:00
Douglas Gregor 7edc20ac24 Devirtualize Decl::getCanonicalDecl().
llvm-svn: 125735
2011-02-17 07:58:36 +00:00
Chris Lattner c8e630e4db Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Douglas Gregor f7b2c93b2f Devirtualize Decl::getBody() and Decl::hasBody().
llvm-svn: 125731
2011-02-17 07:13:24 +00:00
Douglas Gregor a43942a48e De-virtualize Decl::isOutOfLine().
llvm-svn: 125730
2011-02-17 07:02:32 +00:00
Douglas Gregor b0f2ea9e9e When printing a qualified type, look through a substituted template
parameter type to see what's behind it, so that we don't end up
printing silly things like "float const *" when "const float *" would
make more sense. Also, replace the pile of "isa" tests with a simple
switch enumerating all of the cases, making a few more obvious cases
use prefix qualifiers.

llvm-svn: 125729
2011-02-17 06:52:25 +00:00
Chris Lattner 5a9b1ec94c simplify a bit.
llvm-svn: 125724
2011-02-17 05:38:27 +00:00
Chris Lattner e281e99f76 tidy up
llvm-svn: 125723
2011-02-17 05:19:40 +00:00
Douglas Gregor 230a7e60b1 Improve parser recovery in "for" statements, from Richard Smith!
llvm-svn: 125722
2011-02-17 03:38:46 +00:00
Douglas Gregor 0e5d72f164 I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.
I will not hold on to temporary StringRefs.

llvm-svn: 125718
2011-02-17 03:19:26 +00:00
Douglas Gregor 9c1f1bfedc When Parser::ParseExpressionList isn't given a completer, fall back to
normal "expression" completion. Fixes the most annoying
code-completion bug I've found.

llvm-svn: 125715
2011-02-17 03:09:23 +00:00
Matt Beaumont-Gay 956fc1cb81 Fix PR9025 and add a diagnostic (and sometimes a fixit) for an overloaded
function name used as the base of a member expression. Early feedback from
Chandler Carruth, and code review from Nick Lewycky.

llvm-svn: 125714
2011-02-17 02:54:17 +00:00
Ted Kremenek 06e2474d51 Bump up IdentifierInfo::ObjCOrBuiltinID to use 11 bits instead of 10. Fixes PR 9231.
Apparently we can blow out the number of builtin IDs on FreeBSD with only 10 bits.

llvm-svn: 125713
2011-02-17 02:43:00 +00:00
Ted Kremenek 42ec914ff8 Begin overhaul of scan-build/ccc-analyzer's handling of checker options.
We now rely on 'clang --analyze' to provide the default set of checkers.  We're
still working on the new '-analyzer-checker <checker>' interface, and once
that's ready we'll wire it up to scan-build.

llvm-svn: 125712
2011-02-17 02:28:30 +00:00
Ted Kremenek 378313944f Disable default synthesized properties until we can properly re-evaluate the feature.
llvm-svn: 125708
2011-02-17 02:17:56 +00:00
Chris Lattner 5df2a4e8df fix clang -MM output to escape spaces in filenames. This seems to be
the only character that GCC escapes.  PR9224.

llvm-svn: 125707
2011-02-17 02:14:49 +00:00
Chris Lattner ffda452fbf update this test now that reassociate isn't stripping nsw's pointlessly.
llvm-svn: 125705
2011-02-17 02:02:42 +00:00
Ken Dyck 02ced6fd19 Convert MaxFieldAlignment to CharUnits from bits. No change in functionality
intended.

llvm-svn: 125704
2011-02-17 01:49:42 +00:00
Fariborz Jahanian 05d389f407 Improve diagnostics when property names an object type of
a forward class. // rdar://8851803

llvm-svn: 125699
2011-02-17 01:26:14 +00:00
Douglas Gregor 669a25aec3 Implement code completion results for the Objective-C Key-Value Coding
(KVC) and Key-Value Observing (KVO) protocols.

llvm-svn: 125696
2011-02-17 00:22:45 +00:00
Nick Lewycky 8d2226208d Ensure that the NRVO flag has some block to insert into. Fixes PR9178!
llvm-svn: 125694
2011-02-16 23:59:08 +00:00
Ted Kremenek 197fcd4418 Fix assertion failure in -Warray-bounds on template parameters used as arrays.
llvm-svn: 125693
2011-02-16 23:39:09 +00:00
Fariborz Jahanian 9cd649d376 Block rewriting bug. Don't take address of captured
byref variables again when passing them to inner blocks. 
// rdar://9006279

llvm-svn: 125690
2011-02-16 22:37:10 +00:00
Ted Kremenek 3a854f8ad2 Placate Doug and change capitalization of diagnostic note.
llvm-svn: 125688
2011-02-16 22:08:28 +00:00
Zhanyong Wan 85a203ebdd Makes most methods in SVals.h conform to the naming guide. Reviewed
by kremenek.

llvm-svn: 125687
2011-02-16 21:13:32 +00:00
Chandler Carruth 83ac424574 3000 Sema diagnostics should be enough for anyone.
llvm-svn: 125684
2011-02-16 19:41:58 +00:00
Douglas Gregor d766be689d Fix a thinko with llvm::Optional, which is clearly the most dangerous class template in the universe
llvm-svn: 125679
2011-02-16 19:09:24 +00:00
Douglas Gregor 162b712d38 Teach the CXCodeCompleteResults results structure, which stores
code-completion results accessed via libclang, to extend the lifetime
of the allocator used for cached global code-completion results at
least until these completion results are destroyed. Fixes
<rdar://problem/8997369>.

llvm-svn: 125678
2011-02-16 19:08:06 +00:00
Devang Patel 1728c232d5 If preprocessed token introduced empty filename then use main translation unit's filename for debug info entries.
llvm-svn: 125672
2011-02-16 18:40:36 +00:00
Douglas Gregor df7a79a997 Improve the invalidation logic for the cache of global code
completions. We now compute a hash of the names of all top-level
declarations and macro definitions, and invalidate the cache when the
hash value changes.

llvm-svn: 125670
2011-02-16 18:16:54 +00:00
Douglas Gregor 012b69d5bb Teach PPChainedCallbacks to forward the InclusionDirective() callback.
llvm-svn: 125669
2011-02-16 18:15:35 +00:00
Argyrios Kyrtzidis d691ad1680 Warning -> ExtWarn
llvm-svn: 125664
2011-02-16 16:23:31 +00:00
John McCall b5011ab8f9 Remove this FIXME; clear up an unused variable; style.
llvm-svn: 125662
2011-02-16 08:39:19 +00:00
John McCall 1bf5846abf Save a copy expression for non-trivial copy constructions of catch variables.
llvm-svn: 125661
2011-02-16 08:02:54 +00:00
Zhanyong Wan 5201b66530 Adds a CMake target for the Basic lib's unit tests. Reviewed by
jyasskin and chapuni.

llvm-svn: 125657
2011-02-16 05:45:20 +00:00
Zhanyong Wan f8a620f8e1 Improves CMakeLists.txt for Clang's unit tests: make "linked
components" and "used libs" arguments of add_clang_unittest().
Reviewed by jyasskin and chapuni.

llvm-svn: 125652
2011-02-16 05:19:17 +00:00
Ted Kremenek 108b2d56bf Tweak -Warray-bounds diagnostics based on feedback from Chandler.
llvm-svn: 125649
2011-02-16 04:01:44 +00:00
NAKAMURA Takumi 2ec773f772 CMake: Tweak for Visual Studio 10 quirk at clang-standalone build.
llvm-svn: 125647
2011-02-16 03:07:15 +00:00
NAKAMURA Takumi 84f2500eb8 test/CMakeLists.txt: Don't depend on llvm toolchain at clang-standalone build.
llvm-svn: 125646
2011-02-16 03:07:10 +00:00
Nick Lewycky bb1e5079b2 Revert r125642. This broke the build? It should be a no-op.
llvm-svn: 125645
2011-02-16 02:34:28 +00:00
Francois Pichet b3e0886599 test/PCH/headersearch.cpp fails on Win32. Not trivial to fix.
llvm-svn: 125644
2011-02-16 02:29:43 +00:00
Ken Dyck 1300b3b357 Convert the UnpackedAlignment field to CharUnits from bits. No change in
functionality intended.

llvm-svn: 125643
2011-02-16 02:11:31 +00:00
Nick Lewycky 757515588a Don't use "../foo" to return to the current directory.
llvm-svn: 125642
2011-02-16 02:10:49 +00:00
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
Ken Dyck d5090c16f8 Convert RecordLayout::DataSize to CharUnits from bits, eliminating two
unnecessary calls to RoundUpToAlignment. No changes to functionality
intended.

llvm-svn: 125356
2011-02-11 02:20:09 +00:00
Ken Dyck b0fcc59e19 Add a helper function, ASTContext::toBits(), that converts sizes in
CharUnits to sizes in bits, and use it to tidy up the places where the
conversion was done explicitly.

llvm-svn: 125332
2011-02-11 01:54:29 +00:00
Rafael Espindola a759d72d7b Use raw_ostream instead of raw_svector_ostream.
llvm-svn: 125330
2011-02-11 01:41:00 +00:00
Daniel Dunbar c351d2b7fd build/compiler-rt: Fake Clang into using the right assembler to build the ARM
bits for the runtime libraries.

llvm-svn: 125328
2011-02-11 01:29:49 +00:00
Douglas Gregor 005a6ace07 Eliminate a major performance problem with chained PCH, where we were
causing the deserialization of a large number of declarations when
writing the visible-updates record for the translation unit in C. This
takes us from:

*** AST File Statistics:
  2 stat cache hits
  6 stat cache misses
  1/64463 source location entries read (0.001551%)
  15606/16956 types read (92.038216%)
  59266/89334 declarations read (66.342041%)
  38952/61393 identifiers read (63.446976%)
  0/7778 selectors read (0.000000%)
  24192/34644 statements read (69.830276%)
  388/8809 macros read (4.404586%)
  2095/5189 lexical declcontexts read (40.373867%)
  0/4587 visible declcontexts read (0.000000%)
  0/7716 method pool entries read (0.000000%)
  0 method pool misses

to

*** AST File Statistics:
  2 stat cache hits
  6 stat cache misses
  1/64463 source location entries read (0.001551%)
  26/16956 types read (0.153338%)
  18/89334 declarations read (0.020149%)
  145/61393 identifiers read (0.236183%)
  0/7778 selectors read (0.000000%)
  21/34644 statements read (0.060617%)
  0/8809 macros read (0.000000%)
  0/5189 lexical declcontexts read (0.000000%)
  0/4587 visible declcontexts read (0.000000%)
  0/7716 method pool entries read (0.000000%)
  0 method pool misses

when generating a chained PCH for a header that #includes Cocoa.h
(from a PCH file) and adds one simple function declaration. The
generated PCH file is now only 9580 bytes (down from > 2MB).

llvm-svn: 125326
2011-02-11 00:52:17 +00:00
Douglas Gregor 68051a74ec Implement AST/PCH chaining support for macro definitions. Previously,
we would deserialize all of the macro definitions we knew about while
serializing the macro definitions at the end of the AST/PCH file. Even
though we skipped most of them (since they were unchanged), it's still
a performance problem.

Now, we do the standard AST/PCH chaining trick: watch what identifiers
are deserialized as macro names, and consider only those identifiers
(along with macro definitions that have been deserialized/written in
the source) when serializing the preprocessor state.

llvm-svn: 125324
2011-02-11 00:26:14 +00:00
Rafael Espindola ac00f5dd4b Use raw_svector_ostream in more places in the mangler.
llvm-svn: 125321
2011-02-10 23:59:36 +00:00
Matt Beaumont-Gay 1fe49151c9 Add braces to quiet a gcc warning.
llvm-svn: 125309
2011-02-10 20:35:01 +00:00
Daniel Dunbar 7c2dc3667f Fix think-o I committed without testing, shameful.
llvm-svn: 125299
2011-02-10 18:29:28 +00:00
Daniel Dunbar 66d8483170 Fix a gcc Wuninitialized false positive.
llvm-svn: 125298
2011-02-10 18:24:25 +00:00
Douglas Gregor 2e5571d0fb When we're writing macro definitions to an AST/PCH File, sort the
macro definitions by macro name first. That way, we'll get a stable
ordering in the AST/PCH file.

llvm-svn: 125297
2011-02-10 18:20:09 +00:00
Argyrios Kyrtzidis 7dd856a76b For -Woverloaded-virtual take into account canonical methods. Fixes rdar://8979966 & http://llvm.org/PR9182.
llvm-svn: 125296
2011-02-10 18:13:41 +00:00
Daniel Dunbar cb2b3d051d Fix family-friendly-o, tsk tsk.
llvm-svn: 125293
2011-02-10 18:10:07 +00:00
Daniel Dunbar 468a8f8756 IRgen: Fix an immediate-exit-from-fn style nit.
llvm-svn: 125289
2011-02-10 17:32:22 +00:00
Douglas Gregor 09b6989ef0 Implement two related optimizations that make de-serialization of
AST/PCH files more lazy:
  - Don't preload all of the file source-location entries when reading
  the AST file. Instead, load them lazily, when needed.
  - Only look up header-search information (whether a header was already
  #import'd, how many times it's been included, etc.) when it's needed
  by the preprocessor, rather than pre-populating it.

Previously, we would pre-load all of the file source-location entries,
which also populated the header-search information structure. This was
a relatively minor performance issue, since we would end up stat()'ing
all of the headers stored within a AST/PCH file when the AST/PCH file
was loaded. In the normal PCH use case, the stat()s were cached, so
the cost--of preloading ~860 source-location entries in the Cocoa.h
case---was relatively low.

However, the recent optimization that replaced stat+open with
open+fstat turned this into a major problem, since the preloading of
source-location entries would now end up opening those files. Worse,
those files wouldn't be closed until the file manager was destroyed,
so just opening a Cocoa.h PCH file would hold on to ~860 file
descriptors, and it was easy to blow through the process's limit on
the number of open file descriptors.

By eliminating the preloading of these files, we neither open nor stat
the headers stored in the PCH/AST file until they're actually needed
for something. Concretely, we went from

*** HeaderSearch Stats:
835 files tracked.
  364 #import/#pragma once files.
  823 included exactly once.
  6 max times a file is included.
  3 #include/#include_next/#import.
    0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
835 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

with a trivial program that uses a chained PCH including a Cocoa PCH
to

*** HeaderSearch Stats:
4 files tracked.
  1 #import/#pragma once files.
  3 included exactly once.
  2 max times a file is included.
  3 #include/#include_next/#import.
    0 #includes skipped due to the multi-include optimization.
1 framework lookups.
0 subframework lookups.

*** Source Manager Stats:
3 files mapped, 3 mem buffers mapped.
37460 SLocEntry's allocated, 11215575B of Sloc address space used.
62 bytes of files mapped, 0 files with line #'s computed.

for the same program.

llvm-svn: 125286
2011-02-10 17:09:37 +00:00
Roman Divacky 66f2276aee Adjust the object files to be linked in when mcount profiling
is specified in the FreeBSD linker driver.

llvm-svn: 125285
2011-02-10 16:59:40 +00:00
Roman Divacky 5bc5151299 Add a testcase for the mcount profiling.
llvm-svn: 125283
2011-02-10 16:52:35 +00:00
Roman Divacky 178e0160b7 Implement mcount profiling, enabled via -pg.
llvm-svn: 125282
2011-02-10 16:52:03 +00:00
Ken Dyck 89d9f360cd Drop the 'InBits' part from the name of RecordSizeInBits as the value is in
character units.

llvm-svn: 125281
2011-02-10 12:36:29 +00:00
Ken Dyck f18bf0d2e1 Eliminate some signed-to-unsigned comparision warnings introduced in
r125156.

llvm-svn: 125280
2011-02-10 12:20:05 +00:00
NAKAMURA Takumi 98dd73d66c CMake: LLVM_NO_RTTI must be obsolete now!
llvm-svn: 125275
2011-02-10 09:15:32 +00:00
John McCall f768aa7613 Move the check that gives functions with unique-external types unique-external
linkage into Decl.cpp.  Disable this logic for extern "C" functions, because
the operative rule there is weaker.  Fixes rdar://problem/8898466

llvm-svn: 125268
2011-02-10 06:50:24 +00:00
Ted Kremenek 1656db69f3 Run ~GRState() when reclaiming GRStates.
llvm-svn: 125262
2011-02-10 03:07:40 +00:00
Ted Kremenek 75e4564140 static analyzer: Make GRStates reference counted, with reference counts managed by ExplodedNodes.
This reduces memory usage of the analyzer on sqlite by another 5%.

llvm-svn: 125260
2011-02-10 02:21:52 +00:00
Ted Kremenek 4bd19da586 Add hack to CMakeLists.txt so that StaticAnalyzer libraries find their corresponding headers.
This is a hack because we really should only search in the 'include/clang/StaticAnalyzer' directory
if we are in 'lib/StaticAnalyzer'.  My CMake knowledge is limited, so I appeal to anyone with
more expertise.

llvm-svn: 125252
2011-02-10 01:03:09 +00:00
Ted Kremenek f8cbac4b91 Split 'include/clang/StaticAnalyzer' into 'include/clang/StaticAnalyzer/Core' and 'include/clang/StaticAnalyzer/Checkers'.
This layout matches lib/StaticAnalyzer, which corresponds to two StaticAnalyzer libraries.

llvm-svn: 125251
2011-02-10 01:03:03 +00:00
Devang Patel 425909dd41 If an aggregate is returned as 'sret' argument then let debugger know about this.
llvm-svn: 125249
2011-02-10 00:40:52 +00:00
Ted Kremenek 0bc2855aa9 Update clang-wpa to pass extra argument to AnalysisManager constructor.
llvm-svn: 125235
2011-02-09 22:59:20 +00:00
Devang Patel 17ac005dbb Add target triple.
llvm-svn: 125230
2011-02-09 22:29:15 +00:00
Fariborz Jahanian ca3566fc20 Fix scoping of method declarations and issue
warning when same parameter name used multiple times.
// rdar://8877730

llvm-svn: 125229
2011-02-09 22:20:01 +00:00
Peter Collingbourne 5eec5f0422 Parse: add support for parsing CUDA kernel calls
llvm-svn: 125219
2011-02-09 21:12:02 +00:00
Peter Collingbourne c1270f51fa Lexer: add CUDA kernel call tokens
llvm-svn: 125218
2011-02-09 21:08:21 +00:00
Peter Collingbourne 41f8546233 AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actions
llvm-svn: 125217
2011-02-09 21:07:24 +00:00
Peter Collingbourne 9e2c81f00a AST, Sema, Serialization: keep track of cudaConfigureCall
llvm-svn: 125216
2011-02-09 21:04:32 +00:00
Devang Patel 84d40a431f Do not emit AT_MIPS_linkage_name for Objective-C method static variable i.
llvm-svn: 125210
2011-02-09 19:16:38 +00:00
Douglas Gregor 1388a89999 Finish up the diagnostic client before we've torn down the ASTReader,
since the diagnostic client might poke at source locations that have
not yet been deserialized.

llvm-svn: 125204
2011-02-09 18:47:31 +00:00
Daniel Dunbar 0bb0331d95 Driver/Frontend: Wire up -mregparm=.
llvm-svn: 125201
2011-02-09 17:54:19 +00:00
Nick Lewycky bae992ffd9 Non-void functions need to return some value.
llvm-svn: 125185
2011-02-09 08:42:57 +00:00
John McCall f75152fb9f Give these little helper functions definitions so that newer gccs stop
complaining.

llvm-svn: 125184
2011-02-09 08:31:17 +00:00
John McCall bd06678921 Remove vtables from the Stmt hierarchy; this was pretty easy as
there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.

llvm-svn: 125183
2011-02-09 08:16:59 +00:00
Zhanyong Wan 392d2ed8a1 Fix a typo in a comment in tools/clang/unittests/Frontend/Makefile.
llvm-svn: 125182
2011-02-09 07:42:47 +00:00
Ted Kremenek 435c80f5ea Initialize 'reclaimNodes'.
llvm-svn: 125179
2011-02-09 06:04:59 +00:00
NAKAMURA Takumi 1e8200d7ba test: CMake: Be aware of LLVM_LIT_TOOLS_DIR.
llvm-svn: 125178
2011-02-09 04:19:57 +00:00
Devang Patel 19ba2b4d6e Emit debug info for objc_selector.
llvm-svn: 125163
2011-02-09 03:15:05 +00:00
Ken Dyck 48b0b2f762 Correct units in comments describing Size and getSize().
llvm-svn: 125158
2011-02-09 02:06:44 +00:00
Douglas Gregor 2575631c0f When IRgen refers to a function declaration that is not a definition,
and we later find the definition, make sure that we add the definition
(not the declaration) to the list of deferred definitions to
emit. Fixes PR8864.

Thanks to Nick Lewycky for testing this	patch out

llvm-svn: 125157
2011-02-09 02:03:05 +00:00
Ken Dyck c8ae55050d Convert RecordLayout::Size to CharUnits from bits. No changes to
functionality intended.

llvm-svn: 125156
2011-02-09 01:59:34 +00:00
Ted Kremenek a40f8ebc83 static analyzer: Further reduce the analyzer's memory usage when analyzing sqlite3 by 7-10% by recylcing "uninteresting" ExplodedNodes.
The optimization involves eagerly pruning ExplodedNodes from the ExplodedGraph that contain
practically no difference between the predecessor and successor nodes.  For example, if
the state is different between a predecessor and a node, the node is left in.  Only for
the 'environment' component of the state do we not care if the ExplodedNodes are different.
This paves the way for future optimizations where we can reclaim the environment objects.

llvm-svn: 125154
2011-02-09 01:27:33 +00:00
Ted Kremenek a628225535 Make ProgramPoint::getTag() public.
llvm-svn: 125153
2011-02-09 01:27:27 +00:00
John McCall f4cd4f94d9 NonTypeTemplateParmDecl is just a DeclaratorDecl, not a VarDecl.
Also, reorganize and make very explicit the logic for determining
the value kind and type of a referenced declaration.

llvm-svn: 125150
2011-02-09 01:13:10 +00:00
Devang Patel 14524e0f24 If an aggregate argument is passed indirectly because it has non trivial
destructor or copy constructor than let debug info know about it.

Radar 8945514.

llvm-svn: 125142
2011-02-09 00:37:30 +00:00
Ted Kremenek fffba74477 No longer pass deprecated '-nodistribute' flag to xcodebuild.
llvm-svn: 125131
2011-02-08 22:54:30 +00:00
Ted Kremenek 1953f97ac9 analyzer, retain/release checker: Remove hack where objects passed in message to 'self' are no longer tracked.
llvm-svn: 125130
2011-02-08 22:54:26 +00:00
Rafael Espindola c6236065b7 Update for API change.
llvm-svn: 125129
2011-02-08 22:44:16 +00:00
John McCall 7a198cef04 When checking the 'weak' and 'weakref' attributes, look for non-external
linkage rather than the presence of the 'static' storage class specifier.
Fixes rdar://problem/8814626.

llvm-svn: 125126
2011-02-08 22:35:49 +00:00
Fariborz Jahanian 701f094afb Fix an IRGen bug in property setter calls when
setter and getter types mismatch. // rdar://8966864

llvm-svn: 125125
2011-02-08 22:33:23 +00:00
Argyrios Kyrtzidis fa0734ec4f [analyzer] Move the files in lib/StaticAnalyzer to lib/StaticAnalyzer/Core.
Eventually there will also be a lib/StaticAnalyzer/Frontend that will handle initialization and checker registration.
Yet another library to avoid cyclic dependencies between Core and Checkers.

llvm-svn: 125124
2011-02-08 22:30:36 +00:00
Argyrios Kyrtzidis 4975170267 [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineExperimentalChecks.cpp -> lib/StaticAnalyzer/Checkers/ExperimentalChecks.cpp
llvm-svn: 125123
2011-02-08 22:30:15 +00:00
Argyrios Kyrtzidis f410a6299f [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineExperimentalChecks.h -> lib/StaticAnalyzer/Checkers/ExperimentalChecks.h
llvm-svn: 125122
2011-02-08 22:30:11 +00:00
Argyrios Kyrtzidis f99d595cfd [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineInternalChecks.h -> lib/StaticAnalyzer/Checkers/InternalChecks.h
llvm-svn: 125121
2011-02-08 22:30:02 +00:00
John McCall 53c72e71cc Test case accidentally left out of my last commit.
llvm-svn: 125119
2011-02-08 22:28:39 +00:00
Douglas Gregor 92a96f5c32 Split the serialized representation for the detailed preprocessing
record away from the core processor record. The tangling of these two
data structures led to some inefficiencies (e.g., deserializing all
of the detailed preprocessing record when we didn't need it, such as
while performing code completion) along with some unnecessary
ugliness.

llvm-svn: 125117
2011-02-08 21:58:10 +00:00
Peter Collingbourne 3a34725ed1 AST: support for pre-arg expressions on CallExpr subclasses
llvm-svn: 125115
2011-02-08 21:18:02 +00:00