Commit Graph

31138 Commits

Author SHA1 Message Date
Chris Lattner 35bd5be2a2 how about we initialize RecursionState.
llvm-svn: 134855
2011-07-10 01:10:18 +00:00
Chris Lattner 8806e32f16 Rename CGT::VerifyFuncTypeComplete to isFuncTypeConvertible since
it is a predicate, not an action.  Change the return type to be a bool,
not the incomplete member.  Enhace it to detect the recursive compilation
case, allowing us to compile Eli's testcase on llvmdev:

struct T {
 struct T (*p)(void);
} t;

into:

%struct.T = type { {}* }

@t = common global %struct.T zeroinitializer, align 8

llvm-svn: 134853
2011-07-10 00:18:59 +00:00
NAKAMURA Takumi ad43b8fe58 test/CMakeLists.txt: Add missing c-arcmt-test to clang-test.deps.
llvm-svn: 134851
2011-07-09 23:36:37 +00:00
Argyrios Kyrtzidis dd76300464 Fix linker problem in buildbot.
llvm-svn: 134849
2011-07-09 22:35:06 +00:00
Argyrios Kyrtzidis 347bf910b9 Ugh, fix CMake.
llvm-svn: 134848
2011-07-09 22:05:50 +00:00
Argyrios Kyrtzidis 27019be903 [libclang] Fix linker error in buildbots.
llvm-svn: 134847
2011-07-09 21:35:58 +00:00
Argyrios Kyrtzidis d8d3c1b8f3 [arcmt] Remove test/ARCMT/with-working-dir.m which fails at windows hosts and is not that useful
in the first place. http://llvm.org/PR10312.

llvm-svn: 134845
2011-07-09 20:01:02 +00:00
Argyrios Kyrtzidis 7fbd97f641 [arcmt] Introduce new '-ccc-arcmt-migrate <path>' ARC migration driver option.
This is a new mode of migration, where we avoid modifying the original files but
we emit temporary files instead.

<path> will be used to keep migration process metadata. Currently the temporary files
that are produced are put in the system's temp directory but we can put them
in the <path> if is necessary.

Also introduce new ARC migration functions in libclang whose only purpose,
currently, is to accept <path> and provide pairs of original file/transformed file
to map from the originals to the files after transformations are applied.

Finally introduce the c-arcmt-test utility that exercises the new libclang functions,
update arcmt-test, and add tests for the whole process.

rdar://9735086.

llvm-svn: 134844
2011-07-09 20:00:58 +00:00
Chris Lattner 955d9c715e when an enum type is completed, only flush the type cache when
the enum has already been converted.  If not, there cannot be any types
built on top of it, so there is no need to flush the cache.

llvm-svn: 134841
2011-07-09 18:53:56 +00:00
Chris Lattner f5926b460b fix this on 32-bit hosts.
llvm-svn: 134840
2011-07-09 18:33:01 +00:00
Chris Lattner a5f58b05e8 clang side to match the LLVM IR type system rewrite patch.
llvm-svn: 134831
2011-07-09 17:41:47 +00:00
John McCall c2f0001c80 More compiler workarounds. I have to admit that I was not
expecting so much concentrated oddity on what seemed like a
trivial feature.  Thanks to François Pichet for doing the
MSVC legwork here.

llvm-svn: 134813
2011-07-09 09:09:00 +00:00
Evan Cheng 7b15d1885f cc1 must initialize MC subtarget infos for inline asm parsing. Re-enable asm-errors.c
llvm-svn: 134811
2011-07-09 07:32:07 +00:00
Chris Lattner 380667d520 disable this test to get the botz green again.
llvm-svn: 134808
2011-07-09 07:14:54 +00:00
Evan Cheng dec3187e7f createAsmParser API change.
llvm-svn: 134797
2011-07-09 06:04:17 +00:00
John McCall 7c4df104ce GCC 4.2 compatibility hack.
llvm-svn: 134785
2011-07-09 02:30:03 +00:00
John McCall 82fe67bb82 A number of array-related IR-gen cleanups.
- Emit default-initialization of arrays that were partially initialized
    with initializer lists with a loop, rather than emitting the default
    initializer N times;
  - support destroying VLAs of non-trivial type, although this is not
    yet exposed to users; and
  - support the partial destruction of arrays initialized with
    initializer lists when an initializer throws an exception.

llvm-svn: 134784
2011-07-09 01:37:26 +00:00
Eli Friedman a7c9411818 Silly typo in test for r134770.
llvm-svn: 134774
2011-07-08 23:57:18 +00:00
Eli Friedman 3346582bca Change -mno-mmx to be more compatible with gcc. Specifically, -mno-mmx should not imply -mno-sse.
Note that because we don't usually touch the MMX registers anyway, all -mno-mmx needs to do is tweak the x86-32 calling convention a little for vectors that look like MMX vectors, and prevent the definition of __MMX__.

clang doesn't actually stop the user from using MMX inline asm operands or MMX builtins in -mno-mmx mode; as a QOI issue, it would be nice to diagnose, but I doubt it really matters much.

<rdar://problem/9694837>

llvm-svn: 134770
2011-07-08 23:31:17 +00:00
Bruno Cardoso Lopes 129b4cc9ec Revert x86_64 ABI changes until I have time to check the items raised by Eli.
llvm-svn: 134765
2011-07-08 22:57:35 +00:00
Jakub Staszak d2cf2cbae9 Introduce __builtin_expect() intrinsic support.
llvm-svn: 134761
2011-07-08 22:45:14 +00:00
Bruno Cardoso Lopes 308d7423a9 Add support for AVX 256-bit in the x86_64 ABI (as in the 0.99.5 draft)
llvm-svn: 134754
2011-07-08 22:18:40 +00:00
Cameron Zwarich ae7bc98710 Add codegen support for the fma/fmal/fmaf builtins.
llvm-svn: 134743
2011-07-08 21:39:34 +00:00
Benjamin Kramer 581f48f583 Initialize all the AnalysisBasedWarnings statistics to zero.
Found by valgrind.

llvm-svn: 134733
2011-07-08 20:38:53 +00:00
Benjamin Kramer 65cc1074f3 Remove unused variable.
llvm-svn: 134731
2011-07-08 20:20:17 +00:00
Eli Friedman f7ca26a077 Fix up dependency file name printing to more closely match that of gcc, including fixing a nasty recent regression that could make us print "/foo.h" with a command-line including "-I ./".
rdar://problem/9734352

llvm-svn: 134728
2011-07-08 20:17:28 +00:00
Fariborz Jahanian f2913401fc objc++-arc: more diagnosis of converting a weak-unavailable
object to a __weak object type. // rdar://9732636

llvm-svn: 134706
2011-07-08 17:41:42 +00:00
Douglas Gregor 6336f29669 Teach CXXUnresolvedConstructExpr when it should be an
lvalue/xvalue/rvalue, rather than just (incorrectly) assuming it's an
lvalue. Fixes PR10285 / <rdar://problem/9743926>.

llvm-svn: 134700
2011-07-08 15:50:43 +00:00
Chandler Carruth d280754094 Add several CFG-stress-testing input source files. These use the
preprocessor to build up very large CFGs in various shapes that can
produce different algorithmic behavior in CFG-walking code.

llvm-svn: 134698
2011-07-08 11:20:51 +00:00
Chandler Carruth a532863131 Make the worklist in the uninitialized values checker actually a queue.
Previously, despite the names 'enqueue' and 'dequeue', it behaved as
a stack and visited blocks in a LIFO fashion. This interacts badly with
extremely broad CFGs *inside* of a loop (such as a large switch inside
a state machine) where every block updates a different variable.

When encountering such a CFG, the checker visited blocks in essentially
a "depth first" order due to the stack-like behavior of the work list.
Combined with each block updating a different variable, the saturation
logic of the checker caused it to re-traverse blocks [1,N-1] of the
broad CFG inside the loop after traversing block N. These re-traversals
were to propagate the variable values derived from block N. Assuming
approximately the same number of variables as inner blocks exist, the
end result is O(N^2) updates. By making this a queue, we also make the
traversal essentially "breadth-first" across each of the N inner blocks
of the loop. Then all of this state is propagated around to all N inner
blocks of the loop. The result is O(N) updates.

The truth is in the numbers:
Before, gcc.c:   96409 block visits  (max: 61546,   avg: 591)
After,  gcc.c:   69958 block visits  (max: 33090,   avg: 429)
Before, PR10183: 2540494 block vists (max: 2536495, avg: 37360)
After,  PR10183: 137803 block visits (max: 134406,  avg: 2026)

The nearly 20x reduction in work for PR10183 corresponds to a roughly
100x speedup in compile time.

I've tested it on all the code I can get my hands on, and I've seen no
slowdowns due to this change. Where I've collected stats, the ammount of
work done is on average less. I'll also commit shortly some synthetic
test cases useful in analyzing the performance of CFG-based warnings.

Submitting this based on Doug's feedback that post-commit review should
be good. Ted, please review! Hopefully this helps compile times until
then.

llvm-svn: 134697
2011-07-08 11:19:06 +00:00
Evan Cheng 491f56d41e Fix a FIXME in clang ARM driver that was exposed as a bug with ARM backend
change.

Previously clang was passing the following feature strings to the ARM backend
when CPU is cortex-a8: +neon,-vfp2,-vfp3

This used to work because -vfp2,-vfp3 had no effect after +neon. Now that the
features are controlled by individual bits (with implied hierarchy), the net
effect is all three features will be turned off.

llvm-svn: 134691
2011-07-08 06:40:11 +00:00
Francois Pichet 3a44e43d40 Random cleanup:
- fix a comment.
- Remove an unnecessary { } block.

llvm-svn: 134690
2011-07-08 06:21:47 +00:00
Chandler Carruth 904cb14225 Remove a no-op break after a return, and correct one of the most
confusing indentations I've seen recently... Just noticed these while
making a change elsewhere.

No functionality changed.

llvm-svn: 134685
2011-07-08 04:59:44 +00:00
Chandler Carruth c5c3b0a25b Minor style cleanup.
Original patch by John Freeman, some style tweaks by me.

llvm-svn: 134683
2011-07-08 04:28:55 +00:00
Chandler Carruth 961995dc9a Update the creation of the TargetAsmParser based on API change in r134678.
llvm-svn: 134680
2011-07-08 03:15:48 +00:00
Chandler Carruth 8ae50ad064 Tweak formatting.
llvm-svn: 134675
2011-07-08 01:04:24 +00:00
Chandler Carruth 2536c072f7 Switch the token-paste source locations inside of function style macro
argument expansion to use the macro argument source locations as well.
Add a few tests to exercise this. There is still a bit more work needed
here though.

llvm-svn: 134674
2011-07-08 01:04:21 +00:00
Chandler Carruth 402bb38823 Keep track of which source locations are part of a macro argument
instantiation and improve diagnostics which are stem from macro
arguments to trace the argument itself back through the layers of macro
expansion.

This requires some tricky handling of the source locations, as the
argument appears to be expanded in the opposite direction from the
surrounding macro. This patch provides helper routines that encapsulate
the logic and explain the reasoning behind how we step through macros
during diagnostic printing.

This fixes the rest of the test cases originially in PR9279, and later
split out into PR10214 and PR10215.

There is still some more work we can do here to improve the macro
backtrace, but those will follow as separate patches.

llvm-svn: 134660
2011-07-07 23:56:36 +00:00
Eric Christopher f7d303c541 Add a testcase for the previous commit and update an existing test for an
extra register.

Part of PR10299 and rdar://9740322

llvm-svn: 134657
2011-07-07 23:11:01 +00:00
Fariborz Jahanian 7fcce6829d objc++-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
One item is yet todo.

llvm-svn: 134655
2011-07-07 23:04:17 +00:00
Eric Christopher 0c912c5f9b Fix a typo in the fpsr register and add the fpcr register.
Fixes PR10299 and rdar://9740322

llvm-svn: 134654
2011-07-07 22:55:26 +00:00
Jonathan D. Turner f8c3ccdeae Remove BoostCon-specific code from Clang. FWIW, I'm a fan of things like this living in a separate branch.
llvm-svn: 134649
2011-07-07 22:40:15 +00:00
Argyrios Kyrtzidis 61c58f7f43 Move SourceManager::isAt[Start/End]OfMacroInstantiation functions to the Lexer, since they depend on it now.
llvm-svn: 134644
2011-07-07 21:54:45 +00:00
Bill Wendling e367f387af Layout the code for trapping arithmetic so that the overflow case comes after
the normal case.

Before, for this:

$ cat t.c
int test(int x) { return x * 2; }

We would get this:

   addl  %edi, %edi
   jno   LBB0_2
## BB#1:                                ## %overflow
   ud2
LBB0_2:                                 ## %nooverflow
   movl    %edi, %eax
   popq    %rbp
   ret

Now we get this:

   addl   %edi, %edi
   jo     LBB0_2
## BB#1:                                ## %nooverflow
   movl                                 %edi, %eax
   popq                                 %rbp
   ret
LBB0_2:                                 ## %overflow
   ud2

<rdar://problem/8283919>

llvm-svn: 134642
2011-07-07 21:13:10 +00:00
Cameron Zwarich be652e6a24 r134634 causes a failure on MultiSource/Benchmarks/Olden/bh with TEST=nightly,
so roll it out.

llvm-svn: 134638
2011-07-07 21:03:28 +00:00
Nick Lewycky d755e6ac48 A redeclaration of an inline method in C99 mode should trigger emission of that
function. Fixes PR10233!

llvm-svn: 134634
2011-07-07 20:25:10 +00:00
Alexis Hunt efa6776719 Undo r134587 as the bug was actually a deep and hideous one in the
client code.

My bad.

llvm-svn: 134631
2011-07-07 20:14:21 +00:00
Fariborz Jahanian 6f472e803b objc-arc: diagnose assignment/cast of a weak-unavailable
object to a __weak object/type. // rdar://9732636.
This is objc side of things. objc++ side tbd.

llvm-svn: 134624
2011-07-07 18:55:47 +00:00
Argyrios Kyrtzidis dccf6e1948 Turn hashhash into tok::unkwown when it comes from expanding an argument, per Chris' suggestion.
llvm-svn: 134621
2011-07-07 18:04:47 +00:00
Joerg Sonnenberger c46e3ce58c FreeBSD gets FreeBSD target, just mipsel.
llvm-svn: 134619
2011-07-07 17:01:45 +00:00
Joerg Sonnenberger 39ec119132 Slightly improve the code to derive target from program name to not
fault if no arguments are given.

llvm-svn: 134618
2011-07-07 16:57:26 +00:00
Douglas Gregor 2132584d36 Introduce a new libclang aPI function,
clang_codeCompleteGetContexts(), that provides the client with
information about the context in which code completion has occurred
and what kinds of entities make sense as completions at that
point. Patch by Connor Wakamo!

llvm-svn: 134615
2011-07-07 16:03:39 +00:00
David Chisnall 1bfe6d374d If we're using the pure non-fragile ABI, then skip some of the contortions required to support the transitional ABI.
llvm-svn: 134612
2011-07-07 12:34:51 +00:00
David Chisnall a918b88952 Set a flag to tell the runtime when we're compiling in ARC mode and use the pure-nonfragile ABI for both ARC and GC mode.
llvm-svn: 134611
2011-07-07 11:22:31 +00:00
David Chisnall 561471d2f3 Fix example: variable is initialized to 10 and then has 11 stored in it, but in the expanded version is initialized to 11.
llvm-svn: 134610
2011-07-07 09:49:59 +00:00
John McCall 4db5c3c83a In ARC, reclaim all return values of retainable type, not just those
where we have an immediate need of a retained value.

As an exception, don't do this when the call is made as the immediate
operand of a __bridge retain.  This is more in the way of a workaround
than an actual guarantee, so it's acceptable to be brittle here.

rdar://problem/9504800

llvm-svn: 134605
2011-07-07 06:58:02 +00:00
Argyrios Kyrtzidis c44b93d772 [arcmt] Add -ccc-arcmt-check/-ccc-arcmt-modify driver option aliases.
llvm-svn: 134591
2011-07-07 04:00:39 +00:00
Nick Lewycky 7c6c6cc425 Sort #includes.
llvm-svn: 134589
2011-07-07 03:54:51 +00:00
Argyrios Kyrtzidis e245aa2a93 When expanding macro arguments, treat '##' coming from an argument as a normal token.
e.g.

#define M(x) A x B
M(##) // should expand to 'A ## B', not 'AB'

llvm-svn: 134588
2011-07-07 03:40:37 +00:00
Argyrios Kyrtzidis 41fb2d95a3 Make the Preprocessor more memory efficient and improve macro instantiation diagnostics.
When a macro instantiation occurs, reserve a SLocEntry chunk with length the
full length of the macro definition source. Set the spelling location of this chunk
to point to the start of the macro definition and any tokens that are lexed directly
from the macro definition will get a location from this chunk with the appropriate offset.

For any tokens that come from argument expansion, '##' paste operator, etc. have their
instantiation location point at the appropriate place in the instantiated macro definition
(the argument identifier and the '##' token respectively).
This improves macro instantiation diagnostics:

Before:

t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
        ^~~~
t.c:5:11: note: instantiated from:
int y = M(/);
          ^

After:

t.c:5:9: error: invalid operands to binary expression ('struct S' and 'int')
int y = M(/);
        ^~~~
t.c:3:20: note: instantiated from:
\#define M(op) (foo op 3);
                ~~~ ^  ~
t.c:5:11: note: instantiated from:
int y = M(/);
          ^

The memory savings for a candidate boost library that abuses the preprocessor are:

- 32% less SLocEntries (37M -> 25M)
- 30% reduction in PCH file size (900M -> 635M)
- 50% reduction in memory usage for the SLocEntry table (1.6G -> 800M)

llvm-svn: 134587
2011-07-07 03:40:34 +00:00
Argyrios Kyrtzidis c8f7e213b9 Fix bug in SourceManager::getDecomposedInstantiationLocSlowCase.
It would add up relative (decomposed) offsets like in getDecomposedSpellingLocSlowCase, but while
it makes sense to preserve the offset among lexed spelling locations, it doesn't make
sense to add anything to the offset of the instantiation location. The instantiation
location will be the same regardless of the relative offset in the tokens that were
instantiated.

This bug didn't actually affect anything because, currently, in practice we never create macro
locations with relative offset greater than 0.

llvm-svn: 134586
2011-07-07 03:40:27 +00:00
Argyrios Kyrtzidis 2cc62093fc For -print-stats, add the number of bytes that SLocEntryTable consumes.
llvm-svn: 134585
2011-07-07 03:40:24 +00:00
Nick Lewycky 365efd62a1 In an in-class initialization, defer checks for value-dependent initialization
expressions.

llvm-svn: 134583
2011-07-07 02:20:13 +00:00
Eli Friedman a3c122db7e Zap a couple unnecessary loops.
llvm-svn: 134578
2011-07-07 01:54:01 +00:00
Tanya Lattner 207189ef25 Do not violate the opencl casting rules. This test case still illustrates the problem. In the future, we should throw an error when doing invalid casting.
llvm-svn: 134570
2011-07-07 00:12:54 +00:00
John McCall c3df93aa0d Move and elaborate the section on objc_arc_weak_unavailable.
llvm-svn: 134567
2011-07-07 00:03:42 +00:00
Alexis Hunt 197ec69ba7 Ensure that we actually visit function parameter declarations with
RecursiveASTVisitor.

This deficiency was discovered while working with the AST matcher
framework and likely impacts other users of RecursiveASTMatcher who
previously weren't seeing these Decls in their visitation.

Patch reviewed by Chandler Carruth.

llvm-svn: 134562
2011-07-06 23:35:33 +00:00
Fariborz Jahanian 1025318ca9 Update document for objc_arc_weak_unavailable attribute
on class declarations. Documentation for // rdar://9693477

llvm-svn: 134558
2011-07-06 22:56:44 +00:00
Fariborz Jahanian e634a92dac Update document on use of ns_returns_not_retained
attribute on property. Document for // rdar://9636091.

llvm-svn: 134556
2011-07-06 22:47:46 +00:00
Chandler Carruth 50020d9461 Based on comments from Chris, switch to using CFG::getNumBlockIDs()
rather than a computed std::distance(). At some point I had convinced
myself that these two were different; but as far as I can tell on
re-exampination they aren't, and the number of block IDs is actually
just a count of the blocks in the CFG.

While this removes the primary motivation for guarding all of this with
CollectStats, I have a patch coming up that will almost certainly make
it important again.

llvm-svn: 134552
2011-07-06 22:21:45 +00:00
Francois Pichet abcfbecf39 MSVC doesn't like mixing declarations and statements in a C file.
llvm-svn: 134550
2011-07-06 22:09:44 +00:00
Douglas Gregor 53e191ed94 Properly implement the scope restriction on the NRVO for
throw-expressions, such that we don't consider the NRVO when the
non-volatile automatic object comes from outside the innermost try
scope (C++0x [class.copymove]p13). In C++98/03, our ASTs were
incorrect but it didn't matter because IR generation doesn't actually
apply the NRVO here. In C++0x, however, we were moving from an object
when in fact we should have copied from it. Fixes PR10142 /
<rdar://problem/9714312>.

llvm-svn: 134548
2011-07-06 22:04:06 +00:00
Fariborz Jahanian 251e793a3f Update documentation for // rdar://9619861
llvm-svn: 134544
2011-07-06 21:58:44 +00:00
Fariborz Jahanian 134f4587e7 revert patch for // rdar://9227352
llvm-svn: 134536
2011-07-06 21:05:11 +00:00
Fariborz Jahanian c6ba959ab1 Some code cleanup of r134522
llvm-svn: 134529
2011-07-06 20:48:48 +00:00
Evan Cheng 299b36fa72 createMCInstPrinter doesn't need TargetMachine anymore.
llvm-svn: 134526
2011-07-06 19:45:57 +00:00
Fariborz Jahanian 1f626d6fd1 objc-arc: Support objc_arc_weak_unavailable on those
classes which are incompatible with weak references.
// rdar://9693477

llvm-svn: 134522
2011-07-06 19:24:05 +00:00
Douglas Gregor 750734c677 Don't try to type-check a copy construction of an exception
declaration with dependent type. Fixes PR10232 /
<rdar://problem/9700653>.

llvm-svn: 134515
2011-07-06 18:14:43 +00:00
Jonathan D. Turner 3b1da3604f Update docs to remove reference to OverloadedFunctionDecl and replace it with DeclContext::lookup_result.
llvm-svn: 134514
2011-07-06 18:12:36 +00:00
Douglas Gregor 8a60bbe13f Keep track of when "unrecoverable" errors occur, then allow
clang_saveTranslationUnit() to save a PCH file if the only errors it
contains are recoverable errors. Fixes <rdar://problem/9727804>.

llvm-svn: 134503
2011-07-06 17:40:26 +00:00
Benjamin Kramer 37d30835f0 SmallVectorize a critical vector.
The small number of elements was determined by taking the median
file length in clang+llvm and /usr/include on OS X with xcode installed.

llvm-svn: 134496
2011-07-06 16:43:46 +00:00
Douglas Gregor 30c80fa3eb libclang: Allow callers of clang_saveTranslationUnit() to distinguish
between different classes of errors. Addresses most of
<rdar://problem/9660328>.

llvm-svn: 134495
2011-07-06 16:43:36 +00:00
Chandler Carruth b4836ea7a8 Build up statistics about the work done for analysis based warnings.
Special detail is added for uninitialized variable analysis as this has
serious performance problems than need to be tracked.

Computing some of this data is expensive, for example walking the CFG to
determine its size. To avoid doing that unless the stats data is going
to be used, we thread a bit into the Sema object to track whether
detailed stats should be collected or not. This bit is used to avoid
computations whereever the computations are likely to be more expensive
than checking the state of the flag. Thus, counters are in some cases
unconditionally updated, but the more expensive (and less frequent)
aggregation steps are skipped.

With this patch, we're able to see that for 'gcc.c':
*** Analysis Based Warnings Stats:
232 functions analyzed (0 w/o CFGs).
  7151 CFG blocks built.
  30 average CFG blocks per function.
  1167 max CFG blocks per function.
163 functions analyzed for uninitialiazed variables
  640 variables analyzed.
  3 average variables per function.
  94 max variables per function.
  96409 block visits.
  591 average block visits per function.
  61546 max block visits per function.

And for the reduced testcase in PR10183:
*** Analysis Based Warnings Stats:
98 functions analyzed (0 w/o CFGs).
  8526 CFG blocks built.
  87 average CFG blocks per function.
  7277 max CFG blocks per function.
68 functions analyzed for uninitialiazed variables
  1359 variables analyzed.
  19 average variables per function.
  1196 max variables per function.
  2540494 block visits.
  37360 average block visits per function.
  2536495 max block visits per function.

That last number is the somewhat scary one that indicates the problem in
PR10183.

llvm-svn: 134494
2011-07-06 16:21:37 +00:00
Douglas Gregor 5c70b06feb Teach the static analyzer's interpretation of Cocoa conventions to
obey the objc_method_family attribute when provided. Fixes
<rdar://problem/9726279>.

llvm-svn: 134493
2011-07-06 16:00:34 +00:00
Rafael Espindola ba195cff81 Use attributes from the definition (if available) when
instantiating functions.

Fixes PR10272.

llvm-svn: 134491
2011-07-06 15:46:09 +00:00
Joerg Sonnenberger fbc0b3a826 Fix C&P error
llvm-svn: 134490
2011-07-06 11:00:56 +00:00
John McCall 542e7c6f64 When tree-transforming an expression sequence, always flag expanded
variadic argument pack expansions as having changed, rather than doing
it for each changed expansion, which leaves out zero-argument packs
with catastrophic consequences.

Fixes PR10260.

llvm-svn: 134483
2011-07-06 07:30:07 +00:00
John McCall 21878760a4 Fixed enum types can be complete without actually being valid to use
as scope specifiers;  diagnose the attempt, rather than letting it go
to an assert.  The rest of PR10264.

llvm-svn: 134479
2011-07-06 06:57:57 +00:00
John McCall cb432faf6d Properly protect colons when parsing a nested-name-specifier as part
of an enum specifier in dialects which permit fixed underlying types.
Fixes the rejects-valid part of PR10264.

llvm-svn: 134468
2011-07-06 05:58:41 +00:00
Douglas Gregor a98034a25e Improve the Python bindings for libclang in a few ways, from Eli
Bendersky. Specifically: 

* Implemented a new function in libclang: clang_isAttribute

* Fixing TranslationUnit.get_includes to only go through the argument
* buffer when it contains something. This fixed a crash on Windows 

* clang_getFileName returns CXString, not char*. Made appropriate
* fixes in cindex.py - now the relevant tests pass and we can see the
* full locations correctly again (previously there was garbage in
* place of the file name) 
* Exposed clang_getCursorDisplayName to the python bindings

llvm-svn: 134460
2011-07-06 03:00:34 +00:00
John McCall 75bc773be5 Somehow the -fgnu-runtime option itself got lost in all that shuffling.
Restore it.

llvm-svn: 134459
2011-07-06 02:36:30 +00:00
John McCall 9de1978f6e Call objc_terminate() instead of abort() when a cleanup throws an
exception in Objective-C;  in Objective-C++ we still use std::terminate().
This is only available in very recent runtimes.

llvm-svn: 134456
2011-07-06 01:22:26 +00:00
John McCall 6dd2417dbe Missing header from last commit; accidental change.
llvm-svn: 134455
2011-07-06 00:38:59 +00:00
Fariborz Jahanian 76b9d4da16 Added a missing case label.
llvm-svn: 134454
2011-07-06 00:29:51 +00:00
John McCall 24fc0decfe Change the driver's logic about Objective-C runtimes: abstract out a
structure to hold inferred information, then propagate each invididual
bit down to -cc1.  Separate the bits of "supports weak" and "has a native
ARC runtime";  make the latter a CodeGenOption.

The tool chain is still driving this decision, because it's the place that
has the required deployment target information on Darwin, but at least it's
better-factored now.

llvm-svn: 134453
2011-07-06 00:26:06 +00:00
Fariborz Jahanian b7a773626f objc-arc: enforce performSelector rules in rejecting retaining selectors
passed to it, and unknown selectors causing potential leak.
// rdar://9659270

llvm-svn: 134449
2011-07-05 22:38:59 +00:00
Dan Gohman fec0ff84dc Add the ObjC ARC optimization passes manually, now that they're not
hardwired into the default pass list.

llvm-svn: 134445
2011-07-05 22:02:36 +00:00
Eli Friedman bb5c9ae425 Remove unused member of Builtin::Info.
llvm-svn: 134443
2011-07-05 21:53:01 +00:00
Devang Patel 2f5297901d Testcase for r134441.
llvm-svn: 134442
2011-07-05 21:48:46 +00:00
Joerg Sonnenberger f8fa4443b3 Drop "soft" argument that would be considered as file argument by cc1.
llvm-svn: 134438
2011-07-05 19:52:46 +00:00
Douglas Gregor b7c0083878 Look through parenthesized declarators when determining whether an
instantiated function template was written with a prototype or via
some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>. 

llvm-svn: 134426
2011-07-05 18:30:26 +00:00
Joerg Sonnenberger 8360e523cf Hook up mipsel-netbsd and mipsel-freebsd for OS specific handling.
llvm-svn: 134425
2011-07-05 18:24:04 +00:00
Joerg Sonnenberger d60cccfecc Use OS-specific configuration for mips-netbsd and mips-freebsd.
llvm-svn: 134422
2011-07-05 18:05:54 +00:00
Douglas Gregor 6b9be0ffb3 Some documentation fixes for the parser, from John Freeman
llvm-svn: 134419
2011-07-05 17:13:11 +00:00
Douglas Gregor 1cb4290b89 StringRef'ize clang::drive::Option::getName(), from Zach Wheeler!
llvm-svn: 134418
2011-07-05 16:56:25 +00:00
Douglas Gregor 9e66af44ad Clean up and refactor ParseFunctionDeclarator to reduce code
repetition and better reflect the actual grammar, from John Freeman!

llvm-svn: 134417
2011-07-05 16:44:18 +00:00
Douglas Gregor 1fe12c9eba ActOnCXXConditionDeclaration should take into account that
ActOnDeclarator can return NULL. Fixes PR10270, from Hans Wennborg!

llvm-svn: 134416
2011-07-05 16:13:20 +00:00
Fariborz Jahanian bf3eec68dd Don't define __CONSTANT_CFSTRINGS__ with -fno-constant-cfstrings issue.
Patch by Jean-Daniel Dupas.

llvm-svn: 134414
2011-07-05 16:00:59 +00:00
Joerg Sonnenberger 870b3c5429 Don't define _BIG_ENDIAN for NetBSD/PowerPC.
llvm-svn: 134411
2011-07-05 14:56:12 +00:00
Joerg Sonnenberger a6d11777f9 Fix indentation
llvm-svn: 134410
2011-07-05 14:54:41 +00:00
Douglas Gregor c9c40ce861 Teach Clang's <float.h> to also include MinGW's <float.h>, which provides additional system definitions, from Ruben Van Boxem
llvm-svn: 134407
2011-07-05 14:17:04 +00:00
Douglas Gregor c750b6c436 Update header-search paths for MinGW, from Ruben Van Boxem
llvm-svn: 134406
2011-07-05 14:16:05 +00:00
Benjamin Kramer e87c38b229 Don't overread the buffer when an %x escape in inline asm ends prematurely.
Tested by valgrind & Sema/asm.c.

llvm-svn: 134404
2011-07-05 11:13:37 +00:00
Benjamin Kramer de1d62314a Initialize member.
llvm-svn: 134403
2011-07-05 09:46:31 +00:00
Joerg Sonnenberger f031fd9e77 Add explicit default case for -Wswitch-enum.
llvm-svn: 134399
2011-07-04 23:11:58 +00:00
Joerg Sonnenberger 025949c366 Use switch(os) style consistently. Add a bunch of NetBSD branches.
llvm-svn: 134393
2011-07-04 21:59:44 +00:00
Joerg Sonnenberger e72d9b1f85 On PowerPC, both FreeBSD and NetBSD use ints for (s)size_t
llvm-svn: 134392
2011-07-04 21:57:55 +00:00
Anders Carlsson 1052fd76ab Remove unused parameter from ActOnDeclarator.
llvm-svn: 134377
2011-07-04 16:28:17 +00:00
Chandler Carruth bfb154ad3f Switch the Decl and Stmt stats printing to use llvm::errs() instead of
fprintf, and to be more consistent in formatting with the other stats
printing routines.

llvm-svn: 134374
2011-07-04 06:13:27 +00:00
Chandler Carruth 3c147a7731 Start switching the AST stats printing to use llvm::errs() instead of
fprintf. There is more cleanup to be done to the AST stats printing...

llvm-svn: 134373
2011-07-04 05:32:14 +00:00
Chris Lattner 052172bc14 fix typo
llvm-svn: 134361
2011-07-03 02:21:48 +00:00
Abramo Bagnara 9ae292d810 Rewritten fix in r134139 to conform evaluation result to original evaluation context.
llvm-svn: 134320
2011-07-02 13:13:53 +00:00
Nick Lewycky 0bdf13ea9a Fix a typo, remove a tab, canonicalize some spacing. No functional change.
llvm-svn: 134305
2011-07-02 02:05:12 +00:00
Eli Friedman ec485453b2 Reorganize builtins to separate out builtins which require MMX registers. No functional change.
llvm-svn: 134304
2011-07-02 01:53:37 +00:00
Douglas Gregor 4326dd9bcc When producing -Wuninitialized Fix-Its for pointers, prefer " = NULL"
over "= 0". Fixes <rdar://problem/9714386>.

llvm-svn: 134302
2011-07-02 00:59:18 +00:00
Eli Friedman 1310c68bb0 Don't use x86_mmx where it isn't necessary.
The start of some work on getting -mno-mmx working the way we want it to.

llvm-svn: 134300
2011-07-02 00:57:27 +00:00
Chandler Carruth 42f96b78ec Make the GCC version proliferation worse by N+1 for the sake of
ArchLinux. =/ Fixes PR10246.

llvm-svn: 134299
2011-07-02 00:51:03 +00:00
Eli Friedman ad811f01d5 Make clang behave in a gcc-compatible way in the presence of multiple flags for the same x86 target feature (e.g. -mno-sse -msse). gcc uses a somewhat unintuitive algorithm here in that the enabled SSE instructions is based on the order of the *last* flag for *each* feature-level, so that "-mno-sse -msse2" only enables SSE2, but "-mno-sse -msse2 -msse" enables all SSE levels.
Issue reported on cfe-dev.

llvm-svn: 134296
2011-07-02 00:34:19 +00:00
Eric Christopher dba0288cbf Add a testcase for r134292.
Part of rdar://9714064

llvm-svn: 134295
2011-07-02 00:28:30 +00:00
Eric Christopher bf15d2b311 Update for llvm commit r134291.
Fixes rdar://9714064

llvm-svn: 134292
2011-07-02 00:20:22 +00:00
Chandler Carruth edc2c64630 Move the Sema argument to all of the Sema-using helper functions in
SemaDeclAttr to the first argument. This makes them follow the very
consistent policy elsewhere in Sema for helper functions.

Original patch by Caitlin Sadowski, with some tweaking by me.

llvm-svn: 134290
2011-07-02 00:01:44 +00:00
Chandler Carruth 3ed22c35d6 Rename static helpers to use 'camelCaseNames' per the new style
recommendations before adding more of them.

Patch by Caitlin Sadowski.

llvm-svn: 134289
2011-07-01 23:49:16 +00:00
Chandler Carruth ff4c4f0f8a Mechanical rename of 'd' Decl pointer parameters to 'D'. This is more
conventional in the rest of Clang's codebase, and closer to the current
style recommendations. It also makes the code more internally consistent
as FD, VD, etc are used frequently for particular decl variables.

Patch by Caitlin Sadowski.

llvm-svn: 134288
2011-07-01 23:49:12 +00:00
Argyrios Kyrtzidis 8e25253e14 -Fix mistake in ASTContext::getInnerObjCOwnership noticed by Doug
-Remove unnecessary 'return'.
-Remove unnecessary 'if' check (llvm_unreachable make sure attrStr will be non-null)
-Add a test of transferring ownership to a reference cast type.

llvm-svn: 134285
2011-07-01 23:01:46 +00:00
Douglas Gregor 9fabd851c8 Add initial *-*-rtems* target, from Joel Sherrill
llvm-svn: 134283
2011-07-01 22:41:14 +00:00
Argyrios Kyrtzidis 451ccc0892 Fix the warning that is emitted when an ownership attribute is applied incorrectly.
llvm-svn: 134278
2011-07-01 22:23:09 +00:00
Argyrios Kyrtzidis 9ab661b163 Use transferARCOwnershipToDeclaratorChunk in inferARCWriteback, no functionality change.
llvm-svn: 134277
2011-07-01 22:23:05 +00:00
Argyrios Kyrtzidis ea57a9be17 Fix assertion hit in inferARCWriteback.
llvm-svn: 134276
2011-07-01 22:23:03 +00:00
Argyrios Kyrtzidis 7192a3b841 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
(NSString**)&x; // Casting as (__strong NSString**).

llvm-svn: 134275
2011-07-01 22:22:59 +00:00
Argyrios Kyrtzidis d8701b60f7 -Remove Sema::ActOnCastOfParenListExpr and move most of its functionality to
newly introduced Sema::BuildVectorLiteral.
-Make Sema::ActOnCastExpr handle a vector initializer both when the cast'ed expression
 is a ParenListExpr and when it is a ParenExpr.
-Ultimately make Sema::ActOnParenOrParenListExpr independent of what the cast type was.

llvm-svn: 134274
2011-07-01 22:22:54 +00:00
Argyrios Kyrtzidis 7451d1cd00 [ARC] When casting from a pointer to an objective-c object with known ownership, if the
cast type has no ownership specified, implicitly "transfer" the ownership of the cast'ed type
to the cast type:

id x;
static_cast<NSString**>(&x); // Casting as (__strong NSString**).

This currently only works for C++ named casts, C casts to follow.

llvm-svn: 134273
2011-07-01 22:22:50 +00:00
Argyrios Kyrtzidis e9b5c85041 Break Sema::GetTypeForDeclarator in 2 functions, one for DeclSpec processing and another for the rest.
No functionality change.

llvm-svn: 134272
2011-07-01 22:22:42 +00:00
Argyrios Kyrtzidis 774506918c Introduce Declarator::ObjCCatchContext, this will result in correct error for 'auto' in obj-c catch.
llvm-svn: 134271
2011-07-01 22:22:40 +00:00
Douglas Gregor 51189e0b51 Refactor AttributeList.h to use alphabetical order, from Caitlin Sadowski
llvm-svn: 134267
2011-07-01 22:04:06 +00:00
Douglas Gregor fa918f69f6 Emit guard variables for any weak global that has a run-time
initializer. Previously, we only used guard variables for weak static
data members. Fixes <rdar://problem/9692249>.

llvm-svn: 134266
2011-07-01 21:54:36 +00:00
Douglas Gregor 3b22a88488 When adding boolean keywords for typo correction, add either "bool" or
"_Bool" (depending on dialect), but not both, since they have the same
edit distance from "Bool".

llvm-svn: 134263
2011-07-01 21:27:45 +00:00
Douglas Gregor c063ac20d8 Fix testcase
llvm-svn: 134262
2011-07-01 21:19:15 +00:00
Douglas Gregor 82e1af20cb Don't zero-initialize default-initialized local variables that have
trivial default constructors. This generated-code regression was
caused by r131796, which had simplified the handling of default
initialization in Sema. Fixes <rdar://problem/9694300>.

llvm-svn: 134260
2011-07-01 21:08:19 +00:00
Richard Trieu 94942b32a3 For code such as:
int f(int x) {
  if (int foo = f(bar)) {}
  return 0;
}

Clang produces the following error messages:

paren_imbalance.cc:2:19: error: use of undeclared identifier 'bar'
  if (int foo = f(bar)) {}
                  ^
paren_imbalance.cc:2:26: error: expected ')'
  if (int foo = f(bar)) {}
                        ^
paren_imbalance.cc:2:6: note: to match this '('
  if (int foo = f(bar)) {}
     ^

The second error is incorrect.  This patch will stop Clang from producing an error on parenthesis imbalance during error recovery when there isn't one.

llvm-svn: 134258
2011-07-01 20:54:02 +00:00
Richard Trieu 95d880933b Fix for PR7410. Allow functions in a derived class that improperly overwrite a virtual function in the base class to be inserted into the derived class function list to prevent extra errors every time the derived class is used.
llvm-svn: 134251
2011-07-01 20:02:53 +00:00