Commit Graph

44003 Commits

Author SHA1 Message Date
David Chisnall 168a15188e Remove unused check from test.
llvm-svn: 176422
2013-03-03 17:50:06 +00:00
Sean Silva d4ac85d21a [docs] Spelling
llvm-svn: 176421
2013-03-03 17:07:35 +00:00
David Chisnall ef78c305fa Improve C11 atomics support:
- Generate atomicrmw operations in most of the cases when it's sensible to do
  so.
- Don't crash in several common cases (and hopefully don't crash in more of
  them).
- Add some better tests.

We now generate significantly better code for things like:
_Atomic(int) x;
...
x++;

On MIPS, this now generates a 4-instruction ll/sc loop, where previously it
generated about 30 instructions in two nested loops.  On x86-64, we generate a
single lock incl, instead of a lock cmpxchgl loop (one instruction instead of
ten).

llvm-svn: 176420
2013-03-03 16:02:42 +00:00
David Chisnall e0a5c0d914 Default to enabling default-synthesized ivars on all platforms
llvm-svn: 176419
2013-03-03 15:36:10 +00:00
Sean Silva edd5ca5a36 [docs] Use vim code-block instead of console.
llvm-svn: 176418
2013-03-03 15:17:35 +00:00
Rafael Espindola de6a39f759 Process #pragma weak only after we know the linkage of the function or variable
we are looking at.

llvm-svn: 176414
2013-03-02 21:41:48 +00:00
Peter Collingbourne fe7a348614 CommandLineArgumentParser: handle single quotes.
Differential Revision: http://llvm-reviews.chandlerc.com/D482

llvm-svn: 176404
2013-03-02 06:00:16 +00:00
Anna Zaks 8d7c8a4dd6 [analyzer] Simple inline defensive checks suppression
Inlining brought a few "null pointer use" false positives, which occur because
the callee defensively checks if a pointer is NULL, whereas the caller knows
that the pointer cannot be NULL in the context of the given call.

This is a first attempt to silence these warnings by tracking the symbolic value
along the execution path in the BugReporter. The new visitor finds the node
in which the symbol was first constrained to NULL. If the node belongs to
a function on the active stack, the warning is reported, otherwise, it is
suppressed.

There are several areas for follow up work, for example:
 - How do we differentiate the cases where the first check is followed by
another one, which does happen on the active stack?

Also, this only silences a fraction of null pointer use warnings. For example, it
does not do anything for the cases where NULL was assigned inside a callee.

llvm-svn: 176402
2013-03-02 03:20:52 +00:00
Fariborz Jahanian e400cb70d4 Some refactoring in my patch on document
command source fidelity. // rdar://13066276

llvm-svn: 176401
2013-03-02 02:39:57 +00:00
Peter Collingbourne 2ee0b630dc LLVM API changes.
llvm-svn: 176398
2013-03-02 01:20:22 +00:00
Jordan Rose bd804e9d6a CMake: -Wno-nested-anon-types for Clang.
In LLVM, -pedantic is not set unless LLVM_ENABLE_PEDANTIC is set.
However, Clang's CMakeLists.txt unilaterally adds -pedantic to the run
line, so we need to disable -Wnested-anon-types explicitly.

llvm-svn: 176393
2013-03-02 00:49:47 +00:00
Jordan Rose 687d1d33f4 [analyzer] Update open source checker build to checker-272.
See http://clang-analyzer.llvm.org/release_notes.html for what's new
in this build.

llvm-svn: 176389
2013-03-01 23:26:05 +00:00
Jordan Rose e185d73101 [analyzer] Special-case bitfields when finding sub-region bindings.
Previously we were assuming that we'd never ask for the sub-region bindings
of a bitfield, since a bitfield cannot have subregions. However,
unification of code paths has made that assumption invalid. While we could
take advantage of this by just checking for the single possible binding,
it's probably better to do the right thing, so that if/when we someday
support unions we'll do the right thing there, too.

This fixes a handful of false positives in analyzing LLVM.

<rdar://problem/13325522>

llvm-svn: 176388
2013-03-01 23:03:17 +00:00
Fariborz Jahanian d49963609d comment parsing. Keep the original command format
in AST for source fidelity and use it in diagnostics 
to refer to the original format. // rdar://13066276

llvm-svn: 176387
2013-03-01 22:51:30 +00:00
Stefanus Du Toit b331850194 Fix typos: [Dd]iagnosic -> [Dd]iagnostic
These all appear in comments or (ironically) diagnostics output.

llvm-svn: 176383
2013-03-01 21:41:22 +00:00
Jordan Rose 801916baf1 [analyzer] Suppress paths involving a reference whose rvalue is null.
Most map types have an operator[] that inserts a new element if the key
isn't found, then returns a reference to the value slot so that you can
assign into it. However, if the value type is a pointer, it will be
initialized to null. This is usually no problem.

However, if the user /knows/ the map contains a value for a particular key,
they may just use it immediately:

   // From ClangSACheckersEmitter.cpp
   recordGroupMap[group]->Checkers

In this case the analyzer reports a null dereference on the path where the
key is not in the map, even though the user knows that path is impossible
here. They could silence the warning by adding an assertion, but that means
splitting up the expression and introducing a local variable. (Note that
the analyzer has no way of knowing that recordGroupMap[group] will return
the same reference if called twice in a row!)

We already have logic that says a null dereference has a high chance of
being a false positive if the null came from an inlined function. This
patch simply extends that to references whose rvalues are null as well,
silencing several false positives in LLVM.

<rdar://problem/13239854>

llvm-svn: 176371
2013-03-01 19:45:10 +00:00
Daniel Jasper a79064a88f Remove whitespace at end of file.
This fixes the rest of llvm.org/PR15062.

llvm-svn: 176361
2013-03-01 18:11:39 +00:00
Daniel Jasper 8eb371b3cc Correctly format arrays of pointers and function types.
Before:
void f(Type(*parameter)[10]) {}
int(*func)(void *);

After:
void f(Type (*parameter)[10]) {}
int (*func)(void *);

llvm-svn: 176356
2013-03-01 17:13:29 +00:00
Argyrios Kyrtzidis 7c9ba11747 [PCH] Remove building a SmallPtrSet that is not actually used for anything.
llvm-svn: 176354
2013-03-01 17:01:31 +00:00
Daniel Jasper f9a84b5f57 Normal indent for last element of builder-type call.
In builder type call, we indent to the laster function calls.
However, for the last element of such a call, we don't need to do
so, as that normally just wastes space and does not increase
readability.

Before:
aaaaaa->aaaaaa->aaaaaa( // break
                  aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa
    ->aaaaaaaaaaaaaaaaaaaaaaaaaa(
        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
aaaaaa->aaaaaa->aaaaaa( // break
    aaaaaa);
aaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaa->aaaaaaaaaaaaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 176352
2013-03-01 16:48:32 +00:00
Daniel Jasper 3324cbefcd Remove trailing whitespace of line comments.
This fixed llvm.org/PR15378.

llvm-svn: 176351
2013-03-01 16:45:59 +00:00
Manuel Klimek e317d1b1e8 Implements breaking string literals at slashes.
We now break at a slash if we do not find a space to break on.

Also fixes a bug where we would go over the limit when breaking the
second line.

llvm-svn: 176350
2013-03-01 13:29:19 +00:00
Manuel Klimek b176cff89d Implement fallback split point for string literals.
If we don't find a natural split point (currently space) in a string
literal protruding over the line, we just split at the last possible
point.

llvm-svn: 176349
2013-03-01 13:14:08 +00:00
John McCall 80c93a0793 Perform the receiver-expression transformations regardless of
whether we already have a method.  Fixes a bug where we were
failing to properly contextually convert a message receiver
during template instantiation.

As a side-effect, we now actually perform correct method lookup
after adjusting a message-send to integral or non-ObjC pointer
types (legal outside of ARC).

rdar://13305374

llvm-svn: 176339
2013-03-01 09:20:14 +00:00
John McCall 73fc0385de Attempt to not place ownership qualifiers on the result type
of block declarators.  Document the rule we use.

Also document the rule that Doug implemented a few weeks ago
which drops ownership qualifiers on function result types.

rdar://10127067

llvm-svn: 176336
2013-03-01 07:58:16 +00:00
Anna Zaks 4a8a015f13 [analyzer] Reword FAQ
Reword the FAQ to stress more that the assert should be used only in case
the developer is sure that the issue is a false positive.

llvm-svn: 176335
2013-03-01 06:38:16 +00:00
Argyrios Kyrtzidis 1ca7344506 Add one more sanity check in SourceManager::getFileIDLoaded().
llvm-svn: 176333
2013-03-01 03:43:33 +00:00
Argyrios Kyrtzidis 61c3d8778c [PCH] Enhance InputFile to also include whether the file is out-of-date.
Previously we would return null for an out-of-date file. This inhibited ASTReader::ReadSLocEntry
from creating a FileID to recover gracefully in such a case.

llvm-svn: 176332
2013-03-01 03:26:04 +00:00
Argyrios Kyrtzidis 7dc4f33c77 In SourceManager::getFileIDLoaded(), add some sanity checks to make sure we don't enter an infinite loop.
rdar://13120919

llvm-svn: 176331
2013-03-01 03:26:00 +00:00
John McCall e739a49325 Restore order to placate test. I had no real reason to switch them.
llvm-svn: 176328
2013-03-01 01:38:54 +00:00
John McCall 07e60263dd Re-use bit from superclass and extract stuff into a local
function.  Serves a patch we're kicking around out-of-tree.

llvm-svn: 176327
2013-03-01 01:24:35 +00:00
Fariborz Jahanian a1b9b3f599 Fix warning text of my last patch.
// rdar://13158394

llvm-svn: 176308
2013-02-28 23:16:39 +00:00
Bill Wendling 706469b453 Add more of the command line options as attribute flags.
These can be easily queried by the back-end.

llvm-svn: 176304
2013-02-28 22:49:57 +00:00
Fariborz Jahanian d838bba59b objective-C: clang, following gcc, warns on
use of stand-alone protocol as type and uses
id<proto>. Modify warning to say what compiler 
is doing. // rdar//13158394

llvm-svn: 176303
2013-02-28 22:36:31 +00:00
John McCall 882987f30c Use the actual ABI-determined C calling convention for runtime
calls and declarations.

LLVM has a default CC determined by the target triple.  This is
not always the actual default CC for the ABI we've been asked to
target, and so we sometimes find ourselves annotating all user
functions with an explicit calling convention.  Since these
calling conventions usually agree for the simple set of argument
types passed to most runtime functions, using the LLVM-default CC
in principle has no effect.  However, the LLVM optimizer goes
into histrionics if it sees this kind of formal CC mismatch,
since it has no concept of CC compatibility.  Therefore, if this
module happens to define the "runtime" function, or got LTO'ed
with such a definition, we can miscompile;  so it's quite
important to get this right.

Defining runtime functions locally is quite common in embedded
applications.

llvm-svn: 176286
2013-02-28 19:01:20 +00:00
Hans Wennborg c32d513385 ClangFormat.rst: Fix two small typos
llvm-svn: 176276
2013-02-28 18:16:24 +00:00
Manuel Klimek bd5ac98277 Fix a problem where 'clang' is ambiguous in MSVC builds.
llvm-svn: 176275
2013-02-28 18:12:44 +00:00
Fariborz Jahanian 07cde21584 Add comment to my last test.
llvm-svn: 176272
2013-02-28 18:03:28 +00:00
Fariborz Jahanian 15a0b55c97 objective-C code completion. Property accessors may not
have their own code completion comments. Use those in 
their properties in this case. 
// rdar://12791315

llvm-svn: 176271
2013-02-28 17:47:14 +00:00
Daniel Jasper a400cab43a Reduce penalty for splitting after "{" in static initializers.
This fixes llvm.org/PR15379.

Before:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = { 0x00, 0x00, 0x00, 0x00, 0x00,
                                            0x00,                  // comment
                                            0x00, 0x00, 0x00, 0x00, 0x00,
                                            0x00,                  // comment
                                            0x00, 0x00, 0x00, 0x00 // comment
};

After:
const uint8_t aaaaaaaaaaaaaaaaaaaaaa[0] = {
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // comment
  0x00, 0x00, 0x00, 0x00              // comment
};

llvm-svn: 176262
2013-02-28 15:04:12 +00:00
Daniel Jasper 9a23be7451 Dont break between (( in __attribute__((.
Before:
void aaaaaaaaaaaaaaaaaa() __attribute__(
    (aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
     aaaaaaaaaaaaaaaaaaaaaaaaa));

After:
void aaaaaaaaaaaaaaaaaa()
    __attribute__((aaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaa,
                   aaaaaaaaaaaaaaaaaaaaaaaaa));

llvm-svn: 176260
2013-02-28 14:44:25 +00:00
David Chisnall beb8013095 Improve property metadata generation with the GNUstep runtime.
llvm-svn: 176254
2013-02-28 13:59:29 +00:00
Daniel Jasper ff6c3a9525 No spaces around pointers to members.
Before: (a ->* f)()
After:  (a->*f)()
llvm-svn: 176252
2013-02-28 13:40:17 +00:00
Manuel Klimek d4be4084b4 First step towards adding a parent map to the ASTContext.
This does not yet implement the LimitNode approach discussed.

The impact of this is an O(n) in the number of nodes in the AST
reduction of complexity for certain kinds of matchers (as otherwise the
parent map gets recreated for every new MatchFinder).

See FIXMEs in the comments for the direction of future work.

llvm-svn: 176251
2013-02-28 13:21:39 +00:00
Daniel Jasper c22f5b4abb Improve formatting of #defines.
Two improvements:
1) Always leave at least one space before "\". Otherwise is can look bad
   and there is a risk of unwillingly joining to characters to a different
   token.
2) Use the full column limit for single-line #defines.
   Fixes llvm.org/PR15148

llvm-svn: 176245
2013-02-28 11:05:57 +00:00
Daniel Jasper 57d4a5821d Fix bug when formatting "A<A<A>>".
Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
                     int aaaaaaaaaaaaaaaaaaaaaaa);
Before:
A<A<A>> ReadKansas(int aaaaaaaaaaaaaaaaaaaaaaaaaaa,
                   int aaaaaaaaaaaaaaaaaaaaaaa);

llvm-svn: 176244
2013-02-28 10:06:05 +00:00
Daniel Jasper ead41b6b8f Fix incorrect recognition of bin-packing.
Before (in Google style):
Constructor()
    : aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(aaaaaa), aaaaa(
          aaaaaa) {}

After:
Constructor()
    : aaaaa(aaaaaa),
      aaaaa(aaaaaa),
      aaaaa(aaaaaa),
      aaaaa(aaaaaa),
      aaaaa(aaaaaa) {}

llvm-svn: 176242
2013-02-28 09:39:12 +00:00
Daniel Jasper d8ffcfa9b8 Fix spacing after binary operator as macro parameter.
Before: COMPARE(a, == , b);
After:  COMPARE(a, ==, b);
llvm-svn: 176241
2013-02-28 09:21:10 +00:00
Evgeniy Stepanov 00eef441ff Fix global overflow in types::lookupTypeForTypeSpecifier.
memcpy() is allowed to read entire contents of both memory areas.

Found with AddressSanitizer.

llvm-svn: 176237
2013-02-28 07:53:32 +00:00
Jordan Rose a22cd706a2 [analyzer] RegionStore: collectSubRegionKeys -> collectSubRegionBindings
By returning the (key, value) binding pairs, we save lookups afterwards.
This also enables further work later on.

No functionality change.

llvm-svn: 176230
2013-02-28 01:53:08 +00:00
Jordan Rose 4879e49c8e [analyzer] Mark the root SVal class as isPodLike.
Pure optimization, no functionality change. Probably does not make much
of a difference, but it's free.

llvm-svn: 176229
2013-02-28 01:53:03 +00:00
Argyrios Kyrtzidis 397ef40f6b Add a test case, to make sure there is no crash on IRGen when using PCH
Related to rdar://13114142

llvm-svn: 176227
2013-02-28 01:13:53 +00:00
Renato Golin 05bbce70dd Avoiding flamewars
llvm-svn: 176221
2013-02-27 23:21:44 +00:00
David Blaikie dc601e3a09 PR15360: nullptr as a non-type template argument to a function type non-type template parameter
llvm-svn: 176216
2013-02-27 22:10:40 +00:00
David Blaikie a985542ae0 Add test coverage for array to pointer decay in non-type template parameters.
Functionality committed in r172585 but tested the function case without the
array case.

llvm-svn: 176215
2013-02-27 22:10:37 +00:00
Renato Golin 4890582f2a Add config manager to open projects
llvm-svn: 176211
2013-02-27 21:28:29 +00:00
Jordan Rose 2c377feacb [analyzer] Fix test for previous commit.
llvm-svn: 176202
2013-02-27 18:57:20 +00:00
Jordan Rose f7f32d5202 [analyzer] Teach FindLastStoreBRVisitor to understand stores of the same value.
Consider this case:

  int *p = 0;
  p = getPointerThatMayBeNull();
  *p = 1;

If we inline 'getPointerThatMayBeNull', we might know that the value of 'p'
is NULL, and thus emit a null pointer dereference report. However, we
usually want to suppress such warnings as error paths, and we do so by using
FindLastStoreBRVisitor to see where the NULL came from. In this case, though,
because 'p' was NULL both before and after the assignment, the visitor
would decide that the "last store" was the initialization, not the
re-assignment.

This commit changes FindLastStoreBRVisitor to consider all PostStore nodes
that assign to this region. This still won't catches changes made directly
by checkers if they re-assign the same value, but it does handle the common
case in user-written code and will trigger ReturnVisitor's suppression
machinery as expected.

<rdar://problem/13299738>

llvm-svn: 176201
2013-02-27 18:49:57 +00:00
Jordan Rose 4587b28758 [analyzer] Turn on C++ constructor inlining by default.
This enables constructor inlining for types with non-trivial destructors.
The plan is to enable destructor inlining within the next month, but that
needs further verification.

<rdar://problem/12295329>

llvm-svn: 176200
2013-02-27 18:49:43 +00:00
Chad Rosier 6a1de5c634 [driver] The failure of any phase (e.g., preprocess, compile, assemble) for a
single translation unit should prevent later phases from executing.  Otherwise,
this generates lots of noise in build systems.  This a fallout from r173825.
Patch by Matthew Curtis <mcurtis@codeaurora.org>.
rdar://13298009

llvm-svn: 176198
2013-02-27 18:46:04 +00:00
Simon Atanasyan 0da400cf92 [Mips] Add two new aliases for MIPS ABI names 32 (means o32 abi) and 64
(means n64 abi) to improve compatibility with GNU tools.
Patch by Jia Liu <proljc@gmail.com>.

llvm-svn: 176187
2013-02-27 14:55:49 +00:00
Timur Iskhodzhanov 57cbe5c790 Better support for constructors with -cxx-abi microsoft, partly fixes PR12784
llvm-svn: 176186
2013-02-27 13:46:31 +00:00
Manuel Klimek 59b0af6381 Make the negative test of recordType depend on a specific record.
Otherwise it'll break if there's a record type in the AST by default.

llvm-svn: 176181
2013-02-27 11:56:58 +00:00
Daniel Jasper 8e55927153 Fix formatting of multiplications in array subscripts.
Before:
a[a* a] = 1;

After:
a[a * a] = 1;

llvm-svn: 176180
2013-02-27 11:43:50 +00:00
Alexey Samsonov bfb0cd355f [Sanitizer] Change driver behavior when linking with -fsanitize=thread and -fsanitize=memory. TSan/MSan also provide their versions of new/delete and should use the same strategy as ASan. Share the code that sets linker flags for all sanitizers.
llvm-svn: 176178
2013-02-27 11:14:55 +00:00
Daniel Jasper 2cf17bfcc1 Enable bin-packing in Google style.
After some discussions, it seems that this is the better path in
the long run. Does not change Chromium style, as there, bin packing
is forbidden by the style guide.

Also fix two minor bugs wrt. formatting:
1. If a call parameter is a function call itself and is split before
   the "." or "->", split before the next parameter.
2. If a call parameter is string literal that has to be split onto
   two lines, split before the next parameter.

llvm-svn: 176177
2013-02-27 09:47:53 +00:00
Nick Lewycky a0076cdbb2 Update clang for LLVM API change. No functionality change.
llvm-svn: 176174
2013-02-27 06:22:58 +00:00
Rafael Espindola 679eb4062b Don't cache the visibility of types.
Since r175326 an implicitly hidden template argument can cause a template
installation to become hidden, even if the template itself has an explicit
default visibility. This requires that we keep track of "late" additions
of the visibility attribute.

This is hopefully the last followup change. It just removes the caching of
visibilities from types so that we can see new attributes even after a type has
been used.

llvm-svn: 176164
2013-02-27 04:15:01 +00:00
Lang Hames 1694e0d21d Use the correct alignment for POD-member memcpys where the first field is a
bitfield. CGBitField::StorageAlignment holds the alignment in chars, but
emitMemcpy had been treating it as if it were held in bits, leading to
underaligned memcpys.

Related to PR15348.

Thanks very much to Chandler for the diagnosis.

llvm-svn: 176163
2013-02-27 04:14:49 +00:00
Rafael Espindola 4a5da44b34 Rename methods to comply with the LLVM Coding Standards.
llvm-svn: 176159
2013-02-27 02:56:45 +00:00
Rafael Espindola 6fbfafeddc Change Type::getLinkageAndVisibility to return a LinkageInfo.
llvm-svn: 176157
2013-02-27 02:27:19 +00:00
Rafael Espindola a8fbdab850 Move LinkageInfo out of NamedDecl so that it can be used in Type.h.
Everything that cares about visibility also cares about linkage, so I just
moved it to Visibility.h instead of creating a new .h.

llvm-svn: 176155
2013-02-27 02:15:29 +00:00
Richard Trieu 954aaaf76b Update template diffing to handle template arguments that are declarations.
llvm-svn: 176153
2013-02-27 01:41:53 +00:00
Argyrios Kyrtzidis f77453cf22 Add a test to make sure __has_include works from inside a macro.
llvm-svn: 176152
2013-02-27 01:34:48 +00:00
Adrian Prantl 68a5750d5d Temporarily revert r176116 for compile-time performance regression.
This reverts commit ea95e4587fd13606fbf63b10a07a7d02026aa39c.

llvm-svn: 176151
2013-02-27 01:31:55 +00:00
Ted Kremenek f352d8c7ec [analyzer] Add stop-gap patch to prevent assertion failure when analyzing LLVM codebase.
This potentially reduces a performance optimization of throwing away
PreStmtPurgeDeadSymbols nodes.  I'll investigate the performance impact
soon and see if we need something better.

llvm-svn: 176149
2013-02-27 01:26:58 +00:00
Argyrios Kyrtzidis ddee8c9e2b [PCH] When deserializing an IdentifierInfo, call IdentifierInfo::RevertTokenIDToIdentifier() only when it's not already an identifier.
Fixes an assertion hit.
rdar://13288735

llvm-svn: 176148
2013-02-27 01:13:51 +00:00
Fariborz Jahanian 81bbee1ed8 comment parsing: Properties are considered like methods, and people
think of them as having return values that may be computed. Don't
warn when using @return in their comment. // rdar://13189938

llvm-svn: 176147
2013-02-27 00:46:06 +00:00
John McCall d010ac9a48 Don't crash when diagnosing path-constrained protected
access to a private member to which we have special access.

rdar://12926092

llvm-svn: 176146
2013-02-27 00:08:19 +00:00
Bill Wendling 2386bb130c Reapply r176133 with testcase fixes.
llvm-svn: 176145
2013-02-27 00:06:04 +00:00
Jordan Rose 4a7bf49bd4 [analyzer] If a struct has a partial lazy binding, its fields aren't Undef.
This is essentially the same problem as r174031: a lazy binding for the first
field of a struct may stomp on an existing default binding for the
entire struct. Because of the way RegionStore is set up, we can't help
but lose the top-level binding, but then we need to make sure that accessing
one of the other fields doesn't come back as Undefined.

In this case, RegionStore is now correctly detecting that the lazy binding
we have isn't the right type, but then failing to follow through on the
implications of that: we don't know anything about the other fields in the
aggregate. This fix adds a test when searching for other kinds of default
values to see if there's a lazy binding we rejected, and if so returns
a symbolic value instead of Undefined.

The long-term fix for this is probably a new Store model; see
<rdar://problem/12701038>.

Fixes <rdar://problem/13292559>.

llvm-svn: 176144
2013-02-27 00:05:29 +00:00
Ted Kremenek 08037045f8 Refine SourceManager's isBeforeInTranslationUnit() cache to have more entries.
isBeforeInTranslationUnit() uses a cache to reduce the expensive work
to compute a common ancestor for two FileIDs.  This work is very
expensive, so even caching the latest used FileIDs was a big win.
A closer analysis of the cache before, however, shows that the cache
access pattern would oscillate between a working set of FileIDs, and
thus caching more pairs would be profitable.

This patch adds a side table for extending caching.  This side table
is bounded in size (experimentally determined in this case from
a simple Objective-C project), and when the table gets too large
we fall back to the single entry caching before as before.

On Sketch (a small example Objective-C project), this optimization
reduces -fsyntax-only time on SKTGraphicView.m by 5%.  This is
for a project that is already using PCH.

Fixes <rdar://problem/13299847>

llvm-svn: 176142
2013-02-27 00:00:26 +00:00
Rafael Espindola 5718459767 Use existing macros to simplify the test a bit.
llvm-svn: 176138
2013-02-26 23:24:59 +00:00
Bill Wendling 0120ee792c Temporarily revert r176133 until testcases are modified.
llvm-svn: 176137
2013-02-26 23:18:33 +00:00
Bill Wendling d02fd83182 Fix testcases to not rely upon target-* attributes.
llvm-svn: 176135
2013-02-26 23:08:48 +00:00
Bill Wendling fdfd70a00c Don't set the -target-cpu and -target-features attributes just now.
This is causing some problems with some of the builders. It's non-trivial to
reset the target's features.

llvm-svn: 176133
2013-02-26 23:01:33 +00:00
Chad Rosier 05e35566c8 No need to initialize these variables.
llvm-svn: 176128
2013-02-26 22:15:50 +00:00
Fariborz Jahanian 828b8d2415 doxygen command. Add 'attention' command to list of similar
doxygen commands. // rdar://12379053

llvm-svn: 176127
2013-02-26 22:12:16 +00:00
Matt Arsenault 376f72092c Fix assertion failure when a field is given an address space.
llvm-svn: 176122
2013-02-26 21:16:00 +00:00
Matt Arsenault 7d36c01747 Fix initializer for variables with attribute address_space set.
This would error in C++ mode unless the variable also had a cv
qualifier.

e.g.

__attribute__((address_space(2))) float foo = 1.0f; would error but
__attribute__((address_space(2))) const float foo = 1.0f; would not.

llvm-svn: 176121
2013-02-26 21:15:54 +00:00
Adrian Prantl 71510db7bc Ensure that DIType is regenerated after we visited an implementation that adds ivars to an interface. Fixes rdar://13175234
llvm-svn: 176116
2013-02-26 20:01:46 +00:00
Ted Kremenek 37c777ecc0 [analyzer] Use 'MemRegion::printPretty()' instead of assuming the region is a VarRegion.
Fixes PR15358 and <rdar://problem/13295437>.

Along the way, shorten path diagnostics that say "Variable 'x'" to just
be "'x'".  By the context, it is obvious that we have a variable,
and so this just consumes text space.

llvm-svn: 176115
2013-02-26 19:44:38 +00:00
Matt Beaumont-Gay 1c417da558 Warn on dropping the return value from a warn_unused_result function, even in
macros.

llvm-svn: 176114
2013-02-26 19:34:08 +00:00
Rafael Espindola 3a52c44865 Use the most recent decl in getExplicitVisibility.
Now that implicitly hidden template arguments can make an instantiation hidden,
it is important to look at more than just the canonical decl of the argument
in order to see if an attribute is available in a more recent decl.

This has the disadvantage of exposing when getExplicitVisibility is called,
but lets us handle cases like

template <typename T>
struct __attribute__((visibility("default"))) barT {
  static void zed() {}
};
class foo;
class __attribute__((visibility("default"))) foo;
template struct barT<foo>;

llvm-svn: 176112
2013-02-26 19:33:14 +00:00
Rafael Espindola db77c4ae13 Be more careful in applying pragma weak. Fixes pr14974.
GCC applies a pragma weak to a decl if it matches the mangled name. We used
to apply if it matched the plain name.

This patch is a compromise: we apply the pragma only if it matches the name
and the decl has C language linkage.

llvm-svn: 176110
2013-02-26 19:13:56 +00:00
Daniel Jasper 70bc87420a Fix bad line break decision.
Before:
if (Intervals[i].getRange().getFirst() < Intervals[i - 1]
                                             .getRange().getLast()) {}

After:
if (Intervals[i].getRange().getFirst() <
    Intervals[i - 1].getRange().getLast()) {}

llvm-svn: 176092
2013-02-26 13:59:14 +00:00
Evgeniy Stepanov 216bf50f2f Allow dash before "ld" in android driver test.
Sometimes android linker is "arm-linux-androideabi-ld", and not just "ld".

llvm-svn: 176088
2013-02-26 13:20:29 +00:00
Daniel Jasper 16b3562f00 In range-based for-loops, prefer splitting after ":".
Before:
for (const aaaaaaaaaaaaaaaaaaaaa &
         aaaaaaaaa : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

After:
for (const aaaaaaaaaaaaaaaaaaaaa &aaaaaaaaa :
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

llvm-svn: 176087
2013-02-26 13:18:08 +00:00
Daniel Jasper fb5e241183 Only keep empty lines in unwrapped lines if they preceed a line comment.
Empty lines followed by line comments are often used to highlight the
comment. Empty lines somewhere else are usually left over from manual or
automatic formatting and should probably be removed.

Before (clang-format would keep):
S s = {
  a,

  b
};

After:
S s = { a, b };

llvm-svn: 176086
2013-02-26 13:10:34 +00:00
Daniel Jasper 5497fce41c Only break string literals as a last resort.
We might want to move towards doing this if the formatting can be
significantly improved, but we need to carefully evaluate the different
situations first.

Before (the string literal was split by clang-format here):
aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaa, aaaaaa("aaa aaaaa aaa aaa aaaaa aaa "
                                                  "aaaaa aaa aaa aaaaaa"));

After:
aaaaaaaaaaaaaaaaaaaa(
    aaaaaaaaaaaaaaaaaaaa,
    aaaaaa("aaa aaaaa aaa aaa aaaaa aaa aaaaa aaa aaa aaaaaa"));

llvm-svn: 176084
2013-02-26 12:52:34 +00:00