Commit Graph

31676 Commits

Author SHA1 Message Date
Aaron Ballman 283ef4234c Replacing some manual diagnostic checks with an existing helper method. Adding missing test cases for the diagnostics.
llvm-svn: 186944
2013-07-23 15:16:00 +00:00
Aaron Ballman bcee83e99d Removed a redundant diagnostic and replaced it with a more standard one. Added a test case for the diagnostic.
llvm-svn: 186942
2013-07-23 14:54:24 +00:00
Aaron Ballman 2998227501 Consolidate several attribute argument diagnostics into a single, selectable diagnostic. This makes the diagnostic more consistent.
llvm-svn: 186940
2013-07-23 14:03:57 +00:00
Aaron Ballman 7ced167a09 Correcting the NSObject and Overloadable attribute diagnostics so that the count reported matches reality.
llvm-svn: 186936
2013-07-23 12:13:14 +00:00
Richard Smith f4198b7598 C++1y literal suffix support:
* Allow ns, us, ms, s, min, h as numeric ud-suffixes
 * Allow s as string ud-suffix

llvm-svn: 186933
2013-07-23 08:14:48 +00:00
Jordan Rose 316cdda54b [analyzer] Enable pseudo-destructor expressions.
These are cases where a scalar type is "destructed", usually due to
template instantiation (e.g. "obj.~T()", where 'T' is 'int'). This has
no actual effect and the analyzer should just skip over it.

llvm-svn: 186927
2013-07-23 02:15:20 +00:00
Jordan Rose 7b982b30c0 Revert "[analyzer] Add very limited support for temporary destructors"
The analyzer doesn't currently expect CFG blocks with terminators to be
empty, but this can happen when generating conditional destructors for
a complex logical expression, such as (a && (b || Temp{})). Moreover,
the branch conditions for these expressions are not persisted in the
state. Even for handling noreturn destructors this needs more work.

This reverts r186498.

llvm-svn: 186925
2013-07-23 02:15:11 +00:00
Matt Arsenault efb38192b0 Error on more illegal kernel argument types for OpenCL
bool, half, pointers and structs / unions containing any
of these are not allowed. Does not yet reject size_t and
related integer types that are also disallowed.

llvm-svn: 186908
2013-07-23 01:23:36 +00:00
Eli Friedman 088d39afc6 Integers which are too large should be an error.
Switch some warnings over to errors which should never have been warnings
in the first place.  (Also, a minor fix to the preprocessor rules for
integer literals while I'm here.)

llvm-svn: 186903
2013-07-23 00:25:18 +00:00
Eli Bendersky aefa5e2ff2 Add a -fno-math-builtin option to the Clang -cc1
llvm-svn: 186899
2013-07-23 00:13:01 +00:00
Adrian Prantl ead2ba4649 Implement a better fix for r186894 by setting the appropriate type for __byref_variable_layout.
rdar://problem/14386148

llvm-svn: 186898
2013-07-23 00:12:14 +00:00
Fariborz Jahanian 9e543afe19 ObjectiveC migration. Better handle migration to conforming
protocols by ignoring cases where all protocol properties
and methods are optional.

llvm-svn: 186895
2013-07-22 23:50:04 +00:00
Adrian Prantl 52f5b2502f Debug Info: Acknowledge the alignment when locating byref block variables.
Fixes rdar://problem/14386148

llvm-svn: 186894
2013-07-22 23:44:26 +00:00
Eli Friedman ef0b4a36f2 Don't emit open-paren fixit without close-paren.
getLocForEndOfToken() isn't guaranteed to succeed; if it doesn't, make sure
we do something sane.

Fixes PR16673.  I'm not sure how to write a testcase for this short of grepping
through the diagnostic output.

llvm-svn: 186889
2013-07-22 23:09:39 +00:00
Douglas Gregor a3dd900c71 Make modules depend on the compiler's own module.map, as a proxy for the compiler itself.
The headers in the compiler's own resource include directory are
system headers, which means we don't stat() them eagerly when loading
a module. Use module.map as a proxy for these headers and the compiler
itself. Fixes <rdar://problem/13856838>.

llvm-svn: 186870
2013-07-22 20:48:33 +00:00
Bill Wendling b321972fdf Use the updated name for the attribute.
llvm-svn: 186864
2013-07-22 20:15:41 +00:00
Enea Zaffanella c7cb48c4b9 Fixed implementation of C89 6.5.7 p3.
Warning should be emitted only for InitListExpr nodes.

llvm-svn: 186859
2013-07-22 19:10:20 +00:00
Fariborz Jahanian d0f6f79f4e Objective-C migration: Use NS_OPTIONS when enumerators
have shift/bitwise operators or are power of 2.

llvm-svn: 186856
2013-07-22 18:53:45 +00:00
Argyrios Kyrtzidis ec852d908f [arcmt] Only disable ARC in the second compilation if there were actually ARC errors in the checking phase.
rdar://14490204

llvm-svn: 186850
2013-07-22 18:13:54 +00:00
Richard Smith d162703b11 Update comment to refer to core issue number.
llvm-svn: 186848
2013-07-22 18:06:23 +00:00
Samuel Benzaquen e0b2c8e478 Add support for overloaded matchers. ie different matcher function signatures with the same name.
Summary:
Add support for overloaded matchers.
This composes with other features, like supporting polymorphic matchers.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1188

llvm-svn: 186836
2013-07-22 16:13:57 +00:00
Reid Kleckner e7de47efbe [ms-cxxabi] Emit linkonce complete dtors in TUs that need them
Based on Peter Collingbourne's destructor patches.

Prior to this change, clang was considering ?1 to be the complete
destructor and the base destructor, which was wrong.  This lead to
crashes when clang tried to emit two LLVM functions with the same name.

In this ABI, TUs with non-inline dtors might not emit a complete
destructor.  They are emitted as inline thunks in TUs that need them,
and they always delegate to the base dtors of the complete class and its
virtual bases.  This change uses the DeferredDecls machinery to emit
complete dtors as needed.

Currently in clang try body destructors can catch exceptions thrown by
virtual base destructors.  In the Microsoft C++ ABI, clang may not have
the destructor definition, in which case clang won't wrap the virtual
virtual base destructor calls in a try-catch.  Diagnosing this in user
code is TODO.

Finally, for classes that don't use virtual inheritance, MSVC always
calls the base destructor (?1) directly.  This is a useful code size
optimization that avoids emitting lots of extra thunks or aliases.
Implementing it also means our existing tests continue to pass, and is
consistent with MSVC's output.

We can do the same for Itanium by tweaking GetAddrOfCXXDestructor, but
it will require further testing.

Reviewers: rjmccall

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1066

llvm-svn: 186828
2013-07-22 13:51:44 +00:00
Reid Kleckner f6ce2b5f2e Rename D to GD to match the type, which is GlobalDecl
Now we can save GD.getDecl() in D and shorten some casts.

llvm-svn: 186826
2013-07-22 13:07:10 +00:00
Enea Zaffanella 1aac546d31 Implement the part of C89 6.5.7 p3 requiring a constant initializer list
when initializing aggregate/union types, no matter if static or not.

llvm-svn: 186817
2013-07-22 10:58:26 +00:00
Enea Zaffanella e05a3cf648 Improve clarity/consistency of a few UsingDecl methods and related helpers.
No functionality change.

In Sema helper functions:
 * renamed isTypeName as HasTypenameKeyword
In UsingDecl:
 * renamed get/setUsingLocation to get/setUsingLoc
 * renamed is/setTypeName as has/setTypename

llvm-svn: 186816
2013-07-22 10:54:09 +00:00
Robert Wilhelm e3cea80ddb Remove superfluous cast.
llvm-svn: 186807
2013-07-22 05:04:01 +00:00
Richard Smith 35828f1db6 PR16288: A template is only missing a default template argument if it provides
any default template arguments, not if it inherits some.

llvm-svn: 186804
2013-07-22 03:31:14 +00:00
Richard Smith bc46e4341e Implement DR257 / fix PR16659:
A constructor for an abstract class does not call constructors for virtual
  base classes, so it is not an error if no initializer is present for the
  virtual base and the virtual base cannot be default initialized.

Also provide a (disabled by default, for now) warning for the case where a
virtual base class's initializer is ignored in an abstract class's constructor,
and address a defect in DR257 where it was not carried through to C++11's rules
for implicit deletion of special member functions.

Based on a patch by Maurice Bos.

llvm-svn: 186803
2013-07-22 02:56:56 +00:00
NAKAMURA Takumi 75a7c32a3c SemaTemplate.cpp: Prune a stray "\param NumParamLists" in comment. [-Wdocumentation]
llvm-svn: 186802
2013-07-22 01:27:42 +00:00
Richard Smith 8d0dc31dca Tighten up the set of operator new/operator delete calls we're permitted to
optimize, to follow the permissions granted in N3664. Under those rules, only
calls generated by new-expressions and delete-expressions are permitted to be
optimized, and direct calls to ::operator new and ::operator delete must be
treated as normal calls.

llvm-svn: 186799
2013-07-21 23:12:18 +00:00
Craig Topper ea6caba325 Replace 'unsigned short' with 'uint16_t' in a packed data structure for consistency with other fields and to be explicit about bit count.
llvm-svn: 186796
2013-07-21 21:56:18 +00:00
Craig Topper 31e71a3997 Revert r186649 because it wasn't unnecessary and add a comment.
llvm-svn: 186795
2013-07-21 18:58:40 +00:00
Robert Wilhelm f2d2e8ff02 Convert Sema::MatchTemplateParametersToScopeSpecifier to ArrayRef.
llvm-svn: 186794
2013-07-21 15:20:44 +00:00
Lubos Lunak 1f490f3aea report unused-value warning also for warn_unused types
llvm-svn: 186793
2013-07-21 13:15:58 +00:00
Enea Zaffanella 5afb04abaf Added preproc callback for pragma directives.
llvm-svn: 186770
2013-07-20 20:09:11 +00:00
Richard Smith 72d74057ea Add missing check for creating an instance of an abstract class through an
implicit conversion sequence.

llvm-svn: 186769
2013-07-20 19:41:36 +00:00
Lubos Lunak edc138880d add type attribute warn_unused, for -Wunused-variable warnings (pr#14253)
The functionality is equivalent to the GCC attribute. Variables of tagged
types will be warned about as unused if they are not used in any way
except for possible (even non-trivial) ctors/dtors called. Useful for tagging
classes like std::string (which is not part of this commit).

llvm-svn: 186765
2013-07-20 15:05:36 +00:00
Lubos Lunak ba5ee4da1d avoid bogus warnings about "unknown" pragmas with -frewrite-includes (pr#14831)
llvm-svn: 186764
2013-07-20 14:30:01 +00:00
Lubos Lunak 4c22f6a695 fix sometimes incorrect line numbers in -frewrite-includes mode (pr#14795)
Every #include is surrounded by #if 0 in order to comment it out, which adds
lines. That is fixed up right after, but that all can be inside #if part
that is not processed, so fix up also after every end of a conditional part.

llvm-svn: 186763
2013-07-20 14:23:27 +00:00
Benjamin Kramer a3d5304ec0 Silence GCC warning for using both enum and unsigned in a ternary expr.
llvm-svn: 186762
2013-07-20 12:06:17 +00:00
David Majnemer 38af2a2158 DiagnosticIDs: Forbid Diag ID from being valid
Diag ID is used throughout clang as a sentinel id meaning "this is an
invalid diagnostic id."  Confusingly, Diag ID maps to a valid, usable,
diagnostic id.  Instead, start diagnostic ids at ID one.

Incidently, remove an unused element from StaticDiagInfo.

llvm-svn: 186760
2013-07-20 07:15:15 +00:00
Richard Trieu 8ed6f2aacf If a default argument is a dependent type, get the real type from the desugared
template.  Passing around dependent types can lead to integral arguments that
cannot be evaluated.

llvm-svn: 186757
2013-07-20 03:49:02 +00:00
Eli Friedman a54333264a Fix bug in computing POD-for-layout.
A class with a field of non-POD-for-layout type is not POD-for-layout.
This computation should not depend on whether the field is of POD type
in the language sense.

Fixes PR16537.

Patch by Josh Magee.

llvm-svn: 186741
2013-07-20 01:06:31 +00:00
Eli Friedman 75807f239e Make IgnoreParens() look through ChooseExprs.
This is the same way GenericSelectionExpr works, and it's generally a
more consistent approach.

A large part of this patch is devoted to caching the value of the condition
of a ChooseExpr; it's needed to avoid threading an ASTContext into
IgnoreParens().

Fixes <rdar://problem/14438917>.

llvm-svn: 186738
2013-07-20 00:40:58 +00:00
Larisse Voufo 98b20f1278 FIXME fix: improving diagnostics for template arguments deduction of class templates and explicit specializations
This patch essentially removes all the FIXMEs following calls to DeduceTemplateArguments() that want to keep track of deduction failure info.

llvm-svn: 186730
2013-07-19 23:00:19 +00:00
Larisse Voufo 47c0845e0b Revert "Use function overloading instead of template specialization for diagnosis of bad template argument deductions."
This reverts commit a730f548325756d050d4caaa28fcbffdae8dfe95.

llvm-svn: 186729
2013-07-19 22:53:23 +00:00
Eli Friedman fa163749c7 Fix pack instantiation with function types.
Make sure we correctly expand packs which expand to another
pack in a function type.

llvm-svn: 186728
2013-07-19 22:50:29 +00:00
Larisse Voufo 8d33da6d58 Use function overloading instead of template specialization for diagnosis of bad template argument deductions.
llvm-svn: 186727
2013-07-19 22:34:32 +00:00
Eli Friedman 5e05c4afe4 Correctly handle packs for variadic type traits.
I'm not sure how to write a test for this; the following shows the
difference in -ast-dump:

template <int x> struct A {};
template <class T> struct B { };
template <class ...Args> using C = A<(__is_trivially_constructible(Args...))>;
template <class ...Args> using D = C<B<Args>...>;

However, I can't seem to write a test that triggers a visible difference
in behavior.

llvm-svn: 186726
2013-07-19 21:49:32 +00:00
Hans Wennborg e4b031ca03 Add a cl.exe compatible driver mode
The mode doesn't actually do anything yet, but this provides a
way to get into it.

llvm-svn: 186720
2013-07-19 20:33:20 +00:00
Jean-Daniel Dupas 06028a5454 Fix another place where clang check objc selector name instead of checking the selector family
Summary: In ARC mode, clang emits a warning if the result of an 'init' method is unused but miss cases where the method does not follows the Cocoa naming convention but is properly declared as an init family method.

CC: cfe-commits, eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1163

llvm-svn: 186718
2013-07-19 20:25:56 +00:00
Fariborz Jahanian c1c44f62bc ObjectiveC migrator: Another use case of enum
declaration which can be migrated to NS_ENUM.

llvm-svn: 186716
2013-07-19 20:18:36 +00:00
Samuel Benzaquen b837248ad4 Add support for raw_ostream on the printing methods of Diagnostics.
Summary:
Add printToStream*(llvm::raw_ostream&) methods to Diagnostics, and reimplement everything based on streams instead of concatenating strings.
Also, fix some functions to start with lowercase to match the style guide.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1187

llvm-svn: 186715
2013-07-19 20:02:35 +00:00
Reid Kleckner 569b8f83a4 Create calling convention AttributedType sugar nodes
Canonical types are unchanged.  The type printer had to be changed to
avoid printing any non-default implicit calling convention as well as
the calling convention attribute.

Reviewers: rjmccall

Differential Revision: http://llvm-reviews.chandlerc.com/D1132

llvm-svn: 186714
2013-07-19 19:51:03 +00:00
Eli Friedman 8917ad5d1f Fix for template substitution with packs.
When we see a pack, and replace it with a template argument which is
also a pack, we want to use the pack pattern, not the expanded pack.
The caller should take care of expanding the pack afterwards.

Fixes PR16646.

llvm-svn: 186713
2013-07-19 19:40:38 +00:00
Akira Hatanaka 0aa60efe9c [mips] Add support for command-line options -mno-check-zero-division and
-mcheck-zero-division.

llvm-svn: 186710
2013-07-19 18:58:48 +00:00
Argyrios Kyrtzidis 47b1517c52 [arcmt] After checking is successful disable auto-synthesize to avoid "@synthesize of 'weak' property is only
allowed in ARC" errors.

rdar://14461559

llvm-svn: 186709
2013-07-19 18:57:15 +00:00
Aaron Ballman db6d85ef92 Replace some existing type attribute diagnostics with a
single diagnostic that selects.  No functional changes intended.

llvm-svn: 186708
2013-07-19 18:53:44 +00:00
John Thompson cda95fe72c Add SourceRange to PPCallbacks::Defined callback.
llvm-svn: 186707
2013-07-19 18:50:04 +00:00
Enea Zaffanella 25723ce6fc Fix source range of implicitly instantiated friend declaration.
llvm-svn: 186702
2013-07-19 18:02:36 +00:00
Fariborz Jahanian 008ef72bee Fixes an ObjC migrator crash when last decl
in file is an enum.

llvm-svn: 186700
2013-07-19 17:44:32 +00:00
Roman Divacky 4dcb5dbb53 This patch implements __get_cpuid_max() as an inline and __cpuid() and
__cpuid_count() as macros to be compatible with GCC's cpuid.h.  It also adds
bit_<foo> constants for the various feature bits as described in version 039
(May 2011) of Intel's SDM Volume 2 in the description of the CPUID
instruction.  The list of bit_<foo> constants is a bit exhaustive (GCC
doesn't do near this many).  More bits could be added from a newer version of
SDM if desired.

Patch by John Baldwin!

llvm-svn: 186696
2013-07-19 17:28:36 +00:00
Richard Sandiford 4652d893bc [SystemZ] Add -march= command-line option
llvm-svn: 186694
2013-07-19 16:51:51 +00:00
Richard Sandiford 896f8db0bd [SystemZ] Enable frame-pointer elimination for -O1 and above
Copies the x86 behavior.

llvm-svn: 186674
2013-07-19 14:06:49 +00:00
Manuel Klimek 7a698519e8 Allow clang tools to display an overview when using the CommonOptionsParser.
Patch by Guillaume Papin.

llvm-svn: 186671
2013-07-19 12:20:59 +00:00
Timur Iskhodzhanov 03e8746f90 Simplify the CodeGenFunction::Build*Virtual*Call family of functions
llvm-svn: 186657
2013-07-19 08:14:45 +00:00
Craig Topper 61d01cc95e Remove trailing whitespace.
llvm-svn: 186652
2013-07-19 04:46:31 +00:00
Craig Topper ed1236d041 Remove unnecessary IsFirst variable from debug codde in GetDiagInfo.
llvm-svn: 186649
2013-07-19 03:59:51 +00:00
Alexey Bataev 5ec3eb11fc OpenMP: basic support for #pragma omp parallel
llvm-svn: 186647
2013-07-19 03:13:43 +00:00
Fariborz Jahanian b0057bb4fc ObjectiveC migrator: add support to migrate to
NS_OPTIONS.

llvm-svn: 186641
2013-07-19 01:05:49 +00:00
Jordan Rose e9c57229f9 [analyzer] Include analysis stack in crash traces.
Sample output:

0.     Program arguments: ...
1.     <eof> parser at end of file
2.     While analyzing stack:
       #0 void inlined()
       #1 void test()
3.     crash-trace.c:6:3: Error evaluating statement

llvm-svn: 186639
2013-07-19 00:59:08 +00:00
Eric Christopher 978c839315 Update createCompileUnit call for llvm changes.
llvm-svn: 186638
2013-07-19 00:51:58 +00:00
Eli Friedman ebea0f29e2 Clean up diagnostics for inheriting constructors.
No new diagnostics, just better wording and notes pointing at more
relevant locations.

llvm-svn: 186629
2013-07-18 23:29:14 +00:00
Fariborz Jahanian 85e988bbea ObjectiveC migrator: Remove semicolon after the typedef
declaration when converting to NS_ENUM. This required
some code refactoring.

llvm-svn: 186619
2013-07-18 22:17:33 +00:00
Hans Wennborg 5937ec7502 Address -Wreorder warning in Driver.cpp
llvm-svn: 186617
2013-07-18 21:45:42 +00:00
Hans Wennborg 70850d83dc Turn Driver::CCCIsCXX and CCCIsCPP into a single Mode enum,
and add a new option --driver-mode= to control it explicitly.

The CCCIsCXX and CCCIsCPP flags were non-overlapping, i.e. there
are currently really three modes that Clang can run in: gcc, g++
or cpp, so it makes sense to represent them as an enum.

Having a command line flag to control it helps testing.

llvm-svn: 186605
2013-07-18 20:29:38 +00:00
Fariborz Jahanian 92463274e6 ObjectiveC migration. migration to NS_ENUM/SN_OPTION
- wip.

llvm-svn: 186604
2013-07-18 20:11:45 +00:00
Samuel Benzaquen a37bb8c01a Separate the notion of 'context' when recursing down in the parser and actual errors.
Summary:
Change how error messages are constructed and stored in Diagnostics.
Separate the notion of 'context' when recursing down in the parser and actual errors.
This will simplify adding some new features, like argument overloading and error recovery.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1168

llvm-svn: 186602
2013-07-18 19:47:59 +00:00
Aaron Ballman c2cbc66e7a Switching to use checkAttributeNumArgs for trivial cases. No functional changes intended.
llvm-svn: 186591
2013-07-18 18:01:48 +00:00
Aaron Ballman f90ccb082b Replacing a morally duplicate diagnostic by adding it to an existing diagnostic's select list. Updates the tests for the more consistent diagnostic.
llvm-svn: 186584
2013-07-18 14:56:42 +00:00
Daniel Jasper 998cabcff4 clang-format: Fix bad line break with pointers to members.
Before:
  void f() {
    (a->*
     aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(aaaa,
                                           bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
  }

After:
  void f() {
    (a->*aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)(
        aaaa, bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb);
  }

Also add missing test case.

llvm-svn: 186583
2013-07-18 14:46:07 +00:00
Manuel Klimek be0474c047 Fix crash in libclang if code completion is used with unknown flags.
Use CaptureDroppedDiagnostics to make sure that there is a diagnostic
client installed when warning flags are parsed.

llvm-svn: 186582
2013-07-18 14:23:12 +00:00
Aaron Ballman 8b8ebdd9dd Removed a parameter from handleAttrWithMessage to make it more consistent with other attribute handlers, as well as other attribute error messages. Added missing test cases for the unavailable attribute, and updated the deprecated test case.
llvm-svn: 186578
2013-07-18 13:13:52 +00:00
Adrian Prantl b75016d299 s/BuiltinLocation/ArtificialLocation/
llvm-svn: 186557
2013-07-18 01:36:04 +00:00
Eric Christopher f8bc4d878c Instead of checking against some version of "isType()" go ahead and
use the conversion to bool to check if we've managed to get a type
that isn't default constructed - as we meant to in the first place.

llvm-svn: 186556
2013-07-18 00:52:50 +00:00
Adrian Prantl 593f10ed81 Fix a compile error caught by bb-chapuni.
llvm-svn: 186555
2013-07-18 00:47:12 +00:00
Adrian Prantl 9aab9002a6 Fix a compile error caught by bb-chapuni.
llvm-svn: 186554
2013-07-18 00:43:29 +00:00
Adrian Prantl 01eb2a53c7 Don't generate bogus line table entries for __copy_helper_block_ and
__destroy_helper_block_, but do generate scope information.

llvm-svn: 186553
2013-07-18 00:28:05 +00:00
Adrian Prantl 2e0637ff63 Replace llvm::DIBuilder::DisableDebugLocations() with two RAII interfaces
inspired by CodegenFunction::LexicalScope.
- NoLocation temporarily turns off debug locations altogether.
  This is useful for emitting instructions that should be
  counted towards the function prologue.
- BuiltinLocation temporarily switches to an artificial debug location
  that has a valid scope, but no line information. This is useful when
  emitting compiler-generated helper functions that have no source
  location associated with them.

llvm-svn: 186552
2013-07-18 00:28:02 +00:00
Adrian Prantl 02c0caa198 Clarified documentation.
llvm-svn: 186551
2013-07-18 00:27:59 +00:00
Adrian Prantl b1b3bfc068 Simplify logic by using the appropriate function.
llvm-svn: 186550
2013-07-18 00:27:56 +00:00
John Thompson b102856b0e Add condition expression result to if and elif callbacks.
llvm-svn: 186547
2013-07-18 00:00:36 +00:00
Richard Smith 6401768ac4 Reinstate r186040, with additional fixes and more test coverage (reverted in
r186331).

Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186546
2013-07-17 23:53:16 +00:00
Eric Christopher ffdeb1eb03 80-column fixes.
llvm-svn: 186542
2013-07-17 22:52:53 +00:00
Robert Wilhelm 57c6711893 Even more code conformance.
llvm-svn: 186537
2013-07-17 21:14:35 +00:00
Reid Kleckner 736bc98f9c MS wide bitfield error check in Sema
cl.exe treats wide bitfields as an error. This patch causes them to be
an error if IsMsStruct is true, as it is in straight C.

Patch by Warren Hunt!

Reviewers: eli.friedman

Differential Revision: http://llvm-reviews.chandlerc.com/D1125

llvm-svn: 186536
2013-07-17 20:46:03 +00:00
Daniel Jasper ee6d650f91 clang-format: Add space in corner case.
Before:
  SomeType s __attribute__((unused))(InitValue);
After:
  SomeType s __attribute__((unused)) (InitValue);

llvm-svn: 186535
2013-07-17 20:25:02 +00:00
David Blaikie 301fe5f69b Constify Replacements parameter to applyAllReplacements.
http://llvm-reviews.chandlerc.com/D1169

Patch by Guillaume Papin.

llvm-svn: 186526
2013-07-17 18:29:58 +00:00
Jean-Daniel Dupas 3965574929 Improve idiomatic-parentheses by checking method family instead of relying on the selector name.
llvm-svn: 186524
2013-07-17 18:17:14 +00:00
NAKAMURA Takumi 3e7db845f7 SemaDeclCXX.cpp: Dissolve a ligature "fi" in comment.
llvm-svn: 186523
2013-07-17 17:57:52 +00:00
Enea Zaffanella c70b2519d5 Fixed source range of C++03 access declarations.
llvm-svn: 186522
2013-07-17 17:28:56 +00:00
Jordan Rose 5f6c173e7c [analyzer] Handle C++11 member initializer expressions.
Previously, we would simply abort the path when we saw a default member
initialization; now, we actually attempt to evaluate it. Like default
arguments, the contents of these expressions are not actually part of the
current function, so we fall back to constant evaluation.

llvm-svn: 186521
2013-07-17 17:16:42 +00:00
Jordan Rose 5fded08403 [analyzer] Handle C string default values for const char * arguments.
Previously, SValBuilder knew how to evaluate StringLiterals, but couldn't
handle an array-to-pointer decay for constant values. Additionally,
RegionStore was being too strict about loading from an array, refusing to
return a 'char' value from a 'const char' array. Both of these have been
fixed.

llvm-svn: 186520
2013-07-17 17:16:38 +00:00
Jordan Rose 05b2f98d89 [analyzer] Treat std::initializer_list as opaque rather than aborting.
Previously, the use of a std::initializer_list (actually, a
CXXStdInitializerListExpr) would cause the analyzer to give up on the rest
of the path. Now, it just uses an opaque symbolic value for the
initializer_list and continues on.

At some point in the future we can add proper support for initializer_list,
with access to the elements in the InitListExpr.

<rdar://problem/14340207>

llvm-svn: 186519
2013-07-17 17:16:33 +00:00
Hans Wennborg fb624ce885 Option parsing tables: remove some unnecessary #defines
Also make some strings static and add missing #undef's

llvm-svn: 186518
2013-07-17 16:54:06 +00:00
Daniel Jasper c834c70986 Improve line breaking before multi-line strings.
The AlwaysBreakBeforeMultilineStrings rule does not really make sense
if it does not a column gain.

Before (in Google style):
  f(
      "aaaa"
      "bbbb");

After:
  f("aaaa"
    "bbbb");

llvm-svn: 186515
2013-07-17 15:38:19 +00:00
Samuel Benzaquen 21b3da0f93 Add TemplateArgument related matchers to the registry.
Summary:
Continue adding more matchers to the dynamic registry.
This time, we add TemplateArgument matchers.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1166

llvm-svn: 186514
2013-07-17 15:11:30 +00:00
Samuel Benzaquen 06e056c4d8 Add CXXCtorInitializer related matchers to the dynamic matcher registry.
Summary: Now that CXXCtorInitializer is already supported in ASTNodeKind, add CXXCtorInitializer matchers to the dynamic matcher registry.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1158

llvm-svn: 186508
2013-07-17 14:28:00 +00:00
Pavel Labath 9ced602cc6 [analyzer] Add very limited support for temporary destructors
Summary:
This patch enables ExprEndgine to reason about temporary object destructors.
However, these destructor calls are never inlined, since this feature is still
broken. Still, this is sufficient to properly handle noreturn temporary
destructors and close bug #15599. I have also enabled the cfg-temporary-dtors
analyzer option by default.

Reviewers: jordan_rose

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1131

llvm-svn: 186498
2013-07-17 08:33:58 +00:00
JF Bastien 27dcbb24e5 Propagate alignment for _Complex
_Complex load/store didn't have their alignment set properly, which was visible when GCC's torture tests use volatile _Complex.

Update some existing tests to check for alignment, and add a new test which also has over-aligned volatile _Complex (since the imaginary part shouldn't be overaligned, only the real part).

llvm-svn: 186490
2013-07-17 05:57:42 +00:00
Rafael Espindola a07f720a1b Use the simpler is_directory.
llvm-svn: 186487
2013-07-17 04:23:07 +00:00
Fariborz Jahanian dfb7687162 More code conformance.
llvm-svn: 186474
2013-07-17 00:05:08 +00:00
Fariborz Jahanian cb7b8deecb ObjectiveC migrator: When adding conforming protocol,
only add outer-most conforming protocols as adding
others are redundant.

llvm-svn: 186473
2013-07-17 00:02:22 +00:00
Alexander Kornienko 9404234241 Avoid breaking non-trailing block comments.
Motivating example:
// column limit ------------------->
void ffffffffffff(int aaaaaa /* test */);

Formatting before the patch:
void ffffffffffff(int aaaaaa /* test
                              */);

Formatting after the patch:
void
ffffffffffff(int aaaaaa /* test */);

llvm-svn: 186471
2013-07-16 23:47:22 +00:00
Eli Friedman 4c27ac2348 Make Expr::isConstantInitializer match IRGen.
Sema needs to be able to accurately determine what will be
emitted as a constant initializer and what will not, so
we get accurate errors in C and accurate -Wglobal-constructors
warnings in C++.  This makes Expr::isConstantInitializer match
CGExprConstant as closely as possible.

llvm-svn: 186464
2013-07-16 22:40:53 +00:00
Argyrios Kyrtzidis 884bee86a6 [arcmt] Remove some dead code.
Patch by Rafael Espíndola.

llvm-svn: 186462
2013-07-16 22:24:06 +00:00
Fariborz Jahanian 2bc3dda186 ObjectiveC migrator. If a class implements a protocol's
properties, then class conforms to that protocol.

llvm-svn: 186460
2013-07-16 21:59:42 +00:00
Alexander Kornienko 657c67b164 Don't break line comments with escaped newlines.
Summary:
These can appear when comments contain command lines with quoted line
breaks. As the text (including escaped newlines and '//' from consecutive lines)
is a single line comment, we used to break it even when it didn't exceed column
limit. This is a temporary solution, in the future we may want to support this
case completely - at least adjust leading whitespace when changing indentation
of the first line.

Reviewers: djasper

Reviewed By: djasper

CC: cfe-commits, klimek

Differential Revision: http://llvm-reviews.chandlerc.com/D1146

llvm-svn: 186456
2013-07-16 21:06:13 +00:00
Daniel Jasper 8369aa5e12 clang-format: Improve handling of unterminated string literals.
Before, clang-format would simply eat these as they were recognized as
whitespace. With this patch, they are mostly left alone.

llvm-svn: 186454
2013-07-16 20:28:33 +00:00
Eli Friedman 64f2391899 Fix crash on complex constant zero.
Fixes <rdar://problem/14442543>.

llvm-svn: 186452
2013-07-16 20:19:04 +00:00
Rafael Espindola 16125fb652 Update for llvm API change.
llvm-svn: 186448
2013-07-16 19:44:23 +00:00
Fariborz Jahanian 3eb3159816 ObjectiveC migration: complete migrating class
declaration to include list of protocols class
conforms to. 

llvm-svn: 186443
2013-07-16 18:58:41 +00:00
Craig Topper f59ba9f545 Fix formatting. No functional change.
llvm-svn: 186437
2013-07-16 18:27:27 +00:00
Daniel Jasper 6ab5468637 Revamp the formatting of C++11 braced init lists.
The fundamental concept is:
Format as if the braced init list was a function call (with parentheses
replaced by braces). If there is no name/type before the opening brace
(e.g. if the braced list is nested), assume a zero-length identifier
just before the opening brace.

This behavior is gated on a new style flag, which for now replaces the
SpacesInBracedLists style flag. Activate this style flag for Google
style to reflect recent style guide changes.

llvm-svn: 186433
2013-07-16 18:22:10 +00:00
Samuel Benzaquen 0dbabb52a4 Add more types to ASTNodeKind. Refactor common instantiation code.
Summary:
Add support for CXXCtorInitializer and TemplateArgument types to ASTNodeKind.
This change is to support more matchers from clang/ASTMatchers/ASTMatchers.h in the dynamic layer (clang/ASTMatchers/Dynamic).

Reviewers: klimek

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1143

llvm-svn: 186422
2013-07-16 15:47:24 +00:00
Fariborz Jahanian 0080fb5a18 This patch removes unused parameter allProperties and converts remaining
parameters in ArrayRef'ize Sema::ActOnAtEnd  to ArrayRef.
Patch by Robert Wilhelm.

llvm-svn: 186421
2013-07-16 15:33:19 +00:00
Manuel Klimek 6a46149cb1 Remove unnecessary assignment.
llvm-svn: 186412
2013-07-16 13:58:44 +00:00
Manuel Klimek 55d8fb56d3 Fixes another hard to test problem with iterator invalidation.
As every match call can recursively call back into the memoized match
via a nested traversal matcher (for example:
stmt(hasAncestor(stmt(hasDescendant(stmt(hasDescendant(stmt()))))))),
and every memoization step might clear the cache, we must not store
iterators into the result cache when calling match on a submatcher.

llvm-svn: 186411
2013-07-16 13:20:30 +00:00
Daniel Jasper 655d96ab3b clang-format: Improve detection of function types.
This fixes an incorrect detection that led to a formatting error.
Before:
  some_var = function (*some_pointer_var)[0];
After:
  some_var = function(*some_pointer_var)[0];

llvm-svn: 186402
2013-07-16 11:37:21 +00:00
Tim Northover 6aacd49094 ARM: implement low-level intrinsics for the atomic exclusive operations.
This adds three overloaded intrinsics to Clang:
    T __builtin_arm_ldrex(const volatile T *addr)
    int __builtin_arm_strex(T val, volatile T *addr)
    void __builtin_arm_clrex()

The intent is that these do what users would expect when given most sensible
types. Currently, "sensible" translates to ints, floats and pointers.

llvm-svn: 186394
2013-07-16 09:47:53 +00:00
Serge Pavlov dfdb731967 Limit number of bits in size representation so that bit size fit 64 bits.
This fixes PR8256 and some others.

llvm-svn: 186385
2013-07-16 07:14:18 +00:00
Craig Topper 694ddc73ea Add 'const' qualifiers to static const char* variables.
llvm-svn: 186383
2013-07-16 05:03:10 +00:00
Eli Friedman e7b8aa9417 Merge attributes on typedef decls.
Not completely sure this is right, but it's clearly better than what
we did before this commit (effectively dropping the attribute).

<rdar://problem/14413117>

llvm-svn: 186373
2013-07-16 02:07:49 +00:00
Eli Friedman 69d27d2d05 Fix alignment of class derived from empty class.
The record layout code didn't properly take into account that
an empty class at offset 0 can have an alignment greater than 1.

Patch by Andrea Di Biagio.

llvm-svn: 186370
2013-07-16 00:21:28 +00:00
Fariborz Jahanian 5bd5affe2d ObjC migrator: build conforming interface
declaration (not yet used). wip.

llvm-svn: 186369
2013-07-16 00:20:21 +00:00
Eli Friedman cccd06487d Fix member refs with using decl + anonymous union.
Make sure we call BuildFieldReferenceExpr with the appropriate decl
when a member of an anonymous union is made public with a using decl.
Also, fix a crash on invalid field access into an anonymous union.

Fixes PR16630.

llvm-svn: 186367
2013-07-16 00:01:31 +00:00
Fariborz Jahanian d36150d7ca ObjC migrator: finding conforming protocol
candidates for each class. wip.

llvm-svn: 186349
2013-07-15 21:22:08 +00:00
Kaelyn Uhrain bad7fb09b2 Move the "->" to "." fixit from r186128 into a separate note since
recovery is not attempted with the fixit. Also move the associated test
case from FixIt/fixit.cpp to SemaCXX/member-expr.cpp since the fixit is
no longer automatically applied.

llvm-svn: 186342
2013-07-15 19:54:54 +00:00
Samuel Benzaquen 79656e19c8 Add support for type traversal matchers.
Summary:
Fixup the type traversal macros/matchers to specify the supported types.
Make the marshallers a little more generic to support any variadic function.
Update the doc script.

Reviewers: klimek

CC: cfe-commits, revane

Differential Revision: http://llvm-reviews.chandlerc.com/D1023

llvm-svn: 186340
2013-07-15 19:25:06 +00:00
Chandler Carruth 9324d169bd Re-revert r86040, which was un-reverted in r186199.
This breaks the build of basic patterns with repeated friend
declarations. See the added test case in SemaCXX/friend.cpp or the test
case reported to the original commit log.

Original commit log:
  If we friend a declaration twice, that should not make it visible to
  name lookup in the surrounding context. Slightly rework how we handle
  friend declarations to inherit the visibility of the prior
  declaration, rather than setting a friend declaration to be visible
  whenever there was a prior declaration.

llvm-svn: 186331
2013-07-15 17:27:42 +00:00
Daniel Jasper 49a9448d95 clang-format: Improve c-style cast detection.
Before:
  #define x ((int) - 1)
  #define p(q) ((int *) & q)
After:
  #define x ((int)-1)
  #define p(q) ((int *)&q)

llvm-svn: 186324
2013-07-15 15:04:42 +00:00
Daniel Jasper fa21c0724c Improvement of change r186320.
Fixed a test that by now passed for the wrong reason.

Before:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(
                                                 aaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
  llvm::outs() << "aaaaaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);

Also reformatted Format.cpp with the latest changes (1 formatting fix
and 1 layout change of a <<-chain).

llvm-svn: 186322
2013-07-15 14:33:14 +00:00
Daniel Jasper 0d5e44df3c Improve formatting of operator<< chains.
Before:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

After:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

llvm-svn: 186320
2013-07-15 14:12:30 +00:00
Aaron Ballman d0d27ab306 Replacing an empty switch with its moral equivalent. No functional changes intended.
llvm-svn: 186318
2013-07-15 13:41:33 +00:00
Craig Topper d6d31aceea Add 'static' and 'const' qualifiers to some arrays of strings.
llvm-svn: 186314
2013-07-15 08:24:27 +00:00
Serge Pavlov 7cd8f6020f Fix to PR12262 - assertion when substituting explicit template arguments
does not substitute a sizeof-pack expression.
The solution is proposed by Richard Smith.
Differential Revision: http://llvm-reviews.chandlerc.com/D869

llvm-svn: 186306
2013-07-15 06:14:07 +00:00
Craig Topper e5ce831c7c Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).
llvm-svn: 186300
2013-07-15 03:38:40 +00:00
Eric Christopher e9348f6df5 Reformat line.
llvm-svn: 186294
2013-07-14 21:15:27 +00:00
Eric Christopher 324bbbd16a Move BlockLiteralGeneric earlier in CGDebugInfo and remove
BlockLiteralGenericSet and replace with a call to isType() on the
BlockLiteralGeneric.

llvm-svn: 186293
2013-07-14 21:12:44 +00:00
Eric Christopher 35f1f9fc28 Update a few comments and reformat a decl for clarity.
llvm-svn: 186292
2013-07-14 21:00:07 +00:00