]> granicus.if.org Git - clang/log
clang
11 years agoRemove xfail'd test. This method of limiting debug info isn't
Eric Christopher [Thu, 16 May 2013 00:45:15 +0000 (00:45 +0000)]
Remove xfail'd test. This method of limiting debug info isn't
going to go anywhere.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181961 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoWhitespace.
Eric Christopher [Thu, 16 May 2013 00:45:12 +0000 (00:45 +0000)]
Whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181960 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoClarify comment.
Adrian Prantl [Thu, 16 May 2013 00:41:31 +0000 (00:41 +0000)]
Clarify comment.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181959 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSet the debug location for landing pad code to the canonical EH location.
Adrian Prantl [Thu, 16 May 2013 00:41:29 +0000 (00:41 +0000)]
Set the debug location for landing pad code to the canonical EH location.
It used to point to the first call that caused the landing pad to
be generated.

rdar://problem/13888152

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181958 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCleanup: Use a member variable to store the SourceLocation for EH code.
Adrian Prantl [Thu, 16 May 2013 00:41:26 +0000 (00:41 +0000)]
Cleanup: Use a member variable to store the SourceLocation for EH code.
rdar://problem/13888152

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181957 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRevert "Debug Info: Using declarations/DW_TAG_imported_declaration of variables,...
David Blaikie [Wed, 15 May 2013 23:46:19 +0000 (23:46 +0000)]
Revert "Debug Info: Using declarations/DW_TAG_imported_declaration of variables, types, and functions."

This reverts commit r181393 (git 3923d6a87fe7b2c91cc4a7dbd90c4ec7e2316bcd).

This seems to be emitting too much extra debug info for two (known)
reasons:
* full class definitions are emitted when only declarations are expected
* unused using declarations still produce DW_TAG_imported_declarations

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181947 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove unused, awkward CFGStmtVisitor and subclasses.
Jordan Rose [Wed, 15 May 2013 23:22:55 +0000 (23:22 +0000)]
Remove unused, awkward CFGStmtVisitor and subclasses.

This class is a StmtVisitor that distinguishes between block-level and
non-block-level statements in a CFG. However, it does so using a hard-coded
idea of which statements might be block-level, which probably isn't accurate
anymore. The only implementer of the CFGStmtVisitor hierarchy was the
analyzer's DeadStoresChecker, and the analyzer creates a linearized CFG
anyway (every non-trivial statement is a block-level statement).

This also allows us to remove the block-expr map ("BlkExprMap"), which
mapped statements to positions in the CFG. Apart from having a helper type
that really should have just been Optional<unsigned>, it was only being
used to ask /if/ a particular expression was block-level, for traversal
purposes in CFGStmtVisitor.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181945 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjective-C: More cases of -Wsign-conversion not
Fariborz Jahanian [Wed, 15 May 2013 22:25:03 +0000 (22:25 +0000)]
Objective-C: More cases of -Wsign-conversion not
working on new Objective-C array subscripting
syntax. // rdar://13855682

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181940 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTest commit
Samuel Benzaquen [Wed, 15 May 2013 19:49:05 +0000 (19:49 +0000)]
Test commit

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181915 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjective-C: patch to issue the conversion
Fariborz Jahanian [Wed, 15 May 2013 19:03:04 +0000 (19:03 +0000)]
Objective-C: patch to issue the conversion
warning when property-dot syntax is used
with -Wsign-conversion. // rdar://13855394

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181914 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Put back DefaultBool's implicit conversion to bool.
Jordan Rose [Wed, 15 May 2013 18:08:15 +0000 (18:08 +0000)]
[analyzer] Put back DefaultBool's implicit conversion to bool.

DefaultBool is basically just "bool with a default constructor", so it
really should implicitly convert to bool. In fact, it should convert to
bool&, so that it could be passed to functions that take bools by reference.

This time, mark the operator bool& as implicit to promise that it's
deliberate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181908 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoimprove of note message and minor refactoring of my last
Fariborz Jahanian [Wed, 15 May 2013 15:27:35 +0000 (15:27 +0000)]
improve of note message and minor refactoring of my last
patch (r181847).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181896 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix test breakage caused by change in clang-format.
Daniel Jasper [Wed, 15 May 2013 14:27:33 +0000 (14:27 +0000)]
Fix test breakage caused by change in clang-format.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181888 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDon't put short namespace on a single line.
Daniel Jasper [Wed, 15 May 2013 14:09:55 +0000 (14:09 +0000)]
Don't put short namespace on a single line.

Before:
namespace abc { class SomeClass; }
namespace def { void someFunction() {} }

After:
namespace abc {
class Def;
}
namespace def {
void someFunction() {}
}

Rationale:
a) Having anything other than forward declaration on the same line
   as a namespace looks confusing.
b) Formatting namespace-forward-declaration-combinations different
   from other stuff is inconsistent.
c) Wasting vertical space close to such forward declarations really
   does not affect readability.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181887 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImprove recognition of template definitions.
Daniel Jasper [Wed, 15 May 2013 13:46:48 +0000 (13:46 +0000)]
Improve recognition of template definitions.

In the long run, this will probably be better fixed by a proper
expression parser..

Before:
  template <typename F>
  Matcher(const Matcher<F> & Other,
          typename enable_if_c < is_base_of<F, T>::value &&
              !is_same<F, T>::value > ::type * = 0)
      : Implementation(new ImplicitCastMatcher<F>(Other)) {}

After:
  template <typename F>
  Matcher(const Matcher<F> & Other,
          typename enable_if_c<is_base_of<F, T>::value &&
                               !is_same<F, T>::value>::type * = 0)
      : Implementation(new ImplicitCastMatcher<F>(Other)) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181884 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoBetter diagnostics for string initialization.
Hans Wennborg [Wed, 15 May 2013 11:03:04 +0000 (11:03 +0000)]
Better diagnostics for string initialization.

This commit improves Clang's diagnostics for string initialization.
Where it would previously say:

  /tmp/a.c:3:9: error: array initializer must be an initializer list
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: array initializer must be an initializer list or string literal
  char t[] = L"Hi";
       ^

It will now say

  /tmp/a.c:3:9: error: initializing wide char array with non-wide string literal
  wchar_t s[] = "Hi";
          ^
  /tmp/a.c:4:6: error: initializing char array with wide string literal
  char t[] = L"Hi";
       ^

As a bonus, it also fixes the fact that Clang would previously reject
this valid C11 code:

  char16_t s[] = u"hi";
  char32_t t[] = U"hi";

because it would only recognize the built-in types for char16_t and
char32_t, which do not exist in C.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181880 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoBreak function declarations after multi-line return types.
Daniel Jasper [Wed, 15 May 2013 09:35:08 +0000 (09:35 +0000)]
Break function declarations after multi-line return types.

Before:
template <typename A>
SomeLoooooooooooooooooooooongType<
    typename some_namespace::SomeOtherType<A>::Type> Function() {}

After:
template <typename A>
SomeLoooooooooooooooooooooongType<
    typename some_namespace::SomeOtherType<A>::Type>
Function() {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181877 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDon't merge one-line functions in weird brace styles.
Daniel Jasper [Wed, 15 May 2013 08:30:06 +0000 (08:30 +0000)]
Don't merge one-line functions in weird brace styles.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181872 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRemove diagnostics from clang-format.
Daniel Jasper [Wed, 15 May 2013 08:14:19 +0000 (08:14 +0000)]
Remove diagnostics from clang-format.

We only ever implemented one and that one is not actually all that
helpful (e.g. gets incorrectly triggered by macros).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181871 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImprove formatting of function types.
Daniel Jasper [Wed, 15 May 2013 07:51:51 +0000 (07:51 +0000)]
Improve formatting of function types.

The function type detection in r181438 and r181764 detected function
types too eagerly. This led to inconsistent formatting of inline
assembly and (together with r181687) to an incorrect formatting of calls
in macros.

Before: #define DEREF_AND_CALL_F(parameter) f (*parameter)
After:  #define DEREF_AND_CALL_F(parameter) f(*parameter)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181870 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse only explicit bool conversion operator
David Blaikie [Wed, 15 May 2013 07:37:26 +0000 (07:37 +0000)]
Use only explicit bool conversion operator

The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.

DiagnosticBuilder kept its implicit conversion operator owing to the
prevalent use of it in return statements.

One bug was found in ExprConstant.cpp involving a comparison of two
PointerUnions (PointerUnion did not previously have an operator==, so
instead both operands were converted to bool & then compared). A test
is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix
(adding operator== to PointerUnion in LLVM).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181869 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse correct types for SPARC v9.
Jakob Stoklund Olesen [Wed, 15 May 2013 03:22:33 +0000 (03:22 +0000)]
Use correct types for SPARC v9.

It's an LP64 platform.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181867 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoARM: Improve codegen for vget_low_* and vget_high_ intrinsics.
Jim Grosbach [Wed, 15 May 2013 02:40:04 +0000 (02:40 +0000)]
ARM: Improve codegen for vget_low_* and vget_high_ intrinsics.

These intrinsics use the __builtin_shuffle() function to extract the
low and high half, respectively, of a 128-bit NEON vector. Currently,
they're defined to use bitcasts to simplify the emitter, so we get code
like:
uint16x4_t vget_low_u32(uint16x8_t __a) {
  return (uint32x2_t) __builtin_shufflevector((int64x2_t) __a,
                                              (int64x2_t) __a,
                                              0);
}

While this works, it results in those bitcasts going all the way through
to the IR, resulting in code like:
  %1 = bitcast <8 x i16> %in to <2 x i64>
  %2 = shufflevector <2 x i64> %1, <2 x i64> undef, <1 x i32>
  %zeroinitializer
  %3 = bitcast <1 x i64> %2 to <4 x i16>

We can instead easily perform the operation directly on the input vector
like:

uint16x4_t vget_low_u16(uint16x8_t __a) {
  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3);
}

Not only is that much easier to read on its own, it also results in
cleaner IR like:

  %1 = shufflevector <8 x i16> %in, <8 x i16> undef,
                     <4 x i32> <i32 0, i32 1, i32 2, i32 3>

This is both easier to read and easier for the back end to reason
about effectively since the operation is obfuscating the source with
bitcasts.

rdar://13894163

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181865 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse 'env' in tests that set environment variables.
Jordan Rose [Wed, 15 May 2013 01:45:37 +0000 (01:45 +0000)]
Use 'env' in tests that set environment variables.

Patch by David Fang!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181861 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoMove a test that requires 64-bit mode to a separate test with a triple in
Richard Trieu [Wed, 15 May 2013 00:44:06 +0000 (00:44 +0000)]
Move a test that requires 64-bit mode to a separate test with a triple in
the run line.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181854 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUnbreaking the MSVC build by adding an include. It broke with r181832.
Aaron Ballman [Tue, 14 May 2013 23:52:21 +0000 (23:52 +0000)]
Unbreaking the MSVC build by adding an include.  It broke with r181832.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181853 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd static_cast to assertion to silence sign/unsigned comparison warning.
Richard Trieu [Tue, 14 May 2013 23:41:50 +0000 (23:41 +0000)]
Add static_cast to assertion to silence sign/unsigned comparison warning.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181849 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjective-C [diagnostics] [QOI], when method is not
Fariborz Jahanian [Tue, 14 May 2013 23:24:17 +0000 (23:24 +0000)]
Objective-C [diagnostics] [QOI], when method is not
found for a receiver, note where receiver class
is declaraed (this is most common when receiver is a forward
class). // rdar://3258331

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181847 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDon't mark a type specifier as "owned" if there is no declaration to own.
Douglas Gregor [Tue, 14 May 2013 23:22:32 +0000 (23:22 +0000)]
Don't mark a type specifier as "owned" if there is no declaration to own.

This simplifies error recovery elsewhere, eliminating the crash in
<rdar://problem/13853540>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181846 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoWhen computing the size of large arrays, use char units instead of bits.
Richard Trieu [Tue, 14 May 2013 21:59:17 +0000 (21:59 +0000)]
When computing the size of large arrays, use char units instead of bits.
This prevents an overflow and assertion when the number of bits cannot be
stored in 64-bits.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181839 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix clang -Werror build due to -Wreorder violation introduced in r181825
David Blaikie [Tue, 14 May 2013 21:31:46 +0000 (21:31 +0000)]
Fix clang -Werror build due to -Wreorder violation introduced in r181825

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181834 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoProvide operator<< for stream output of DeclarationNames
David Blaikie [Tue, 14 May 2013 21:04:00 +0000 (21:04 +0000)]
Provide operator<< for stream output of DeclarationNames

ASTDumper was already trying to do this & instead got an implicit bool
conversion by surprise (thus printing out 0 or 1 instead of the name of
the declaration). To avoid that issue & simplify call sites, simply make
it the normal/expected operator<<(raw_ostream&, ...) overload & simplify
all the existing call sites. (bonus: this function doesn't need to be a
member or friend, it's just using public API in DeclarationName)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181832 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix copy-pasto in naming of LAST_MS_INHERITANCE[_ATTR]
Reid Kleckner [Tue, 14 May 2013 20:55:49 +0000 (20:55 +0000)]
Fix copy-pasto in naming of LAST_MS_INHERITANCE[_ATTR]

Richard Smith pointed this out over a month ago.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181830 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix expression breaking for one-parameter-per-line styles.
Daniel Jasper [Tue, 14 May 2013 20:39:56 +0000 (20:39 +0000)]
Fix expression breaking for one-parameter-per-line styles.

Before:
  if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
After:
  if (aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa || aaaaaaaaaaaaaaaaaaaaaaaaaaaa ||
      aaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181828 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix the MSVC build broken by r181768
Reid Kleckner [Tue, 14 May 2013 20:30:49 +0000 (20:30 +0000)]
Fix the MSVC build broken by r181768

MSVC accepts the using decl but not the typedef.  It complains that the
typedef is ambiguous.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181826 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[ms-cxxabi] Mangle in an implicit 'E' for certain types on win64
Reid Kleckner [Tue, 14 May 2013 20:30:42 +0000 (20:30 +0000)]
[ms-cxxabi] Mangle in an implicit 'E' for certain types on win64

Most of the complexity of this patch is figuring out which types get the
qualifier and which don't.  If we implement __ptr32/64, then we should
check the qualifier instead of assuming all pointers are 64-bit.

This fixes PR13792.

Patch by Warren Hunt!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181825 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoReally fix the declaration of __clear_cache.
Rafael Espindola [Tue, 14 May 2013 18:06:10 +0000 (18:06 +0000)]
Really fix the declaration of __clear_cache.

When I tested gcc's behaviour before, I forgot the extern "C", so it
would warn when the types *did* match.

So in the end
* __clear_cache takes two void pointers.
* aarch64 was correct before.
* libgcc's manual is wrong.
* this patch fixes arm.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181810 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd LeakSanitizer.rst to docs.
Sergey Matveev [Tue, 14 May 2013 15:48:54 +0000 (15:48 +0000)]
Add LeakSanitizer.rst to docs.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181798 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix __clear_cache on ARM.
Rafael Espindola [Tue, 14 May 2013 12:45:47 +0000 (12:45 +0000)]
Fix __clear_cache on ARM.

Current gcc's produce an error if __clear_cache is anything but

__clear_cache(char *a, char *b);

It looks like we had just implemented a gcc bug that is now fixed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181784 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoLink dynamic ast matchers with the ast matchers library. Unbreaks shared cmake build.
Benjamin Kramer [Tue, 14 May 2013 12:41:50 +0000 (12:41 +0000)]
Link dynamic ast matchers with the ast matchers library. Unbreaks shared cmake build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181783 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoRevert accidental commit.
Benjamin Kramer [Tue, 14 May 2013 12:23:08 +0000 (12:23 +0000)]
Revert accidental commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181782 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoTake a stab at trying to unbreak the makefile build.
Benjamin Kramer [Tue, 14 May 2013 12:21:21 +0000 (12:21 +0000)]
Take a stab at trying to unbreak the makefile build.

There is no clangRewrite.a.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181781 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoHopefully fix configure build.
Manuel Klimek [Tue, 14 May 2013 11:59:20 +0000 (11:59 +0000)]
Hopefully fix configure build.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181780 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix uninitialized value bug found by valgrind.
Daniel Jasper [Tue, 14 May 2013 10:44:17 +0000 (10:44 +0000)]
Fix uninitialized value bug found by valgrind.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181779 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCorrectly determine ranges for clang-format.
Daniel Jasper [Tue, 14 May 2013 10:31:09 +0000 (10:31 +0000)]
Correctly determine ranges for clang-format.

We have been assuming that CharSourceRange::getTokenRange() by itself
expands a range until the end of a token, but in fact it only sets
IsTokenRange to true. Thus, we have so far only considered the first
character of the last token to belong to an unwrapped line. This
did not really manifest in symptoms as all edit integrations
expand ranges to fully lines.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181778 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix clang-format bug in unwrapped-line merging.
Daniel Jasper [Tue, 14 May 2013 09:30:02 +0000 (09:30 +0000)]
Fix clang-format bug in unwrapped-line merging.

Before (in styles that allow it), clang-format would not merge an
if statement onto a single line, if only the second line was format
(e.g. in an editor integration):

if (a)
  return; // clang-format invoked on this line.

With this patch, this gets properly merged to:

if (a) return; // ...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181770 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFirst revision of the dynamic ASTMatcher library.
Manuel Klimek [Tue, 14 May 2013 09:13:00 +0000 (09:13 +0000)]
First revision of the dynamic ASTMatcher library.

This library supports all the features of the compile-time based ASTMatcher
library, but allows the user to specify and construct the matchers at runtime.
It contains the following modules:
 - A variant type, to be used by the matcher factory.
 - A registry, where the matchers are indexed by name and have a factory method
   with a generic signature.
 - A simple matcher expression parser, that can be used to convert a matcher
   expression string into actual matchers that can be used with the AST at
   runtime.

Many features where omitted from this first revision to simplify this code
review. The main ideas are still represented in this change and it already has
support working use cases.
Things that are missing:
 - Support for polymorphic matchers. These requires supporting code in the
   registry, the marshallers and the variant type.
 - Support for numbers, char and bool arguments to the matchers. This requires
   supporting code in the parser and the variant type.
 - A command line program putting everything together and providing an already
   functional tool.

Patch by Samuel Benzaquen.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181768 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplement string literal breaking on unbreakable token sequences.
Manuel Klimek [Tue, 14 May 2013 09:04:24 +0000 (09:04 +0000)]
Implement string literal breaking on unbreakable token sequences.

This fixes indentation where there are for example multiple closing
parentheses after a string literal, and where those parentheses
run over the end of the line.

During testing this revealed a bug in the implementation of
breakProtrudingToken: we don't want to change the state if we didn't
actually do anything.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181767 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUpdate clang-format emacs integration.
Daniel Jasper [Tue, 14 May 2013 08:48:24 +0000 (08:48 +0000)]
Update clang-format emacs integration.

- Remove free variables
- Add function clang-format-buffer, e.g. for before-save-hooks
- Wrap restoring windows in an unwind-protect

Patch by Stephen Gildea!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181766 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAArch64: add test for updated __clear_cache definition
Tim Northover [Tue, 14 May 2013 08:37:13 +0000 (08:37 +0000)]
AArch64: add test for updated __clear_cache definition

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181765 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDon't format sizeof/alignof as function types.
Daniel Jasper [Tue, 14 May 2013 08:34:47 +0000 (08:34 +0000)]
Don't format sizeof/alignof as function types.

Before: A<sizeof (*x)> a;
After:  A<sizeof(*x)> a;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181764 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAArch64: correct definition of __clear_cache
Tim Northover [Tue, 14 May 2013 08:26:14 +0000 (08:26 +0000)]
AArch64: correct definition of __clear_cache

According to libgcc document __clear_cache takes two char*
pointers. I suspect GCC's actual behaviour is more subtle than that,
but char* should clearly be preferred to void*.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181762 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoReplace EXPECT_EQ with EXPECT_FALSE to avoid gcc warning
Patrik Hagglund [Tue, 14 May 2013 07:53:53 +0000 (07:53 +0000)]
Replace EXPECT_EQ with EXPECT_FALSE to avoid gcc warning
[-Wconversion-null], introduced in r181326.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181761 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSuppress bogus "use of undefined constexpr function" error if the function body
Richard Smith [Tue, 14 May 2013 05:18:44 +0000 (05:18 +0000)]
Suppress bogus "use of undefined constexpr function" error if the function body
was erroneous and got discarded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181758 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse atomic instructions on linux thumb v7.
Rafael Espindola [Tue, 14 May 2013 00:44:24 +0000 (00:44 +0000)]
Use atomic instructions on linux thumb v7.

This matches gcc's behaviour. The patch also explicitly parses the version so
that this keeps working when we add support for v8.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181750 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPR15956: Debug Info: Include the appropriate file location in types created due to...
David Blaikie [Tue, 14 May 2013 00:34:20 +0000 (00:34 +0000)]
PR15956: Debug Info: Include the appropriate file location in types created due to using declarations

We might benefit from API refactoring here (why pass in a value that's
derived from another parameter?) but this is the immediate issue.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181747 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Refactor: address Jordan’s code review of r181738.
Anna Zaks [Mon, 13 May 2013 23:49:51 +0000 (23:49 +0000)]
[analyzer] Refactor: address Jordan’s code review of r181738.

(Modifying the checker to record that the values are no longer nil will be done separately.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181744 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Warn about nil elements/keys/values in array and dictionary literals.
Anna Zaks [Mon, 13 May 2013 21:48:20 +0000 (21:48 +0000)]
[analyzer] Warn about nil elements/keys/values in array and dictionary literals.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181738 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAlign a multiline string literal with the first part.
Daniel Jasper [Mon, 13 May 2013 20:50:15 +0000 (20:50 +0000)]
Align a multiline string literal with the first part.

Before:
  #define A(X)          \
    "aaaaa" #X "bbbbbb" \
               "ccccc"

After:
  #define A(X)          \
    "aaaaa" #X "bbbbbb" \
    "ccccc"

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181732 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoSuppress GCC warning for no return after covered switch, and remove some
Richard Smith [Mon, 13 May 2013 20:33:30 +0000 (20:33 +0000)]
Suppress GCC warning for no return after covered switch, and remove some
debugging code from an unreachable codepath.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181731 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix a wrong and confusing comment in CharUnits.h. Neither C nor C++ allows
Richard Smith [Mon, 13 May 2013 20:28:15 +0000 (20:28 +0000)]
Fix a wrong and confusing comment in CharUnits.h. Neither C nor C++ allows
bytes and character units to be different sizes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181730 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUse atomic instructions on ARM linux.
Rafael Espindola [Mon, 13 May 2013 20:09:47 +0000 (20:09 +0000)]
Use atomic instructions on ARM linux.

This is safe given how the pre-v6 atomic ops funcions in libgcc are
implemented.

This fixes pr15429.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181728 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjective-C error recovery. This patch makes a quick
Fariborz Jahanian [Mon, 13 May 2013 17:27:00 +0000 (17:27 +0000)]
Objective-C error recovery. This patch makes a quick
recovery form duplicate method definition error thus
preventing doc parsing to loop trying to find comment
for the invalid redefinition in a previous declaration.
// rdar://13836387

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181710 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix test/CodeGenCXX/captured-statements.cpp on powerpc64
Ben Langmuir [Mon, 13 May 2013 14:45:11 +0000 (14:45 +0000)]
Fix test/CodeGenCXX/captured-statements.cpp on powerpc64

Generalize some attributes that differ on powerpc64 (i32 vs signext i32). Also
fix some copy-and-pasted code that didn't get updated properly.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181707 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix a gcc warning.
Rafael Espindola [Mon, 13 May 2013 14:05:53 +0000 (14:05 +0000)]
Fix a gcc warning.

In r181677 I removed this llvm_unreachable and it introduced a gcc
warning. Add it back.

Thanks to Patrik Hägglund for noticing it.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181704 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoA better version of r181699: use raw_string_ostream.str() instead of manually calling...
Alexander Kornienko [Mon, 13 May 2013 12:56:35 +0000 (12:56 +0000)]
A better version of r181699: use raw_string_ostream.str() instead of manually calling .flush().

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181702 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix style according to post-commit review comments.
Manuel Klimek [Mon, 13 May 2013 12:53:04 +0000 (12:53 +0000)]
Fix style according to post-commit review comments.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181701 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplements brace breaking styles.
Manuel Klimek [Mon, 13 May 2013 12:51:40 +0000 (12:51 +0000)]
Implements brace breaking styles.

We now support "Linux" and "Stroustrup" brace breaking styles, which
gets us one step closer to support formatting WebKit, KDE & Linux code.

Linux brace breaking style:
namespace a
{
class A
{
  void f()
  {
    if (x) {
      f();
    } else {
      g();
    }
  }
}
}

Stroustrup brace breaking style:
namespace a {
class A {
  void f()
  {
    if (x) {
      f();
    } else {
      g();
    }
  }
}
}

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181700 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFixes [Bug 15960] YAMLTraits doesn't roundtrip on Windows.
Alexander Kornienko [Mon, 13 May 2013 12:41:08 +0000 (12:41 +0000)]
Fixes [Bug 15960] YAMLTraits doesn't roundtrip on Windows.
Thanks to Kim Gräsman for help!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181699 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplements UseTab for clang-format.
Manuel Klimek [Mon, 13 May 2013 09:22:11 +0000 (09:22 +0000)]
Implements UseTab for clang-format.

This is required for kernel linux kernel style formatting.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181693 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFurther improve optimization for nested calls.
Daniel Jasper [Mon, 13 May 2013 09:19:24 +0000 (09:19 +0000)]
Further improve optimization for nested calls.

Fake parentheses (i.e. emulated parentheses used to correctly handle
binary expressions) used to prevent the optimization implemented in
r180264.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181692 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoImplements IndentWidth.
Manuel Klimek [Mon, 13 May 2013 08:42:42 +0000 (08:42 +0000)]
Implements IndentWidth.

This is required for various styles that are for example based on
8-indent.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181690 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAssume macros to contain declarations.
Daniel Jasper [Mon, 13 May 2013 07:14:40 +0000 (07:14 +0000)]
Assume macros to contain declarations.

This seems to be the vastly more common case. If we find enough
examples to the contrary, we can make it smarter.

Before: #define MACRO void f(int * a)
After:  #define MACRO void f(int *a)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181687 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDebug Info: PR14992: Support values for non-type template parameters of function...
David Blaikie [Mon, 13 May 2013 06:57:50 +0000 (06:57 +0000)]
Debug Info: PR14992: Support values for non-type template parameters of function type

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181685 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoOpenMP threadprivate with qualified names.
Alexey Bataev [Mon, 13 May 2013 04:18:18 +0000 (04:18 +0000)]
OpenMP threadprivate with qualified names.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181683 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoUpdate for LLVM interface change in r181680.
Rafael Espindola [Mon, 13 May 2013 01:24:18 +0000 (01:24 +0000)]
Update for LLVM interface change in r181680.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181681 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAdd missing triple to CodeGen test.
Richard Smith [Mon, 13 May 2013 00:29:57 +0000 (00:29 +0000)]
Add missing triple to CodeGen test.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181679 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCleanup handling of UniqueExternalLinkage.
Rafael Espindola [Mon, 13 May 2013 00:12:11 +0000 (00:12 +0000)]
Cleanup handling of UniqueExternalLinkage.

This patch renames getLinkage to getLinkageInternal. Only code that
needs to handle UniqueExternalLinkage specially should call this.

Linkage, as defined in the c++ standard, is provided by
getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage.

Most places in the compiler actually want isExternallyVisible, which
handles UniqueExternalLinkage as internal.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181677 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDowngrade C++14 "Clarifying memory allocation". We perform non-conforming
Richard Smith [Sun, 12 May 2013 23:39:32 +0000 (23:39 +0000)]
Downgrade C++14 "Clarifying memory allocation". We perform non-conforming
optimizations -- in particular, globalopt will remove calls to ::operator
new(size_t) that did not come from new-expressions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181676 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoFix stack overflow in linkage computation when a function with a deduced return
Richard Smith [Sun, 12 May 2013 23:17:59 +0000 (23:17 +0000)]
Fix stack overflow in linkage computation when a function with a deduced return
type returns a lambda defined within itself. The computation of linkage for the
function looked at the linkage of the lambda, and vice versa.

This is solved by not checking whether an 'auto' in a function return type
deduces to a type with unique external linkage. We don't need this check,
because the type deduced for 'auto' doesn't affect whether two
otherwise-identical declarations would name different functions, so we don't
need to give an ostensibly external-linkage function internal linkage for this
reason. (We also don't need unique-external linkage in C++11 onwards at all,
but that's not implemented yet.)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181675 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDebug Info: Comment changes in r181393 by request of echristo
David Blaikie [Sun, 12 May 2013 18:05:52 +0000 (18:05 +0000)]
Debug Info: Comment changes in r181393 by request of echristo

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181672 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoC++1y: support for 'switch' statements in constexpr functions. This is somewhat
Richard Smith [Sun, 12 May 2013 17:32:42 +0000 (17:32 +0000)]
C++1y: support for 'switch' statements in constexpr functions. This is somewhat
inefficient; we perform a linear scan of switch labels to find the one matching
the condition, and then walk the body looking for that label. Both parts should
be straightforward to optimize.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181671 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoC++1y: provide full 'auto' return type deduction for lambda expressions. This
Richard Smith [Sun, 12 May 2013 03:09:35 +0000 (03:09 +0000)]
C++1y: provide full 'auto' return type deduction for lambda expressions. This
completes the implementation of N3638.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181669 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoCodeGen: Refactor SetLLVMFunctionAttributesForDefinition to use an AttrBuilder.
Benjamin Kramer [Sat, 11 May 2013 12:45:37 +0000 (12:45 +0000)]
CodeGen: Refactor SetLLVMFunctionAttributesForDefinition to use an AttrBuilder.

Adding attributes to a uniqued set has become expensive, don't do it more often
than necessary. No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181662 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[Mips] Add -mldc1-sdc1 / -mno-ldc1-sdc1 command line options.
Simon Atanasyan [Sat, 11 May 2013 06:33:44 +0000 (06:33 +0000)]
[Mips] Add -mldc1-sdc1 / -mno-ldc1-sdc1 command line options.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181660 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoC++1y deduced return types: when we deduce a return type for a function which
Richard Smith [Sat, 11 May 2013 05:45:24 +0000 (05:45 +0000)]
C++1y deduced return types: when we deduce a return type for a function which
we loaded from PCH, if we're building another PCH, create an update record to
patch the return type of the earlier declaration.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181659 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDebug Info: correct comment
David Blaikie [Fri, 10 May 2013 23:36:06 +0000 (23:36 +0000)]
Debug Info: correct comment

Eric's code review feedback to r181644

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181650 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoDebug Info: Silently accept template argument packs
David Blaikie [Fri, 10 May 2013 22:53:25 +0000 (22:53 +0000)]
Debug Info: Silently accept template argument packs

We could support the GCC extension DW_TAG_GNU_template_parameter_pack if
we're feeling adventurous, at some point - but I don't think GDB's doing
anything useful with it yet anyway.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181644 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[Modules] Make r180934 more efficient by only loading top-level module maps in system...
Douglas Gregor [Fri, 10 May 2013 22:52:27 +0000 (22:52 +0000)]
[Modules] Make r180934 more efficient by only loading top-level module maps in system header directories.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181643 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[Modules] When things go horribly wrong when reading a module, point at the module...
Douglas Gregor [Fri, 10 May 2013 22:15:13 +0000 (22:15 +0000)]
[Modules] When things go horribly wrong when reading a module, point at the module cache.

Sometimes people hack on their system headers. In such cases, they'll
need to delete their module cache, but may not know where it is. Add a
note to show them where it is.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181638 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[Modules] Extend Darwin hack to include the modification time of SystemVersion.plist.
Douglas Gregor [Fri, 10 May 2013 21:54:08 +0000 (21:54 +0000)]
[Modules] Extend Darwin hack to include the modification time of SystemVersion.plist.

Fixes <rdar://problem/13856838>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181635 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPR14992: Debug Info: Support more non-type template parameters
David Blaikie [Fri, 10 May 2013 21:53:14 +0000 (21:53 +0000)]
PR14992: Debug Info: Support more non-type template parameters

* Provide DW_TAG_template_value_parameter for pointers, function
  pointers, member pointers, and member function pointers (still missing
  support for template template parameters which GCC encodes as a
  DW_TAG_GNU_template_template_param)
* Provide values for all but the (member & non-member) function pointer case.
  Simple constant integer values for member pointers (offset within the
  object) and address for the value pointer case. GCC doesn't provide a
  value for the member function pointer case so I'm not sure how, if at
  all, GDB supports encoding that. & non-member function pointers should
  follow shortly in a subsequent patch.
* Null pointer value encodings of all of these types, including
  correctly encoding null data member pointers as -1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181634 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoObjC debug info: Substitute the class type for methods that return
Adrian Prantl [Fri, 10 May 2013 21:08:31 +0000 (21:08 +0000)]
ObjC debug info: Substitute the class type for methods that return
a related type (e.g., if they use the instancetype keyword).

rdar://problem/13359718

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181629 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAvoid patching storage class for block scope thread_local variables.
Enea Zaffanella [Fri, 10 May 2013 20:34:44 +0000 (20:34 +0000)]
Avoid patching storage class for block scope thread_local variables.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181627 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoPR15966: don't get confused by a complex integer -> complex integer conversion
Richard Smith [Fri, 10 May 2013 20:29:50 +0000 (20:29 +0000)]
PR15966: don't get confused by a complex integer -> complex integer conversion
and misclassify it as a complex-real conversion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181626 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoReformat clang-format help strings, filter out irrelevant options.
Alexander Kornienko [Fri, 10 May 2013 18:12:00 +0000 (18:12 +0000)]
Reformat clang-format help strings, filter out irrelevant options.

Summary: +updated ClangFormat.rst

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D780

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181617 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Assume [NSNull null] does not return nil.
Anna Zaks [Fri, 10 May 2013 18:04:46 +0000 (18:04 +0000)]
[analyzer] Assume [NSNull null] does not return nil.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181616 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Do not check if sys/queue.h file is a system header.
Anna Zaks [Fri, 10 May 2013 18:04:43 +0000 (18:04 +0000)]
[analyzer] Do not check if sys/queue.h file is a system header.

In most cases it is, by just looking at the name. Also, this check prevents the heuristic from working in strange user settings.
radar://13839692

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181615 91177308-0d34-0410-b5e6-96231b3b80d8

11 years agoAllocate memory for the new number of subexpressions. Fixup for r181572
Dmitri Gribenko [Fri, 10 May 2013 17:30:13 +0000 (17:30 +0000)]
Allocate memory for the new number of subexpressions.  Fixup for r181572

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181611 91177308-0d34-0410-b5e6-96231b3b80d8

11 years ago[analyzer] Indirect invalidation counts as an escape for leak checkers.
Jordan Rose [Fri, 10 May 2013 17:07:16 +0000 (17:07 +0000)]
[analyzer] Indirect invalidation counts as an escape for leak checkers.

Consider this example:

  char *p = malloc(sizeof(char));
  systemFunction(&p);
  free(p);

In this case, when we call systemFunction, we know (because it's a system
function) that it won't free 'p'. However, we /don't/ know whether or not
it will /change/ 'p', so the analyzer is forced to invalidate 'p', wiping
out any bindings it contains. But now the malloc'd region looks like a
leak, since there are no more bindings pointing to it, and we'll get a
spurious leak warning.

The fix for this is to notice when something is becoming inaccessible due
to invalidation (i.e. an imperfect model, as opposed to being explicitly
overwritten) and stop tracking it at that point. Currently, the best way
to determine this for a call is the "indirect escape" pointer-escape kind.

In practice, all the patch does is take the "system functions don't free
memory" special case and limit it to direct parameters, i.e. just the
arguments to a call and not other regions accessible to them. This is a
conservative change that should only cause us to escape regions more
eagerly, which means fewer leak warnings.

This isn't perfect for several reasons, the main one being that this
example is treated the same as the one above:

  char **p = malloc(sizeof(char *));
  systemFunction(p + 1);
  // leak

Currently, "addresses accessible by offsets of the starting region" and
"addresses accessible through bindings of the starting region" are both
considered "indirect" regions, hence this uniform treatment.

Another issue is our longstanding problem of not distinguishing const and
non-const bindings; if in the first example systemFunction's parameter were
a char * const *, we should know that the function will not overwrite 'p',
and thus we can safely report the leak.

<rdar://problem/13758386>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181607 91177308-0d34-0410-b5e6-96231b3b80d8