Commit Graph

35471 Commits

Author SHA1 Message Date
Douglas Gregor e171601ff6 Rework the external Sema source's ReadMethodPool() so that it doesn't
return pre-built lists. Instead, it feeds the methods it deserializes
to Sema so that Sema can unique them, which keeps the chains shorter.

llvm-svn: 148889
2012-01-25 00:49:42 +00:00
Ted Kremenek 44d2973b6f Reduce peak memory usage of the static analyzer on sqlite3 (when using inlining) by 30%.
This is accomplished by periodically reclaiming nodes in the graph.  This was an optimization
done before the CFG was linearized, but the CFG linearization destroyed that optimization since each
freshly created node couldn't be reclaimed and we only looked at a window of nodes created between
each ProcessStmt.  This optimization can be reclaimed my merely expanding the window to N number of nodes.

llvm-svn: 148888
2012-01-25 00:35:05 +00:00
Fariborz Jahanian aa7b9aa10d arc migrator: Provide infrastructure to add options
specific to migrator. Use its first option to
warn migrating from GC to arc when 
NSAllocateCollectable/NSReallocateCollectable is used.
// rdar://10532541

llvm-svn: 148887
2012-01-25 00:20:29 +00:00
Douglas Gregor c454afedff Factor out the addition of a method into the global method pool, and
teach it to always add the new method at the *end* of the list rather
than as the second element in the list.

llvm-svn: 148886
2012-01-25 00:19:56 +00:00
Ted Kremenek 9b1f3d46d0 Fix NSLog format string checking for %@.
llvm-svn: 148885
2012-01-25 00:04:09 +00:00
Eli Friedman 946b7b5bc8 Switch PerformImplicitConversion over to use DefaultLvalueConversion for lvalue-to-rvalue conversion.
llvm-svn: 148874
2012-01-24 22:51:26 +00:00
Jean-Daniel Dupas 78536ae5b5 Replace a hack to handle NSLog/NSLogv in sema by declaring them as Library Builtins.
llvm-svn: 148873
2012-01-24 22:32:46 +00:00
Jean-Daniel Dupas 5778cb8e06 Remove trailing slash in front of header name of ObjC builtins.
llvm-svn: 148872
2012-01-24 22:29:27 +00:00
Anna Zaks b3d896d333 [analyzer] Add the HTML file to the SATest diagnostic diff.
(Uses the functionality which has been in CmpRuns long before.)

llvm-svn: 148868
2012-01-24 21:57:35 +00:00
Anna Zaks 895c312404 [analyzer] Testing: make diagnostic diffs more informative (add
diagnostic message).

llvm-svn: 148867
2012-01-24 21:57:32 +00:00
Argyrios Kyrtzidis 3698cef19f [libclang] In clang::getCursorKindForDecl() don't return "UnexposedDecl"
for forward references of classes and protocols, this breaks libclang API usage.

rdar://10747438.

llvm-svn: 148861
2012-01-24 21:39:26 +00:00
Ted Kremenek 6fa5727939 Teach scanf/printf checking about '%Ld' and friends (a GNU extension). Fixes PR 9466.
llvm-svn: 148859
2012-01-24 21:29:54 +00:00
Nick Lewycky 3c1c7952b1 Force triple on these tests to pacify the windows tester.
llvm-svn: 148858
2012-01-24 21:28:47 +00:00
Nick Lewycky 411fc65b45 Add a new warning, -Wover-aligned, which detects attempts to use the default
allocator to construct an object which declares more alignment than the default
allocator actually provides. Fixes PR9527!

llvm-svn: 148857
2012-01-24 21:15:41 +00:00
Chandler Carruth 96bae7b1fd Fix one of the (larger) FIXMEs where we were misusing the Driver's idea
of the target triple to stand in for the "host" triple.

Thanks to a great conversation with Richard Smith, I'm now much more
confident in how this is proceeding. In all of the places where we
currently reason about the "host" architecture or triple, what we really
want to reason about in the detected GCC installation architecture or
triple, and the ways in which that differs from the target. When we find
a GCC installation with a different triple from our target *but capable
of targeting our target* through an option such as '-m64', we want to
detect *that* case and change the paths within the GCC installation (and
libstdc++ installation) to reflect this difference.

This patch makes one function do this correctly. Subsequent commits will
hoist the logic used here into the GCCInstallation utility, and then
reuse it through the rest of the toolchains to fix the remaining places
where this is currently happening.

llvm-svn: 148852
2012-01-24 20:08:17 +00:00
Kaelyn Uhrain 9ce58bd757 Small code cleanup/simplification in Sema::ClassifyName.
llvm-svn: 148850
2012-01-24 19:45:35 +00:00
Argyrios Kyrtzidis d0a27f717e [libclang] When calling clang_getCursorReferenced on a class or protocol
forward reference, do give an interface or protocol cursor back, don't give
an 'UnexposedDecl' one.

rdar://10743193

llvm-svn: 148848
2012-01-24 19:40:15 +00:00
Fariborz Jahanian e2a7776eff objc: Issue a generic diagnostic assigning to
an objc object in any abi mode.

llvm-svn: 148847
2012-01-24 19:40:13 +00:00
Anna Zaks bf740512ec [analyzer] Add more C taint sources/sinks.
llvm-svn: 148844
2012-01-24 19:32:25 +00:00
Chandler Carruth 4d9d76839a Address one part of the FIXME I introduced my switching the triple
inside of GCCInstallation to be a proper llvm::Triple. This is still
a touch ugly because we have to use it as a string in so many places,
but I think on the whole the more structured representation is better.

Comments of course welcome if this tradeoff isn't working for folks.

llvm-svn: 148843
2012-01-24 19:28:29 +00:00
Kostya Serebryany 588d6abf7d The following patch adds __attribute__((no_address_safety_analysis)) which will allow to disable
address safety analysis (such as e.g. AddressSanitizer or SAFECode) for a specific function.

When building with AddressSanitizer, add AddressSafety function attribute to every generated function
except for those that have __attribute__((no_address_safety_analysis)).

With this patch we will be able to
1. disable AddressSanitizer for a particular function
2. disable AddressSanitizer-hostile optimizations (such as some cases of load widening) when AddressSanitizer is on.

llvm-svn: 148842
2012-01-24 19:25:38 +00:00
Chandler Carruth 64cee06504 At least within these classes, consistently spell 'GCC' as 'GCC'.
I can't read Java-style 'Gcc' acronyms. ;]

No functionality changed.

llvm-svn: 148840
2012-01-24 19:21:42 +00:00
Chandler Carruth 46f204fef8 Start hoisting the logic for computing the target triple into its own
function. The logic for this, and I want to emphasize that this is the
logic for computing the *target* triple, is currently scattered
throughout various different HostInfo classes ToolChain factoring
functions. Best part, it is largely *duplicated* there. The goal is to
hoist all of that up to here where we can deal with it once, and in
a consistent manner.

Unfortunately, this uncovers more fun problems: the ToolChains assume
that the *actual* target triple is the one passed into them by these
factory functions, while the *host* triple is the one in the driver.
This already was a lie, and a damn lie, when the '-target' flag was
specified. It only really worked when the difference stemmed from '-m32'
and '-m64' flags. I'll have to fix that (and remove all the FIXMEs I've
introduced here to document the problem) before I can finish hoisting
the target-calculation logic.

It's bugs all the way down today it seems...

llvm-svn: 148839
2012-01-24 19:17:46 +00:00
Douglas Gregor 3ecbc3d655 Promote the extension warning for attempts to catch a reference or
pointer to incomplete type from an ExtWarn to an error. We put the
ExtWarn in place as part of a workaround for Boost (PR6527), but it
(1) doesn't actually match a GCC extension and (2) has been fixed for
two years in Boost, and (3) causes us to emit code that fails badly at
run time, so it's a bad idea to keep it. Fixes PR11803.

llvm-svn: 148838
2012-01-24 19:01:26 +00:00
Douglas Gregor 95d8283931 When importing a RecordDecl as a DeclContext, make sure that we pull
in the definition as well.

llvm-svn: 148831
2012-01-24 18:36:04 +00:00
Fariborz Jahanian 3c4225a858 objc: issue error if assigning objects in fragile-abi too.
// rdar://10731065

llvm-svn: 148823
2012-01-24 18:05:45 +00:00
Douglas Gregor 2aa53777e7 Teach the AST importer about redeclaration chains for Objective-C
classes and protocols, implementing lazy-import semantics for both.

llvm-svn: 148816
2012-01-24 17:42:07 +00:00
Douglas Gregor 247afcc6a9 Only mark an IdentifierInfo as having changed since deserialization
when it actually has changed (and not, e.g., when we've simply attached a
deserialized macro definition). Good for ~1.5% reduction in module
file size, mostly in the identifier table.

llvm-svn: 148808
2012-01-24 15:24:38 +00:00
Douglas Gregor 38f3981a99 On Darwin, use the system's <unwind.h> whenever it is
available. Clang's <unwind.h> isn't ready for prime time. Fixes
<rdar://problem/10733587>.

llvm-svn: 148807
2012-01-24 15:12:50 +00:00
Chandler Carruth 7f1417f7cf Remove HostInfo::useDriverDriver(). This was only used in two places
inside the innards of the Driver implementation, and only ever
implemented to return 'true' for the Darwin OSes. Instead use a more
direct query on the target triple and a comment to document why the
target matters here.

If anyone is worried about this predicate getting wider use or improper
use, I can make it a local or private predicate in the driver.

llvm-svn: 148797
2012-01-24 10:43:44 +00:00
Chandler Carruth 4d73703ffd Hoist the targeted triple object into an actual object in the Driver.
The Driver has a fixed target, whether we like it or not, the
DefaultTargetTriple is not a default. This at least makes things more
honest. I'll eventually get rid of most (if not all) of
DefaultTargetTriple with this proper triple object. Bit of a WIP.

llvm-svn: 148796
2012-01-24 10:21:46 +00:00
David Blaikie 186a8899a4 Support decltype in member initializers.
This is the last piece of N3031 (decltype in weird places) - supporting
the use of decltype in a class ctor's member-initializer-list to
specify the base classes to initialize.

Reviewed by Richard Smith.

llvm-svn: 148789
2012-01-24 06:03:59 +00:00
David Blaikie 25896afbe5 Support decltype as a simple-type-specifier.
This makes all sorts of fun examples work with decltype.
Reviewed by Richard Smith.

llvm-svn: 148787
2012-01-24 05:47:35 +00:00
Richard Smith efc39b1d71 Add a test for a diagnostic special case added in r148439, as requested by
Francois Pichet.

llvm-svn: 148784
2012-01-24 05:40:50 +00:00
David Blaikie 38d0d295ea Reword/rename -Wswitch-unreachable-default.
Rewording the diagnostic to be more precise/correct: "default label in switch
which covers all enumeration values" and changed the switch to
-Wcovered-switch-default

llvm-svn: 148783
2012-01-24 05:34:08 +00:00
David Blaikie 30feb29915 Improve -Wswitch-enum diagnostic message.
Changing wording to include the word "explicitly" (as in "enumeration value ...
not /explicitly/ handled by switch"), as suggested by Richard Smith.

Also, now that the diagnostic text differs between -Wswitch and -Wswitch-enum,
I've simplified the test cases a bit.

llvm-svn: 148781
2012-01-24 04:56:25 +00:00
David Blaikie 0f2ae78980 Revert various template unreachability code I committed accidentally.
r148774, r148775, r148776, r148777

llvm-svn: 148780
2012-01-24 04:51:48 +00:00
David Blaikie afc6824fa6 More fixes/tests.
llvm-svn: 148777
2012-01-24 04:29:31 +00:00
David Blaikie 13ab2a417d Test for the previous commit/crash.
llvm-svn: 148776
2012-01-24 04:29:27 +00:00
David Blaikie 243a4c46d8 Support undefined dependent bases.
llvm-svn: 148775
2012-01-24 04:29:23 +00:00
David Blaikie 7e625b67e5 Simple hack to do unreachable code analysis on template patterns.
llvm-svn: 148774
2012-01-24 04:29:18 +00:00
Argyrios Kyrtzidis 50cfa12752 Rename Sema::isNullExpr() -> Sema::isSentinelNullExpr() which is more descriptive.
llvm-svn: 148772
2012-01-24 03:13:57 +00:00
Chandler Carruth 7a8c477f2a Make driver tests more resilient to output trees containing symlinks --
the tests are making assertions about the name of the clang binary, so
we should ensure that the name is as stable as possible.

llvm-svn: 148767
2012-01-24 01:55:55 +00:00
Argyrios Kyrtzidis 034e83ca17 In CXXRecordDecl::isCLike(), also check for PODness.
llvm-svn: 148765
2012-01-24 01:37:11 +00:00
Fariborz Jahanian 04c4455dd4 objective-c: Ignore with warning forward class declaration whose name
matches a typedef declaring an object type. // rdar://10733000

llvm-svn: 148760
2012-01-24 00:40:15 +00:00
Akira Hatanaka 377152870b Make sure the integer type used to align the vaarg address is the same as the
type of pointers. 

llvm-svn: 148753
2012-01-23 23:59:52 +00:00
Fariborz Jahanian 586be883ca fixes location of "availability" attribute so warning is displayed at
its line. // rdar://10711037

llvm-svn: 148747
2012-01-23 23:38:32 +00:00
Akira Hatanaka 60f5fe6857 Ignore return type if its size is zero.
llvm-svn: 148744
2012-01-23 23:18:57 +00:00
Bill Wendling ec601f003a Remove extraneous ';'.
llvm-svn: 148739
2012-01-23 22:53:59 +00:00
Sebastian Redl 09edce0400 Minor fixups for auto deduction of initializer lists.
Fix some review comments.
Add a test for deduction when std::initializer_list isn't available yet.
Fix redundant error messages. This fixes and outstanding FIXME too.

llvm-svn: 148735
2012-01-23 22:09:39 +00:00
Argyrios Kyrtzidis 18dc04eba2 [libclang] For:
@implementation I(cat)
suppress subsequent references to 'I'.

rdar://10568103

llvm-svn: 148730
2012-01-23 21:28:38 +00:00
Argyrios Kyrtzidis ba52365ae3 Introduce Sema::isNullExpr() that contains the checks that
Sema::DiagnoseSentinelCalls() does.

llvm-svn: 148722
2012-01-23 20:38:53 +00:00
Kaelyn Uhrain cb7a0406c3 In CorrectTypo, use the cached correction as a starting point instead.
Previously, for unqualified lookups, a positive cache hit is used as the
only non-keyword correction and a negative cache hit immediately returns
an empty TypoCorrection. With the new callback objects, this behavior
causes false negatives by not accounting for the fact that callback
objects alter the set of potential/allowed corrections. The new behavior
is to seed the set of corrections with the cached correction (for
positive hits) to estabilishing a baseline edit distance. Negative cache
hits are only stored or used when either no callback object is provided
or when it returns true for a call to ValidateCandidate with an empty
TypoCorrection (i.e. when ValidateCandidate does not seem to be doing
any checking of the TypoCorrection, such as when an instance of the base
callback class is used solely to specify the set of keywords to be accepted).

llvm-svn: 148720
2012-01-23 20:18:59 +00:00
Kostya Serebryany 8c84d4591d [asan] document the need for -fno-optimize-sibling-calls
llvm-svn: 148716
2012-01-23 18:50:23 +00:00
Bob Wilson 51897ec79b Fix a typo: _MM_FLUSH_ZERO_OFF has the wrong value. rdar://10716672
llvm-svn: 148711
2012-01-23 18:27:24 +00:00
Argyrios Kyrtzidis 5c4e065a9a Introduce CXXRecordDecl::isCLike() that is true if the class is C-like,
without C++-specific features.

Use it to set the language to C++ when indexing non-C-like structs.
rdar://10732579

llvm-svn: 148708
2012-01-23 16:58:45 +00:00
Argyrios Kyrtzidis 7e614d7dce [libclang] Index C++ template specializations, rdar://10732708
llvm-svn: 148707
2012-01-23 16:58:41 +00:00
Argyrios Kyrtzidis 9f777356a3 [libclang] Index namespaces in C++ qualified lookup of members, rdar://10732798
llvm-svn: 148706
2012-01-23 16:58:38 +00:00
Argyrios Kyrtzidis 84bd164862 [libclang] Index C++ constructor initializers, rdar://10732164
llvm-svn: 148705
2012-01-23 16:58:36 +00:00
Argyrios Kyrtzidis abff5f1271 Improve Lexer::getImmediateMacroName to take into account inner macros
of macro arguments.

For "MAC1( MAC2(foo) )" and location of 'foo' token it would return
"MAC1" instead of "MAC2".

llvm-svn: 148704
2012-01-23 16:58:33 +00:00
Douglas Gregor 1cc88a977c Handle pseudo-object expressions (and any other placeholder
expression) when code-completing member access expressions. Fixes
<rdar://problem/10717172>.

llvm-svn: 148703
2012-01-23 15:59:30 +00:00
Douglas Gregor c7ee2013d9 Add -Wnarrowing as an alias for -Wc++11-narrowing, for better GCC
compatibility.

llvm-svn: 148702
2012-01-23 15:52:03 +00:00
Douglas Gregor 84585ab48e Downgrade C++11 narrowing conversion errors to warnings default-mapped
to an error, so that users can turn them off if necessary. Note that
this does *not* change the behavior of in a SFINAE context, where we
still flag an error even if the warning is disabled. This matches
GCC's behavior.

llvm-svn: 148701
2012-01-23 15:29:33 +00:00
Nick Lewycky 1c8c436a85 Add support for -fno-optimize-sibling-calls. Currently only implemented in the
X86 backend in LLVM.

llvm-svn: 148689
2012-01-23 08:29:12 +00:00
Nico Weber 4bc649943f Add a source range to the ms path. Spotted by David Blaikie.
llvm-svn: 148683
2012-01-23 06:08:16 +00:00
Nico Weber 5882927d7a In microsoft mode, downgrade pseudo-destructors on void from error to warning.
This matches cl.exe's behavior and fixes PR11791.

llvm-svn: 148682
2012-01-23 05:50:57 +00:00
David Blaikie aebe36046d Rename -Wswitch-enum-redundant-default to -Wswitch-redundant-default.
This is for consistency, since the flag is actually under -Wswitch now, rather
than -Wswitch-enum (since it's really valuable for the former and rather
orthogonal to the latter)

llvm-svn: 148680
2012-01-23 04:58:54 +00:00
David Blaikie 60ac6382e0 Implement -Wswitch-enum correctly.
Clang previously implemented -Wswitch-enum the same as -Wswitch. This patch
corrects the behavior to match GCC's. The critical/only difference being that
-Wswitch-enum is not silenced by the presence of a default case in the switch.

llvm-svn: 148679
2012-01-23 04:46:12 +00:00
Nico Weber 33a362e0af Convert file from 60% unix 40% dos line endings to 100% unix line endings.
No other changes.

llvm-svn: 148678
2012-01-23 04:08:13 +00:00
Nico Weber 323076f439 Eli says this should check MicrosoftMode instead.
Also change a || that I accidentally changed to && back to ||.

llvm-svn: 148677
2012-01-23 04:01:33 +00:00
Nico Weber 94e746d5e5 In ms mode, a move assignment operator shouldn't mark a copy ctor as deleted.
MSVC2010's pair class has a move assignment operator but no explicit copy
constructor, which makes it unusable without this change.

For symmetry, let move copy constructors not mark the default assignment
operator as deleted either. Both changes match cl.exe's behavior.  Fixes
pr11826.

Also update the standard excerpt to point to the right paragraph.

llvm-svn: 148675
2012-01-23 03:19:29 +00:00
Eli Friedman 844f945963 Make sure the AST correctly represents lvalue-to-rvalue conversions where appropriate.
llvm-svn: 148673
2012-01-23 02:35:22 +00:00
David Blaikie e476f979ca Fix -Wswitch to warn about out of bounds enum cases even when there's a default
For consistency with GCC & reasonable sanity. The FIXME suggests that the
original author was perhaps using the default check for some other purpose,
not realizing the more obvious limitation/false-negatives it creates, but this
doesn't seem to produce any regressions & fixes the included test.

llvm-svn: 148649
2012-01-22 02:31:55 +00:00
David Blaikie 29e7d60880 Move -Wswitch-enum to -Wswitch
This matches GCC's documented (& actual) behavior. What Clang had implemented
as -Wswitch-enum was actually GCC's -Wswitch behavior. -Wswitch is on by
default (part of -Wall) and warns if a switch-over-enum, without a default
case, covers all enum values.

-Wswitch-enum, on the other hand, does not have the default clause and should
fire even in the presence of a default. This warning is off by default.

With this change the -Wswitch-enum flag is off-by-default in Clang but has no
functionality at the moment. I'll add that in a future commit.

llvm-svn: 148648
2012-01-22 01:58:03 +00:00
Francois Pichet 2056a69cb2 In Microsoft Mode, disable the C++11 strict integral conversion rules for enumerator that were introduced with r148439. Otherwise MSVC headers won't compile in C++ 11 mode.
llvm-svn: 148642
2012-01-21 23:26:50 +00:00
David Blaikie 645ae0ce10 Add -Wswitch-enum-redundant-default.
This warning acts as the complement to the main -Wswitch-enum warning (which
warns whenever a switch over enum without a default doesn't cover all values of
 the enum) & has been an an-doc coding convention in LLVM and Clang in my
experience. The purpose is to ensure there's never a "dead" default in a
switch-over-enum because this would hide future -Wswitch-enum errors.

The name warning has a separate flag name so it can be disabled but it's grouped
under -Wswitch-enum & is on-by-default because of this.

The existing violations of this rule in test cases have had the warning disabled
& I've added a specific test for the new behavior (many negative cases already
exist in the same test file - and none regressed - so I didn't add more).

Reviewed by Ted Kremenek ( http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120116/051690.html )

llvm-svn: 148640
2012-01-21 18:12:07 +00:00
NAKAMURA Takumi eb3f454a67 lib/Frontend/InitHeaderSearch.cpp: [Cygwin] Add 4.5.3.
llvm-svn: 148637
2012-01-21 14:46:07 +00:00
NAKAMURA Takumi 44193b732e [Cygwin] Abandon Cygwin-1.5 and g++-3. Use g++-4.3 and higher on Cygwin-1.7.
llvm-svn: 148636
2012-01-21 14:46:01 +00:00
Anna Zaks 97bef5642e [analyzer] It's possible to have a non PointerType expression evaluate to a Loc value. When this happens, use the default type.
llvm-svn: 148631
2012-01-21 06:59:01 +00:00
Bob Wilson 6d69f1a818 Use the new installheaders makefile target in libcxx.
llvm-svn: 148630
2012-01-21 06:25:34 +00:00
Rafael Espindola de15baf1f4 Remove redundant argument.
llvm-svn: 148628
2012-01-21 05:43:40 +00:00
Anna Zaks b7eac9fbef [analyzer] Make VLA checker taint aware.
Also, slightly modify the diagnostic message in ArrayBound and DivZero (still use 'taint', which might not mean much to the user, but plan on changing it later).

llvm-svn: 148626
2012-01-21 05:07:33 +00:00
Eli Friedman 5720e34955 Add an assertion that our use-marking actually covers all uses of a variable. The assertion doesn't cover quite as much as it should, but it's a good start, at least.
llvm-svn: 148625
2012-01-21 04:52:58 +00:00
Eli Friedman 02b5851823 Fix some comments relating to ExpressionEvaluationContexts. Get rid of a couple of uses of ConstantEvaluated which don't make sense.
llvm-svn: 148624
2012-01-21 04:44:06 +00:00
Richard Trieu 0d7305470e Fix code so that a SkipUntil will ignore semicolons when skipping a
function body.  This keeps the brace count accurate to prevent
additional errors.  Also, moved the caret from the brace to the function
name.

Code:
class F{ int Foo{ return 1; } };

Fixed error:
parameters.cc:1:14: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
             ^
1 error generated.

Old errors:
parameters.cc:1:17: error: function definition does not declare parameters
class F{ int Foo{ return 1; } };
                ^
parameters.cc:1:30: error: expected ';' after class
class F{ int Foo{ return 1; } };
                             ^
                             ;
parameters.cc:1:31: error: expected external declaration
class F{ int Foo{ return 1; } };
                              ^
3 errors generated.

llvm-svn: 148621
2012-01-21 02:59:18 +00:00
Anna Zaks a08c6b7efc [analyzer] Unbreak the static analyzer bot. Regression from r148558.
When we build a single source file, we call clang directly (not though scan-build).

llvm-svn: 148612
2012-01-21 01:11:35 +00:00
Eli Friedman d78a5d36d5 Add obvious missing call to MarkDeclarationReferenced.
llvm-svn: 148611
2012-01-21 01:07:00 +00:00
Eli Friedman e0afc98742 Make clang's AST model sizeof and typeof with potentially-evaluated operands correctly, similar to what we already do with typeid.
llvm-svn: 148610
2012-01-21 01:01:51 +00:00
Fariborz Jahanian 1630c15b0f arg migrator: change all "assign" of object properties
to "strong" when migrating from GC. // rdar://10532449

llvm-svn: 148607
2012-01-21 00:43:53 +00:00
Douglas Gregor 3aa55267c4 Fix the code completion string for variadic macros with more than one
argument, which was broken and very ugly (and even had a test case to
make *sure* it was broken and ugly). Fixes <rdar://problem/10609117>.

llvm-svn: 148606
2012-01-21 00:43:38 +00:00
Seth Cantrell a7956f92df add tests for wide character encodings
and fix typo

llvm-svn: 148603
2012-01-21 00:16:11 +00:00
DeLesley Hutchins 68f7b1a647 Handle thread safety attributes on functions with separate definitions and declarations.
llvm-svn: 148599
2012-01-20 23:24:41 +00:00
DeLesley Hutchins 30398dd410 Delayed template instantiation of late-parsed attributes.
llvm-svn: 148595
2012-01-20 22:50:54 +00:00
DeLesley Hutchins ceec3063e2 Instantiate dependent attributes when instantiating templates.
llvm-svn: 148592
2012-01-20 22:37:06 +00:00
Ted Kremenek 9139892728 The 'l' length modifier makes sense with the scanlist conversion specifier.
llvm-svn: 148586
2012-01-20 22:11:52 +00:00
Eric Christopher f3ed1bc8ac Testcase for PR11345.
llvm-svn: 148585
2012-01-20 22:10:18 +00:00
Eric Christopher 45c4d47b8a When adding types to the context chain for record types, just emit
a forward declaration unless we already have a type. We can fill it in
later if it's actually used.

Fixes PR11345

llvm-svn: 148584
2012-01-20 22:10:15 +00:00
Bob Wilson 1052b0c467 Remove unnecessary and incorrect redirection of stderr.
llvm-svn: 148583
2012-01-20 22:01:45 +00:00
Sebastian Pop 422377cfd3 rename -ccc-host-triple into -target
llvm-svn: 148582
2012-01-20 22:01:23 +00:00
Ted Kremenek e7b9d4342b Tighten format string diagnostic and make it a bit clearer (and a bit closer to GCC's).
llvm-svn: 148579
2012-01-20 21:52:58 +00:00
David Blaikie e4d798f078 More dead code removal (using -Wunreachable-code)
llvm-svn: 148577
2012-01-20 21:50:17 +00:00
Ted Kremenek f2a2f5f2bf Add ability to specifiy 'restrict' on parameters of builtins, and correct this oversight for scanf functions.
llvm-svn: 148573
2012-01-20 21:40:12 +00:00
Ted Kremenek 6b33356614 Per PR 11814, use Monospace instead of Andale Mono.
llvm-svn: 148567
2012-01-20 20:39:55 +00:00
Anna Zaks 8298af85a6 [analyzer] Add taint awareness to DivZeroChecker.
llvm-svn: 148566
2012-01-20 20:28:31 +00:00
Fariborz Jahanian 9652adf2af arc migrator: replace "retain" attribute with "strong"
which have same semantics in mrr as well as arr.
// rdar://10688312

llvm-svn: 148559
2012-01-20 19:15:02 +00:00
Anna Zaks 7a75cf32a2 [analyzer] Tweak the buildbot script to include the experimental taint checker and correct the checker enabling setting.
llvm-svn: 148558
2012-01-20 19:10:59 +00:00
Kostya Serebryany ca95aa03f9 use llvm:Attributes instead of unsigned
llvm-svn: 148554
2012-01-20 17:57:16 +00:00
Argyrios Kyrtzidis 85e7671b71 Enhance Lexer::makeFileCharRange to check for ranges inside a macro argument
expansion, in which case it returns a file range in the location where the
argument was spelled.

llvm-svn: 148551
2012-01-20 16:52:43 +00:00
Benjamin Kramer 4d08ccb2d5 Replace a dubious use of SmallVectorImpl with a proper copy.
llvm-svn: 148549
2012-01-20 16:39:18 +00:00
Douglas Gregor d6a58286f5 Fix broken unit test
llvm-svn: 148547
2012-01-20 16:33:00 +00:00
Douglas Gregor 32fbe31246 Extract the (InputKind, std::string) pair used to describe inputs to
the front end into its own class, FrontendInputFile, to make it easier
to introduce new per-input data. No functionality change.

llvm-svn: 148546
2012-01-20 16:28:04 +00:00
Benjamin Kramer 469214426a Localize variable, remove unused assignment.
Found by the clang static analyzer.

llvm-svn: 148544
2012-01-20 14:57:34 +00:00
Benjamin Kramer 1dd48bc76f Remove unused variables.
Found by clang's own static analyzer.

llvm-svn: 148542
2012-01-20 14:42:32 +00:00
Ted Kremenek b9ff6b2302 Reenable DeadStoresChecker under --analyze, and move the IdempotentOperationsChecker to the 'experimental' category. Fixes <rdar://problem/10146347>.
llvm-svn: 148533
2012-01-20 06:00:17 +00:00
Ted Kremenek 89eaf8d531 Implement checker that looks for calls to mktemps and friends that have fewer than 6 Xs. Implements <rdar://problem/6336672>.
llvm-svn: 148531
2012-01-20 05:35:06 +00:00
Ted Kremenek c54dc9515d Turn 'SecuritySyntaxChecker' into a "meta" security checker for insecure APIs. Now
multiple checks are exposed as separate checkers, but CheckerManager only creates
one Checker object.

llvm-svn: 148525
2012-01-20 01:44:29 +00:00
Argyrios Kyrtzidis 908c4dcc5d [libclang] Fix crash when indexing attributes, rdar://10702250.
llvm-svn: 148524
2012-01-20 01:38:51 +00:00
Eli Friedman 456f01833b Remove PotentiallyPotentiallyEvaluated, and replace it with a much simpler and less error-prone way of handling the relevant cases. Towards marking of whether a declaration is used more accurately.
llvm-svn: 148522
2012-01-20 01:26:23 +00:00
Anna Zaks 3b754b25bd [analyzer] Add socket API as a source of taint.
llvm-svn: 148518
2012-01-20 00:11:19 +00:00
Anna Zaks 282dc1437f [analyzer] Skip casts when determining taint dependencies + pretty
printing.

llvm-svn: 148517
2012-01-20 00:11:16 +00:00
Anna Zaks 43de767b55 [analyzer] Add a utility method that allows to find the macro name used
at the given location. 

This could be useful when checkers' logic depends on whether a function
is called with a given macro argument.

llvm-svn: 148516
2012-01-20 00:11:12 +00:00
Anna Zaks 9796f2aa56 [analyzer] Cleanup of Symbol dump methods.
This solves a the issue of crashing gdb when dumping a symbol; +
consistent vitualization.

llvm-svn: 148515
2012-01-20 00:11:08 +00:00
Anna Zaks 03e0651ff3 [analyzer] www: A minor cleanup to the dev manual.
llvm-svn: 148514
2012-01-20 00:11:04 +00:00
Richard Smith ab3fe0f9ba Further testing for instantiation of out-of-line constexpr static data member
template definitions.

llvm-svn: 148506
2012-01-19 22:50:02 +00:00
Richard Smith 45bb45523f An instantiation of a constexpr static data member in a class template is
constexpr.

llvm-svn: 148505
2012-01-19 22:46:17 +00:00
Richard Trieu 4972a6dd08 Extend the error of invalid token after declarations to include fixits for
!=, %=, ^=, &=, *=, -=, |=, /=, <<=, <=, >=, and >>= to =.

llvm-svn: 148499
2012-01-19 22:01:51 +00:00
Benjamin Kramer 704fe866b2 Silence set-but-unused warning.
llvm-svn: 148496
2012-01-19 21:12:23 +00:00
Argyrios Kyrtzidis 7838a2bffb Introduce Lexer::getSourceText() that returns a string for the source
that the given source range encompasses.

llvm-svn: 148481
2012-01-19 15:59:19 +00:00
Argyrios Kyrtzidis a99e02d019 Introduce Lexer::makeFileCharRange() that accepts a token source range
and returns a character range with file locations.

llvm-svn: 148480
2012-01-19 15:59:14 +00:00
Argyrios Kyrtzidis 1b07c344b4 For Lexer's isAt[Start/End]OfMacroExpansion add an out parameter for the macro
start/end location.

It is commonly needed after calling the function; with this way we avoid
recalculating it.

llvm-svn: 148479
2012-01-19 15:59:08 +00:00
Argyrios Kyrtzidis d169911cc0 Add unit testing for Lexer.
llvm-svn: 148478
2012-01-19 15:59:01 +00:00
Evgeniy Stepanov 5dfe9f2b2f Extend unwind.h with the ARM unwinder interface.
These declarations come from the sample code in the
"Exception Handling ABI for the ARM Architecture" document.

llvm-svn: 148469
2012-01-19 11:39:05 +00:00
Tanya Lattner 3dd33b296a A few style changes.
Change CheckVectorLogicalOperands to pass params by ref.
Add another test case.

llvm-svn: 148452
2012-01-19 01:16:16 +00:00
Kaelyn Uhrain edb4acf16b Remove the now-unused CorrectTypoContext enum.
llvm-svn: 148441
2012-01-19 00:33:34 +00:00
Richard Smith f8379a0fc3 constexpr: converted constant expression handling for enumerator values, case
values and non-type template arguments of integral and enumeration types.

This change causes some legal C++98 code to no longer compile in C++11 mode, by
enforcing the C++11 rule that narrowing integral conversions are not permitted
in the final implicit conversion sequence for the above cases.

llvm-svn: 148439
2012-01-18 23:55:52 +00:00
Richard Trieu c64d3230d2 Change the error when a '+=' follows a declaration to suggest a fixit to '=' instead of just suggesting a ';'.
Old error:
plusequaldeclare1.cc:3:8: error: expected ';' at end of declaration
  int x += 6;
       ^
       ;

New error:
plusequaldeclare1.cc:3:9: error: invalid '+=' at end of declaration; did you
      mean '='?
  int x += 6;
        ^~
        =

llvm-svn: 148433
2012-01-18 22:54:52 +00:00
Fariborz Jahanian f9a05d26db Use -Wdeprecated-objc-isa-usage for option to issue
deprecated usage of 'isa'. // rdar://8290002

llvm-svn: 148430
2012-01-18 22:18:30 +00:00
Kaelyn Uhrain b1378408e4 Convert SemaDecl.cpp to pass callback objects to CorrectTypo.
Includes tests highlighting the cases where accuracy has improved
(there is one call that does no filtering beyond selecting the set
of allowed keywords, and one call that only triggers for ObjC code
for which a test by someone who knows ObjC would be welcome). Also
fixes a small typo in one of the suggestion messages, and drops a
malformed "expected-note" for a suggestion that did not occur even
when the malformed note was committed as r145930.

llvm-svn: 148420
2012-01-18 21:41:41 +00:00
Douglas Gregor 4fc9f3e819 Optimize unqualified/global name lookup in modules by introducing a
generational scheme for identifiers that avoids searching the hash
tables of a given module more than once for a given
identifier. Previously, loading any new module invalidated all of the
previous lookup results for all identifiers, causing us to perform the
lookups repeatedly.

llvm-svn: 148412
2012-01-18 20:56:22 +00:00
Anna Zaks 1bea4bf590 Refactor: Pull getImmediateMacroName() out of DiagnosticRenderer and
into Lexer and Preprocessor; making it widely available.

llvm-svn: 148410
2012-01-18 20:17:16 +00:00
Fariborz Jahanian 28324b0066 objc: deprecate direct usage of 'isa' of objc objects
in favor of usage of api's intended for.
// rdar://8290002

llvm-svn: 148404
2012-01-18 19:08:56 +00:00
Douglas Gregor 226173ae93 In the driver, -fmodules enables modules for C/Objective-C but one
also needs -fcxx-modules to enable modules for C++/Objective-C++.

llvm-svn: 148393
2012-01-18 15:19:58 +00:00
Seth Cantrell 6255c257e9 Add and update tests for character literals
llvm-svn: 148392
2012-01-18 12:27:10 +00:00
Seth Cantrell 9c2d6f0279 stop claiming unicode escape sequences are too long in strings, because they never are
llvm-svn: 148391
2012-01-18 12:27:08 +00:00
Seth Cantrell 02f8605974 Fix char literal types in C
L'x' is actually wchar_t

support C11 u and U char literals

llvm-svn: 148390
2012-01-18 12:27:06 +00:00
Seth Cantrell 8b2b677f39 Improves support for Unicode in character literals
Updates ProcessUCNExcape() for C++. C++11 allows UCNs in character
and string literals that represent control characters and basic
source characters. Also C++03 allows UCNs that refer to surrogate
codepoints.

UTF-8 sequences in character literals are now handled as single
c-chars.

Added error for multiple characters in Unicode character literals.

Added errors for when a the execution charset encoding of a c-char
cannot be represented as a single code unit in the associated
character type. Note that for the purposes of this error the asso-
ciated character type for a narrow character literal is char, not
int, even though in C narrow character literals have type int.

llvm-svn: 148389
2012-01-18 12:27:04 +00:00
Seth Cantrell c9196651fc test svn commit access
llvm-svn: 148388
2012-01-18 12:11:32 +00:00
Kaelyn Uhrain 79d01c1760 Convert DiagnoseEmptyLookup to use correction callbacks.
No new unit tests yet as there is no behavioral change
(except for slightly more specific filtering in
Sema::ActOnStartOfLambdaDefinition). Tests will be added
as the code paths are traced in greater depth to determine
how to improve the results--there are at least one or two
known bugs that require those improvements. This commit
lays the groundwork for those changes.

llvm-svn: 148382
2012-01-18 05:58:54 +00:00
Richard Smith 66e05fe630 Move narrowing conversion detection code from SemaInit to SemaOverload, ready
for it to be used in converted constant expression checking, and fix a couple
of issues:
 - Conversion operators implicitly invoked prior to the narrowing conversion
   were not being correctly handled when determining whether a constant value
   was narrowed.
 - For conversions from floating-point to integral types, the diagnostic text
   incorrectly always claimed that the source expression was not a constant
   expression.

llvm-svn: 148381
2012-01-18 05:21:49 +00:00
Nick Lewycky e2367d2508 Add testcase for r148375!
llvm-svn: 148378
2012-01-18 04:28:31 +00:00
Eli Friedman 7bda7f7533 Make PotentiallyPotentiallyEvaluated contexts work correctly when referencing a class field from outside an instance method.
llvm-svn: 148376
2012-01-18 03:53:45 +00:00
Nick Lewycky 9ed5b156a2 Fix a string over-run detected by ASAN.
llvm-svn: 148375
2012-01-18 03:41:19 +00:00
Richard Smith 9cf080fba3 A call to strlen is not a constant expression, even if we're treating it as a
builtin.

llvm-svn: 148374
2012-01-18 03:06:12 +00:00
Eli Friedman 1f4f9ddee8 The value of a case statement is a potentially evaluated context. Found by inspection.
llvm-svn: 148373
2012-01-18 02:54:10 +00:00
Anna Zaks 7f6a6b7507 [analyzer] Refactor: prePropagateTaint ->
TaintPropagationRule::process().

Also remove the "should be a pointer argument" warning - should be
handled elsewhere.

llvm-svn: 148372
2012-01-18 02:45:13 +00:00
Anna Zaks 560dbe9ac9 [analyzer] Taint: warn when tainted data is used to specify a buffer
size (Ex: in malloc, memcpy, strncpy..)

(Maybe some of this could migrate to the CString checker. One issue
with that is that we might want to separate security issues from
regular API misuse.)

llvm-svn: 148371
2012-01-18 02:45:11 +00:00
Anna Zaks 5d324e509c [analyzer] Taint: add taint propagation rules for string and memory copy
functions.

llvm-svn: 148370
2012-01-18 02:45:07 +00:00
Anna Zaks 28db7ceabd Constify FunctionDecl::getmemoryFunctionKind().
llvm-svn: 148369
2012-01-18 02:45:01 +00:00
Nick Lewycky 72cd229398 Fix special king of typo.
llvm-svn: 148368
2012-01-18 01:50:13 +00:00
Eli Friedman fbc0dff6f8 Fix a couple issues where we didn't correctly delay diagnostics in PotentiallyPotentiallyEvaluated contexts. In preparation for making sizeof() PotentiallyPotentiallyEvaluated.
llvm-svn: 148367
2012-01-18 01:05:54 +00:00
Fariborz Jahanian 07b5f4ca03 output body of folded case again.
llvm-svn: 148361
2012-01-17 23:55:19 +00:00
Fariborz Jahanian 9ce39e299d Folding away unreachable case statement.
patch (slightly revised) by Aaron Ballman.

llvm-svn: 148359
2012-01-17 23:39:50 +00:00
Douglas Gregor a95f9aaa84 Make sure to initialize ExternalProtocolPtrTy
llvm-svn: 148358
2012-01-17 23:38:32 +00:00
Fariborz Jahanian c72a807039 objc-arc: when 'assign' attribute is unspecified,
rely on property's type for its life-time to avoid
bogus warning with -Warc-unsafe-retained-assign.
// rdar://10694932

llvm-svn: 148355
2012-01-17 22:58:16 +00:00
Sebastian Redl be24ec22fd Add Sema::isInitListConstructor. This will be needed for upcoming work.
llvm-svn: 148354
2012-01-17 22:50:14 +00:00
Sebastian Redl 42acd4a05b Auto deduction support for std::initializer_list, including for-range support. This means you can now write:
for (int i : {1, 4, 512, 23, 251}) {}

llvm-svn: 148353
2012-01-17 22:50:08 +00:00
Sebastian Redl 43144e72b5 Template argument deduction for std::initializer_list arguments from initializer lists.
llvm-svn: 148352
2012-01-17 22:49:58 +00:00
Sebastian Redl fb0b1f1f1f Rename the first of 11 DeduceTemplateArguments overloads.
There are 5 functions of this name in Sema, and 6 more static helpers in
SemaTemplateDeduction.cpp. The Sema functions have jobs like "deduce for
function call", "deduce for taking the address", etc. The static helpers
have jobs like "deduce by comparing two types", "deduce by comparing two
lists of types", "deduce by comparing two template arguments", etc.
The fact that they all are called the same and only differ in two of their
6 or more arguments makes the code using them very hard to read.

Here I rename the one function that concerns me most at the moment, but
as a matter of cleanup, the others will eventually be renamed as well.

llvm-svn: 148351
2012-01-17 22:49:52 +00:00
Sebastian Redl 10f0fc04a8 Basic overloading support for std::initializer_list.
llvm-svn: 148350
2012-01-17 22:49:48 +00:00
Sebastian Redl c1839b1b09 Sema support for initialization of std::initializer_list from initializer lists.
This does not yet support CodeGen.

llvm-svn: 148349
2012-01-17 22:49:42 +00:00
Sebastian Redl 2bfa104b40 Add Sema::isStdInitializerList, which will be necessary for the upcoming operations.
llvm-svn: 148348
2012-01-17 22:49:33 +00:00
Anton Yartsev 68d773cb3d fix for PR11655
changes i64 alignment from 64 to 32 for powerpc-darwin

llvm-svn: 148345
2012-01-17 22:40:00 +00:00
Bob Wilson 206e2302eb Disable -Wduplicate-method-match by default. <rdar://problem/10663536>
llvm-svn: 148343
2012-01-17 22:24:32 +00:00
Eli Friedman 65499b45f0 Add __builtin_labs and __builtin_llabs, to complete the set of __builtin_*abs. Patch by Ruben Van Boxem.
llvm-svn: 148340
2012-01-17 22:11:30 +00:00
Richard Smith dd5bdd8de7 Remove constant member pointer support from Expr-based constant emission now
that APValue-based constant emission knows how to emit member pointers.

llvm-svn: 148336
2012-01-17 21:42:19 +00:00
Eli Friedman 419b1ff677 Correctly resolve an overload set passed to an overloaded operator=. PR11784.
llvm-svn: 148335
2012-01-17 21:27:43 +00:00
Richard Smith 4ef685becf Enable constant evaluation of implicit calls to constexpr conversion operators.
llvm-svn: 148333
2012-01-17 21:17:26 +00:00
Dan Gohman 5932ce257f Enable the new ObjC ARC autorelease pool elimination pass.
llvm-svn: 148331
2012-01-17 20:54:51 +00:00
John McCall 9701731a3e When initializing a catch variable in ARC, be sure to emit retains
or whatever else is required for the initialization instead of
assuming it can be done with a simple store.

Fixes PR11732.

llvm-svn: 148325
2012-01-17 20:16:56 +00:00
Jean-Daniel Dupas 0ae6e671cc Fix a couples of issues in format strings checking.
PR 10274: format function attribute with the NSString archetype yields no compiler warnings
PR 10275: format function attribute isn't checked in Objective-C methods

llvm-svn: 148324
2012-01-17 20:03:31 +00:00
Douglas Gregor f3bccd77fc Rework the way in which we (de-)serialize the declarations
corresponding to TagType and ObjCInterfaceType. Previously, we would
serialize the definition (if available) or the canonical declaration
(if no definition was available). However, this can end up forcing the
deserialization of the definition even through we might not want to
yet. 

Instead, always serialize the canonical declaration reference in the
TagType/ObjCInterfaceType entry, and as part of loading a pending
definition, update the "decl" pointer within the type node to point at
the definition. This is more robust in hard-to-isolate cases
where the *Type gets built and filled in before we see the definition.

llvm-svn: 148323
2012-01-17 19:21:53 +00:00
Fariborz Jahanian 9d7cf2baaf objc: fixes a bug where struct used inside an
objc class was not being exported to parent decl
context resulting in bogus mismatch warning later on.
// rdar://10655530

llvm-svn: 148320
2012-01-17 18:52:07 +00:00
Argyrios Kyrtzidis da6e05476d [libclang] Make sure Preprocessor is set in ASTUnit during indexing.
llvm-svn: 148319
2012-01-17 18:48:07 +00:00
Douglas Gregor 020de3254a Don't eagerly deserialize the 'Protocol' type when initializing code
generation for Objective-C; it may not be needed.

llvm-svn: 148317
2012-01-17 18:36:30 +00:00
Douglas Gregor 41dc6ff524 When collecting all of the redeclarations of a declaration loaded from
a module file, be sure to also add the first (potentially canonical)
declarations to the chain. This isn't guaranteed to occur because the
first declaration is not listed in the stored redeclaration chain.

llvm-svn: 148314
2012-01-17 18:13:45 +00:00
Douglas Gregor d53ae83516 Delay the creation of the built-in Objective-C class 'Protocol' by
moving it from a "special type" to a predefined declaration, as we do
for id, Class, and SEL.

llvm-svn: 148313
2012-01-17 18:09:05 +00:00
Hans Wennborg 507b567707 Treat -Wformat=0 as an alias for -Wformat.
Fixes PR9195.

llvm-svn: 148300
2012-01-17 09:30:38 +00:00
David Blaikie 60deeee783 Re-add an over-zealously removed break.
llvm-svn: 148296
2012-01-17 08:24:58 +00:00
David Blaikie d72e5c0dac Remove dead comments as per Chandler's feedback to r148292
llvm-svn: 148294
2012-01-17 07:28:46 +00:00
David Blaikie 8a40f700e6 Remove unreachable code in Clang. (replace with llvm_unreachable where appropriate or when GCC requires it)
llvm-svn: 148292
2012-01-17 06:56:22 +00:00
David Blaikie f47fa304a4 Remove unnecessary default cases in switches over enums.
This allows -Wswitch-enum to find switches that need updating when these enums are modified.

llvm-svn: 148281
2012-01-17 02:30:50 +00:00
Argyrios Kyrtzidis 7890821b5b [libclang] Make clang_getCursorCompletionString not depend on the ASTUnit having
a Sema.

This allows it to work when Sema is not available, like when loading AST files.

llvm-svn: 148279
2012-01-17 02:15:54 +00:00
Argyrios Kyrtzidis 8d05ca7dd2 Introduce a CodeCompletionResult::CreateCodeCompletionString() that
does not depend on Sema, it accepts an ASTContext and a Preprocessor.

Step towards making clang_getCursorCompletionString not depend on Sema.

llvm-svn: 148278
2012-01-17 02:15:51 +00:00
Argyrios Kyrtzidis f34950d26a Introduce a static Sema::MarkDeducedTemplateParameters() that only depends
on an ASTContext.

This is a step towards making clang_getCursorCompletionString not depend on Sema.

llvm-svn: 148277
2012-01-17 02:15:41 +00:00
Eli Friedman 05e280156f Revert r148271; this requires more thought.
llvm-svn: 148276
2012-01-17 02:13:45 +00:00
Eli Friedman 4f97786e16 Change the behavior of the lvalue-to-rvalue conversion for varargs in PotentiallyPotentiallyEvaluated contexts so that we model it in a sane way in most cases, and give up for the edge case which hopefully doesn't matter too much.
In preparation for correctly treating sizeof() as a PotentiallyPotentiallyEvaluated context.

llvm-svn: 148271
2012-01-17 01:17:46 +00:00
Nico Weber e1df10a79e Improve diagnostics for dangling '}'.
Fixes PR6484. Patch from Jason Switzer!

llvm-svn: 148270
2012-01-17 01:04:27 +00:00
Anna Zaks 2212270e71 Use Builtin ID as the return value
for FunctionDecl::getMemoryFunctionKind().

This is a follow up on the Chris's review for r148142: We don't want to
pollute FunctionDecl with an extra enum. (To make this work, added
memcmp and family to the library builtins.)

llvm-svn: 148267
2012-01-17 00:37:07 +00:00
Anna Zaks 3666d2c160 [analyzer] Taint: generalize taint propagation to simplify adding more
taint propagation functions.

llvm-svn: 148266
2012-01-17 00:37:02 +00:00
Tanya Lattner 81ce08c983 Add new line.
llvm-svn: 148255
2012-01-16 21:15:33 +00:00
Tanya Lattner 20248226a9 Add support for OpenCL 1.1 logical operations.
llvm-svn: 148254
2012-01-16 21:02:28 +00:00
Eli Friedman 2dfa79325c Add some calls to MarkDeclarationReferenced, towards a point where every declaration which is used is marked as used.
llvm-svn: 148253
2012-01-16 21:00:51 +00:00
Eli Friedman 5ceb74a7d0 Make the auto-detection hack for the iOS simulator set the target triple correctly. Getting the target triple wrong mostly appears to work, but messes up in subtle cases; for example, we incorrectly conclude that fwrite is actually named fwrite$UNIX2003. Also shuffles around the auto-detection code a bit to try and make it a bit more reliable. Fixes <rdar://problem/10664848>.
llvm-svn: 148249
2012-01-16 18:50:54 +00:00
Fariborz Jahanian 1352eea8c9 Another test for 148243
non-constant-folded-switch containing a constant-folded switch.

llvm-svn: 148247
2012-01-16 18:22:26 +00:00
Fariborz Jahanian 7c4dcf4b93 A little more elaborate test for r148243
llvm-svn: 148245
2012-01-16 18:07:45 +00:00
Fariborz Jahanian 60bb82a584 Patch for r148243 which was left behind.
llvm-svn: 148244
2012-01-16 17:52:22 +00:00
Fariborz Jahanian 9c882f98cc Fixes a crash during constant folding of a switch and case
statement which has an unscoped case inside it.
Patch by Aaron Ballman

llvm-svn: 148243
2012-01-16 17:35:57 +00:00
David Chisnall fa35df628a Some improvements to the handling of C11 atomic types:
- Add atomic-to/from-nonatomic cast types
- Emit atomic operations for arithmetic on atomic types
- Emit non-atomic stores for initialisation of atomic types, but atomic stores and loads for every other store / load
- Add a __atomic_init() intrinsic which does a non-atomic store to an _Atomic() type.  This is needed for the corresponding C11 stdatomic.h function.
- Enables the relevant __has_feature() checks.  The feature isn't 100% complete yet, but it's done enough that we want people testing it.

Still to do:

- Make the arithmetic operations on atomic types (e.g. Atomic(int) foo = 1; foo++;) use the correct LLVM intrinsic if one exists, not a loop with a cmpxchg.
- Add a signal fence builtin
- Properly set the fenv state in atomic operations on floating point values
- Correctly handle things like _Atomic(_Complex double) which are too large for an atomic cmpxchg on some platforms (this requires working out what 'correctly' means in this context)
- Fix the many remaining corner cases

llvm-svn: 148242
2012-01-16 17:27:18 +00:00
David Blaikie ca043229c7 Refactor variables unused under non-assert builds.
llvm-svn: 148229
2012-01-16 05:16:03 +00:00
Douglas Gregor 3a5ae564b8 Now that deserializing a definition of a C++ class/Objective-C
class/Objective-C protocol suffices get all of the redeclarations of
that declaration wired to the definition, we no longer need to record
the identity of the definition in every declaration. Instead, just
record a bit to indicate whether a particular declaration is the
definition.

llvm-svn: 148224
2012-01-15 18:17:48 +00:00
Douglas Gregor c03c52ea01 When deserializing the definition of a C++ class/ObjC class/ObjC
protocol, record the definition pointer in the canonical declaration
for that entity, and then propagate that definition pointer from the
canonical declaration to all other deserialized declarations. This
approach works well even when deserializing declarations that didn't
know about the original definition, which can occur with modules.

A nice bonus from this definition-deserialization approach is that we
no longer need update records when a definition is added, because the
redeclaration chains ensure that the if any declaration is loaded, the
definition will also get loaded.

llvm-svn: 148223
2012-01-15 18:08:05 +00:00
Douglas Gregor 358cd44170 Completely re-implement (de-)serialization of redeclaration
chains, again. The prior implementation was very linked-list oriented, and
the list-splicing logic was both fairly convoluted (when loading from
multiple modules) and failed to preserve a reasonable ordering for the
redeclaration chains.

This new implementation uses a simpler strategy, where we store the
ordered redeclaration chains in an array-like structure (indexed based
on the first declaration), and use that ordering to add individual
deserialized declarations to the end of the existing chain. That way,
the chain mimics the ordering from its modules, and a bug somewhere is
far less likely to result in a broken linked list.

llvm-svn: 148222
2012-01-15 16:58:34 +00:00
Benjamin Kramer 83369b3377 Tweak markup.
llvm-svn: 148221
2012-01-15 16:42:14 +00:00
Anton Yartsev e89856784c added descriptions of vector extensions, info about vector literals and vector operations.
llvm-svn: 148220
2012-01-15 16:22:24 +00:00
Benjamin Kramer eaa262b5b8 Fix ALL the markup.
llvm-svn: 148219
2012-01-15 15:26:07 +00:00
Chandler Carruth 5b15a9be6a Two variables had been added for an assert, but their values were
re-computed rather than the variables be re-used just after the assert.
Just use the variables since we have them already. Fixes an unused
variable warning.

Also fix an 80-column violation.

llvm-svn: 148212
2012-01-15 09:03:45 +00:00
Richard Smith bd1530949d decltype(e) is type-dependent if e is instantiation-dependent. Scary but true.
Don't consider decltype(e) for an instantiation-dependent, but not
type-dependent, e to be non-type-dependent but canonical(!).

llvm-svn: 148210
2012-01-15 06:24:57 +00:00
Richard Smith 2ec4061e39 Pedantic diagnostic correction: in C++, we have integral constant expressions,
not integer constant expressions. In passing, fix the 'folding is an extension'
diagnostic to not claim we're accepting the code, since that's not true in
-pedantic-errors mode, and add this diagnostic to -Wgnu.

llvm-svn: 148209
2012-01-15 03:51:30 +00:00
Richard Smith b19ac0d6ca constexpr: casts to void* are allowed in constant expressions, don't set the
designator invalid. (Since we can't read the value of such a pointer, this only
affects the quality of diagnostics.)

llvm-svn: 148208
2012-01-15 03:25:41 +00:00
Eli Friedman 839192fd29 Change linkage computation so it doesn't depend on FunctionDecl::isExternC or VarDecl::isExternC, and instead queries what it actually cares about: whether the given declaration is inside an extern "C" context. Fundamentally, figuring out whether a function/variable uses C linkage requires knowing the linkage, and the logic in FunctionDecl::isExternC and VarDecl::isExternC was getting it wrong. Given that, fix FunctionDecl::isExternC and VarDecl::isExternC to use much simpler implementations that depend on the fixed linkage computation.
Fixes a regression to test/SemaCXX/linkage.cpp caused by a new warning exposing the fact that the internal state was wrong.

llvm-svn: 148207
2012-01-15 01:23:58 +00:00
Benjamin Kramer 490afa6b9d Use a smaller vector than SmallVector.
Shrinks OverloadCandidate from 208 to 168 bytes.

llvm-svn: 148204
2012-01-14 21:05:10 +00:00
Benjamin Kramer 02b0843684 Clear ImplicitConversionSequence the obvious way which turns out to be less fragile.
llvm-svn: 148200
2012-01-14 20:16:52 +00:00
Benjamin Kramer 0b9c509c4e Give OverloadCandidateSet the responsibility for destroying the implicit conversion sequences so we don't get double frees when the vector reallocates.
llvm-svn: 148198
2012-01-14 19:31:39 +00:00
Fariborz Jahanian 52d02f68e5 objc: disallow __block attribute on method params.
llvm-svn: 148197
2012-01-14 18:44:35 +00:00
Benjamin Kramer 9059ff5056 Reorder initializers, make use of the whole array.
llvm-svn: 148193
2012-01-14 17:59:15 +00:00
Benjamin Kramer 1f8f8a3e64 Move the inline array to the end.
llvm-svn: 148192
2012-01-14 17:23:10 +00:00
Benjamin Kramer da765a7322 Destroy OverloadCandidates before taking away the underlying memory.
llvm-svn: 148190
2012-01-14 17:10:59 +00:00
Douglas Gregor aefdb38352 Replace a using declararion with a typedef in the hope of satisfying GCC
llvm-svn: 148188
2012-01-14 16:48:12 +00:00
Douglas Gregor ec9fd13c77 De-virtualize getPreviousDecl() and getMostRecentDecl() when we know
we have a redeclarable type, and only use the new virtual versions
(getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have
that type information. This keeps us from penalizing users with strict
type information (and is the moral equivalent of a "final" method).

Plus, settle on the names getPreviousDecl() and getMostRecentDecl()
throughout.

llvm-svn: 148187
2012-01-14 16:38:05 +00:00
Benjamin Kramer b009517ad4 Pool allocate ImplicitConversionSequences.
To avoid malloc thrashing give OverloadCandidateSet an inline capacity for conversion sequences.
We use the fact that OverloadCandidates never outlive the OverloadCandidateSet and have a fixed
amount of conversion sequences.

This eliminates the oversized SmallVector from OverloadCandidate shrinking it from 752 to 208 bytes.

On the test case from the "Why is CLANG++ so freaking slow" thread on llvmdev this avoids one gig
of vector reallocation (including memcpy) which translates into 5-10% speedup on Lion/x86_64.

Overload candidate computation is still the biggest malloc contributor when compiling templated
c++ code.

llvm-svn: 148186
2012-01-14 16:32:05 +00:00
Benjamin Kramer fb761ff544 OverloadCandidateSet: Stop exposing SmallVector internals
Replace push_back with addCandidate which will let us make use of the fixed size of
the conversion sequence vector soon.

llvm-svn: 148185
2012-01-14 16:31:55 +00:00
Douglas Gregor 0bc8a21dba Introduce Decl::getPreviousDecl() and Decl::getMostRecentDecl(),
virtual functions that provide previous/most recent redeclaration
information for any declaration. Use this to eliminate the redundant,
less efficient getPreviousDecl() functions.

llvm-svn: 148184
2012-01-14 15:55:47 +00:00
Douglas Gregor 9abeca16e5 Revert accidental commit
llvm-svn: 148183
2012-01-14 15:31:52 +00:00
Douglas Gregor 463c8e7070 Add a FIXME for mutation of the common pointer of a RedeclarableTemplateDecl. It is not clear that it's worth delaying the allocation of said pointer
llvm-svn: 148182
2012-01-14 15:30:55 +00:00
Douglas Gregor 68444de354 Reimplement RedeclarableTemplateDecl in terms of
Redeclarable<RedeclarableTemplateDecl>, eliminating a bunch of
redeclaration-chain logic both in RedeclarableTemplateDecl and
especially in its (de-)serialization.

As part of this, eliminate the RedeclarableTemplate<> class template,
which was an abstraction that didn't actually save anything.

llvm-svn: 148181
2012-01-14 15:13:49 +00:00
Zhongxing Xu 82846eae0a Remove a redundant word.
llvm-svn: 148179
2012-01-14 09:08:15 +00:00
Richard Smith dafff94759 constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,
APValue::Array and APValue::MemberPointer. All APValue values can now be emitted
as constants.

Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other
entrypoints dealing with constant member pointers are no longer necessary and
will be removed in a later change.

Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to
VarDecl::evaluateValue. This performs caching and deals with the nasty cases in
C++11 where a non-const object's initializer can refer indirectly to
previously-initialized fields within the same object.

Building the intermediate APValue object incurs a measurable performance hit on
pathological testcases with huge initializer lists, so we continue to build IR
directly from the Expr nodes for array and record types outside of C++11.

llvm-svn: 148178
2012-01-14 04:30:29 +00:00
Anna Zaks 0244cd7450 [analyzer] Taint: add system and popen as undesirable sinks for taint
data.

llvm-svn: 148176
2012-01-14 02:48:40 +00:00
Argyrios Kyrtzidis 9ef9486ab7 [libclang] If CXIndexOpt_IndexFunctionLocalSymbols is enabled, also
index parameters.

llvm-svn: 148169
2012-01-14 02:05:51 +00:00
Rafael Espindola 2f869a3f4f Remember if a type has its visibility set explicitly or implicitly.
With that, centralize the way we merge visibility, always preferring explicit over
implicit and then picking the most restrictive one.
Fixes pr10113 and pr11690.

llvm-svn: 148163
2012-01-14 00:30:36 +00:00
Chad Rosier 1b9c5f1188 Fix 80-column violation.
llvm-svn: 148162
2012-01-14 00:30:11 +00:00
Argyrios Kyrtzidis fb7d1455cd [libclang] Add CXIndexOpt_IndexFunctionLocalSymbols indexing option to indicate
that one wants indexing callbacks for function-local symbols as well.

llvm-svn: 148160
2012-01-14 00:11:49 +00:00
Douglas Gregor 87ea58f5cd (Implicit) parameters deserialized as part of a function type must not
get added to the identifier chains as part of deserialization, because
they should not be visible to name lookup.

llvm-svn: 148159
2012-01-13 23:49:34 +00:00
Eli Friedman c09e0557a5 Progress towards making isUsed() reflect whether a declaration is odr-used; don't set isUsed for local variables which are referenced in unevaluated contexts. Make other code use isReferenced() (which basically indicates that a declaration isn't dead) where appropriate.
I was forced to change test/SemaCXX/linkage.cpp because we aren't actually modeling extern "C" in the AST the way that testcase expects; we were not printing a warning only because we skipped the relevant check.  Someone who actually understands the semantics here should fix that.

llvm-svn: 148158
2012-01-13 23:41:25 +00:00
Eli Friedman 1c29e7297a Fix a silly mistake in ComplexExprEvaluator::ZeroInitialization. <rdar://problem/10691092>.
llvm-svn: 148157
2012-01-13 23:34:56 +00:00
Kaelyn Uhrain 637b5b3235 Convert SemaTemplate*.cpp to pass a callback object to CorrectTypo.
The change to SemaTemplateVariadic.cpp improves the typo correction
results in certain situations, while the change to SemaTemplate.cpp
does not change existing behavior.

llvm-svn: 148155
2012-01-13 23:10:36 +00:00
Douglas Gregor 81bd038623 Make sure to consider non-DeclContext scopes properly when finding
multiple name lookup results in C/Objective-C. Fixes a regression a
caused in r147533, found by Enea Zaffanella!

llvm-svn: 148154
2012-01-13 23:06:53 +00:00
Douglas Gregor 3a5999bc1c When inferring a module for a framework, first determine whether that
framework is actually a subframework within a top-level framework. If
so, only infer a module for the top-level framework and then dig out
the appropriate submodule.

This helps us cope with an amusing subframeworks anti-pattern, where
one uses -F <framework>/Frameworks to get direct include access to the
subframeworks of a framework (which otherwise would not be
permitted).

llvm-svn: 148148
2012-01-13 22:31:52 +00:00
Anna Zaks 201d489cb8 Move identification of memory setting and copying functions (memset,
memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic
could be reused in the analyzer.

llvm-svn: 148142
2012-01-13 21:52:01 +00:00
Eli Friedman d749c6bf2e Revert r148138; it's causing test failures.
llvm-svn: 148141
2012-01-13 21:33:06 +00:00