Commit Graph

16202 Commits

Author SHA1 Message Date
Alp Toker bfa3934f27 Rename language option MicrosoftMode to MSVCCompat
There's been long-standing confusion over the role of these two options. This
commit makes the necessary changes to differentiate them clearly, following up
from r198936.

MicrosoftExt (aka. fms-extensions):
 Enable largely unobjectionable Microsoft language extensions to ease
 portability. This mode, also supported by gcc, is used for building software
 like FreeBSD and Linux kernel extensions that share code with Windows drivers.

MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode):
 Turn on a special mode supporting 'heinous' extensions for drop-in
 compatibility with the Microsoft Visual C++ product. Standards-compilant C and
 C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt.

Note that full -fms-compatibility mode is currently enabled by default on the
Windows target, which may need tuning to serve as a reasonable default.

See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined
type_info out of InitializePredefinedMacros'

No change in behaviour.

llvm-svn: 199209
2014-01-14 12:51:41 +00:00
Aaron Ballman 05d76eaa21 Removing some attribute magic related to the OpenCL keyword attributes. Instead of mapping them to their semantics as a custom part of the parser, they instead map declaratively through the rest of the attribute system.
llvm-svn: 199175
2014-01-14 01:29:54 +00:00
DeLesley Hutchins f28bbec90e Consumed analysis: add two new attributes which fine-tune the behavior of
consumable objects.  These are useful for implementing error codes that
must be checked.  Patch also includes some significant refactoring, which was
necesary to implement the new behavior.

llvm-svn: 199169
2014-01-14 00:36:53 +00:00
Aaron Ballman 530740be50 Updating the attribute declarations to have the correct syntaxes. This means giving a __declspec spelling to: deprecated, naked, noinline, noreturn, and nothrow. uuid has no GNU spelling, so it was switched to __declspec. dllexport and dllimport both are now supported with GNU spellings.
llvm-svn: 199142
2014-01-13 21:32:48 +00:00
Jordan Rose c9176072e6 [analyzer] Add a CFG node for the allocator call in a C++ 'new' expression.
In an expression like "new (a, b) Foo(x, y)", two things happen:
- Memory is allocated by calling a function named 'operator new'.
- The memory is initialized using the constructor for 'Foo'.

Currently the analyzer only models the second event, though it has special
cases for both the default and placement forms of operator new. This patch
is the first step towards properly modeling both events: it changes the CFG
so that the above expression now generates the following elements.

1. a
2. b
3. (CFGNewAllocator)
4. x
5. y
6. Foo::Foo

The analyzer currently ignores the CFGNewAllocator element, but the next
step is to treat that as a call like any other.

The CFGNewAllocator element is not added to the CFG for analysis-based
warnings, since none of them take advantage of it yet.

llvm-svn: 199123
2014-01-13 17:59:19 +00:00
Chandler Carruth 2192505190 [PM] Update Clang to reflect LLVM r199095 which moves the core DomTree
algorithms and datastructures into the fully generic support library,
separating them (almost) entirely from the LLVM IR. This makes the
reliance on domtrees here *much* cleaner.

It might be worthwhile for someone to use extern templates and other
tools to sink a lot more of this code into the .cpp files instead of the
.h files, but leaving that for someone other than me.

llvm-svn: 199096
2014-01-13 10:56:17 +00:00
Chandler Carruth ca88474aba [cleanup] Update the include of Dominators.h to reflect its move to the
IR library in LLVM r199082.

llvm-svn: 199083
2014-01-13 09:26:48 +00:00
Nico Weber 0e224700de Add help text for -MMD, -MD, -MM, -M, -MF.
Also regroup these flags so that alike flags are next to each other, while
keeping the list still mostly alphabetical.

The help text isn't ideal, but I feel it's less maze-like than
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Preprocessor-Options.html (look
at the entry for '-MMD' and count how many other entries you need to look up
until you know what it does).

And it looks like -M / -MM are mostly an historical accident and most people
use -MD or -MMD for deps tracking these days, so make -M / -MM refer to
-MD / -MMD instead of the other way round.

llvm-svn: 199067
2014-01-12 23:12:35 +00:00
Alp Toker 44e3905987 Clarify warn_cxx98_compat_attribute diagnostic
Various attribute flavours are supported in C++98. Make it clear that this
compatibility warning relates specifically to C++11-style generalized
attributes.

llvm-svn: 199053
2014-01-12 15:18:06 +00:00
Nick Lewycky 35a6ef4c35 Add a new attribute 'enable_if' which can be used to control overload resolution based on the values of the function arguments at the call site.
llvm-svn: 198996
2014-01-11 02:50:57 +00:00
Richard Smith 6fa28ffd5a Fix "regression" caused by updating our notion of POD to better match the C++11
rules: instead of requiring flexible array members to be POD, require them to
be trivially-destructible. This seems to be the only constraint that actually
matters here (and even then, it's questionable whether this matters).

llvm-svn: 198983
2014-01-11 00:53:35 +00:00
Fariborz Jahanian 26cb6d90b8 ObjectiveC. Remove warning on mismatched methods
which may belong to unrelated classes. It was
primarily intended for miuse of @selector expression.
But warning is too noisy and will be issued when
an actual @selector is used. // rdar://15740134

llvm-svn: 198952
2014-01-10 19:27:21 +00:00
Alp Toker 9f1d619c07 Remove unexpected code completion handling from ConsumeToken()
With this change tok::code_completion is finally handled exclusively as a
special token kind like other tokens that need special treatment.

All callers have been updated to use the specific token consumption methods and
the parser has a clear idea the current token isn't special by the time
ConsumeToken() gets called, so this has been unreachable for some time.

ConsumeAnyToken() behaviour is unchanged and will continue to support
unexpected code completion as part of the special token path.

This survived an amount of fuzzing and validation, but please ping the list if
you hit a code path that previously relied on the old unexpected handler and
now asserts.

llvm-svn: 198942
2014-01-10 14:37:02 +00:00
Alp Toker b630b9d20a Update LangOpt descriptions
Based on recent discussions, attempt to provide a clearer distinction between
MicrosoftMode and MicrosoftExt. This still doesn't feel perfect but gives a
better idea which is which.

Also update the CPlusPlus11 description which got missed in r171367.

C++0x is dead, long live C++0x!

llvm-svn: 198936
2014-01-10 11:19:45 +00:00
Fariborz Jahanian 65b1377911 ObjectiveC. 1) Warn when @dynamic (as well as synthesize)
property has the naming convention that implies 'ownership'.
2) improve on diagnostic and make it property specific.
3) fix the line number in the case of default property
synthesis. // rdar://15757510

llvm-svn: 198905
2014-01-10 00:53:48 +00:00
Richard Smith 7073a2da15 Reapply r198845, reverted in r198849, with a fix to make it valid C++98, not
just valid C++11 =)

Original commit message:

PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on
SPARC, where uint64_t apparently requires higher alignment than void*.

llvm-svn: 198903
2014-01-10 00:40:45 +00:00
Aaron Ballman ab7691c4ce Removing the notion of TargetAttributesSema and replacing it with one where the parsed attributes are responsible for knowing their target-specific nature, instead of letting Sema figure it out. This is necessary so that __has_attribute can eventually determine whether a parsed attribute applies to the given target or not.
llvm-svn: 198896
2014-01-09 22:48:32 +00:00
Ben Langmuir de04923344 Preserve -fretain-comments-from-system-headers in modules
Preserves the setting of -fretain-comments-from-system-headers when
building/saving/loading module files. This allows code completion to pick up
documentation comments from system modules.

llvm-svn: 198890
2014-01-09 20:53:49 +00:00
Aaron Ballman 15b27b97b7 Removing a bit of custom parsing functionality used by the thread safety analysis APIs. Now using tablegen to determine whether an attribute's arguments should be parsed in an unevaluated context instead of relying on a separate, hard-coded list of attributes.
llvm-svn: 198883
2014-01-09 19:39:35 +00:00
Argyrios Kyrtzidis 62a85daecd Revert "PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on"
It broke building.
This reverts commit r198845.

llvm-svn: 198849
2014-01-09 05:01:04 +00:00
Richard Smith e2f4a2744c PR18427: Use an appropriately-aligned buffer in APValue, to avoid a crash on
SPARC, where uint64_t apparently requires higher alignment than void*.

llvm-svn: 198845
2014-01-09 03:29:54 +00:00
Chandler Carruth 439991d7e3 Update Clang's CFGBlock interface to conform to the strange part of
LLVM's Value interface which is used in LLVM's DominatorTree analysis
and which changed in LLVM r198836.

The DominatorTree analysis is actually a generic graph analysis and
should be moved to LLVM's support library to clarify that Clang and
others are using it with arbitrary graphs. Further, it seems likely that
it should be using something other than printAsOperand, but this is
a simpler build fix. I'll clean this up later.

llvm-svn: 198840
2014-01-09 02:56:16 +00:00
Richard Smith 83b11aae18 PR18401: Fix assert by implementing the current proposed direction of core
issue 1430. Don't allow a pack expansion to be used as an argument to an alias
template unless the corresponding parameter is a parameter pack.

llvm-svn: 198833
2014-01-09 02:22:22 +00:00
Warren Hunt d640d7d96e [ms-abi] Refactor Microsoft Record Layout
This patch refactors microsoft record layout to be more "natural".  The 
most dominant change is that vbptrs and vfptrs are injected after the 
fact.  This simplifies the implementation and the math for the offest 
for the first base/field after the vbptr.

llvm-svn: 198818
2014-01-09 00:30:56 +00:00
Aaron Ballman 8c7817ebb1 Attempting a fix the build bots should be happier with. Amends 198804.
llvm-svn: 198805
2014-01-08 23:26:53 +00:00
Aaron Ballman 199a78935e Silencing an MSVC warning about control reaching the end of a non-void function.
llvm-svn: 198804
2014-01-08 23:08:41 +00:00
Argyrios Kyrtzidis 9308f0ae80 [Serialization] In ASTReader::getInputFile record it when we didn't find the file to avoid looking it up again.
Hopefully addresses rdar://14514222.

llvm-svn: 198781
2014-01-08 19:13:34 +00:00
Aaron Ballman b8c0adeac8 Treating the RegParmAttr as a TypeAttr because that is what it is.
Patch reviewed by Rafael Espindola.

llvm-svn: 198765
2014-01-08 13:23:01 +00:00
Richard Smith 8bcc086e58 PR18400: ignore cv-qualifiers on the underlying type of an enumeration.
llvm-svn: 198723
2014-01-08 01:16:19 +00:00
Richard Smith 649c7b069f PR18234: Mark a tag definition as invalid early if it appears in a
type-specifier in C++. Some checks will assert in this case otherwise (in
particular, the access specifier may be missing if this happens inside a class
definition, due to a violation of an AST invariant).

llvm-svn: 198721
2014-01-08 00:56:48 +00:00
Jordan Rose 514f935411 [analyzer] Pointers escape into +[NSValue valueWithPointer:]...
...even though the argument is declared "const void *", because this is
just a way to pass pointers around as objects. (Though NSData is often
a better one.)

PR18262

llvm-svn: 198710
2014-01-07 21:39:48 +00:00
Jordan Rose 6ad4cb4eca [analyzer] Remove unused ARCNotOwnedSymbol retain count return effect.
RetainCountChecker has to track returned object values to know if they are
retained or not. Under ARC, even methods that return +1 are tracked by the
system and should be treated as +0. However, this effect behaves exactly
like NotOwned(ObjC), i.e. a generic Objective-C method that actually returns
+0, so we don't need a special case for it.

No functionality change.

llvm-svn: 198709
2014-01-07 21:39:41 +00:00
Nico Weber b00d66e6ac Shorten the output of `clang-format --version`, include revision number.
Before:
  $ clang-format  --version
  LLVM (http://llvm.org/):
    LLVM version 3.5svn
    Optimized build with assertions.
    Built Jan  3 2014 (14:28:46).
    Default target: x86_64-apple-darwin13.0.0
    Host CPU: core-avx-i

Now:
  $ bin/clang-format --version
  clang-format version 3.5 (198452)

llvm-svn: 198694
2014-01-07 16:27:35 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Argyrios Kyrtzidis d07dcdb958 For areVectorOperandsLaxBitCastable(), only return false if both opearands are vector types
and add a diagnostic when the operand is a vector and non-scalar value.

rdar://15722301

llvm-svn: 198680
2014-01-07 07:59:31 +00:00
Alp Toker f990cefc7e Bring back magic constants in the digraph diagnostic
This backs out changes in commit r198605 and part of r198604, replacing the
original tok::kw_template with a slightly more obvious placeholder
tok::unknown.

llvm-svn: 198666
2014-01-07 02:35:33 +00:00
Adrian Prantl a763447124 Implement a new -fstandalone-debug option. rdar://problem/15685848
It controls everything that -flimit-debug-info used to, plus the
vtable type optimization. The old -fno-limit-debug-info option is now an
alias to -fstandalone-debug and vice versa.

Standalone is the default on Darwin until dtrace is updated to work with
non-standalone debug info (rdar://problem/15758808).

Note: I kept the LimitedDebugInfo name in CodeGenOptions::DebugInfoKind
because NoStandaloneDebugInfo sounded even more confusing.

llvm-svn: 198655
2014-01-07 01:19:08 +00:00
Justin Bogner 6a9d2cfadd Driver: Accept -fprofile-instr-use and -fprofile-instr-generate
These flags will be used for instrumentation based PGO.

llvm-svn: 198639
2014-01-06 22:27:36 +00:00
Alp Toker b3f9501b25 Prospective MSVC 2010 build fix
Try to fix Compiler Error C2011 following r198607 by removing enum from 'enum
TokenKind' parameter types.

llvm-svn: 198621
2014-01-06 15:52:13 +00:00
Alp Toker e9ab39da86 Correct underlying integer type of enum TokenKind
This matches up the underlying type against the actual storage type 'unsigned
short' and lets us get rid of some casts while we're at it.

Effort is made to keep this building in pre-C++11 but as with other features
Token will be less efficiently packed in in legacy configurations.

llvm-svn: 198607
2014-01-06 12:54:51 +00:00
Alp Toker 01d65e1387 Simplify diagnostic tag type using the token kind formatter
As far as the parser is concerned the tag type is always a keyword.

llvm-svn: 198606
2014-01-06 12:54:41 +00:00
Alp Toker addd3669d4 Don't use magic constants in the digraph diagnostic
llvm-svn: 198605
2014-01-06 12:54:32 +00:00
Alp Toker a231ad2216 Support diagnostic formatting of keyword tokens
Implemented with a new getKeywordSpelling() accessor. Unlike getTokenName() the
result of this function is stable and may be used in diagnostic output.

Uses of this feature are split out into the subsequent commit.

llvm-svn: 198604
2014-01-06 12:54:18 +00:00
Alp Toker 6d35eab5a6 Rename getTokenSimpleSpelling() to getPunctuatorSpelling()
That's what it does, what the documentation says it does and what callers
expect it to do.

llvm-svn: 198603
2014-01-06 12:54:07 +00:00
Alp Toker b9fa512954 Highlight the previous underlying enum type when diagnosing a mismatch
enum-scoped.cpp:93:6: error: enumeration redeclared with different underlying type 'short' (was 'int')
  enum Redeclare6 : short;
       ^
enum-scoped.cpp:92:6: note: previous declaration is here
  enum Redeclare6 : int;
       ^            ~~~

The redeclaration source range is still missing but this is a step forward,
potentially edging towards a FixIt.

llvm-svn: 198601
2014-01-06 11:31:18 +00:00
Alp Toker 6e97a69200 Use token kind instead of '%select{.|->}0' in diagnostic
llvm-svn: 198599
2014-01-06 11:30:41 +00:00
Alp Toker 637b347ed0 Apply some LLVM_READONLY / LLVM_READNONE on diagnostic functions
llvm-svn: 198598
2014-01-06 11:30:15 +00:00
Joey Gouly 16cb99dd15 [OpenCL] Produce an error if an address space is used on the return
type of a function.

llvm-svn: 198597
2014-01-06 11:26:18 +00:00
Alp Toker ef6b007dc5 Only mark dump() function definitions 'used' in debug builds
This has the dual effect of (1) enabling more dead-stripping in release builds
and (2) ensuring that debug helper functions aren't stripped away in debug
builds, as they're intended to be called from the debugger.

Note that the attribute is applied to definitions rather than declarations in
headers going forward because it's now conditional on NDEBUG:

  /// \brief Mark debug helper function definitions like dump() that should not be
  /// stripped from debug builds.

Requires corresponding macro added in LLVM r198456.

llvm-svn: 198489
2014-01-04 13:47:14 +00:00
Reid Kleckner 5f08094106 [ms-cxxabi] Improve vbtable name mangling accuracy
Summary:
This makes us more compatible with MSVC 2012+ and fixes PR17748 where we
would give two tables the same name.

Rather than doing a fresh depth-first traversal of the inheritance graph
for every record's vbtables, now we memoize vbtable paths for each
record.  By doing memoization, we end up considering virtual bases of
subobjects that come later in the depth-first traversal.  Where
previously we would have ignored a virtual base that we'd already seen,
we now consider it for name mangling purposes without emitting a
duplicate vbtable for it.

Reviewers: majnemer

CC: cfe-commits

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

llvm-svn: 198462
2014-01-03 23:42:00 +00:00
Aaron Ballman 69714e78e0 Refactored Builtin::Context::isPrintfLike and isScanfLike into a helper function. The implementations are identical, except for the format arguments being searched for.
No functional changes intended.

llvm-svn: 198446
2014-01-03 20:10:54 +00:00
Aaron Ballman 1d17bde708 Marked the default constructor as an LLVM_DELETED_FUNCTION.
llvm-svn: 198435
2014-01-03 18:51:47 +00:00
Aaron Ballman 75ee4cc830 Removed one of the string versions of getQualifiedNameAsString, and switched over to using printQualifiedName where possible. No functional changes intended.
llvm-svn: 198433
2014-01-03 18:42:48 +00:00
Argyrios Kyrtzidis 2080d90f37 [objc] Refactor and improve functionality for the -Wunused-property-ivar warning.
- Remove the additions to ObjCMethodDecl & ObjCIVarDecl that were getting de/serialized and consolidate
  all functionality for the checking for this warning in Sema::DiagnoseUnusedBackingIvarInAccessor
- Don't check immediately after the method body is finished, check when the @implementation is finished.
  This is so we can see if the ivar was referenced by any other method, even if the method was defined after the accessor.
- Don't silence the warning if any method is called from the accessor silence it if the accessor delegates to another method via self.

rdar://15727325

llvm-svn: 198432
2014-01-03 18:32:18 +00:00
Aaron Ballman 7cb6741b3b We haven't cared about VS 2005 in a long time, and VS 2003 in even longer.
llvm-svn: 198429
2014-01-03 18:10:25 +00:00
Aaron Ballman b190f974c9 Fixed a FIXME; created a print method for Selectors that accepts a raw_ostream, and started using it in places it made sense.
No functional changes intended, just API cleanliness.

llvm-svn: 198428
2014-01-03 17:59:55 +00:00
Alexander Kornienko 6de39492da Make clang::ento::CreateAnalysisConsumer a part of a public interface of the static analyzer.
Summary:
This allows for a better alternative to the FrontendAction hack used in
clang-tidy in order to get static analyzer's ASTConsumer.

Reviewers: jordan_rose, krememek

Reviewed By: jordan_rose

CC: cfe-commits

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

llvm-svn: 198426
2014-01-03 17:23:10 +00:00
Aaron Ballman b9bb201194 Removing some more unnecessary manual quotes from diagnostics.
llvm-svn: 198420
2014-01-03 14:54:10 +00:00
Aaron Ballman 1fb3955cee Removing some more unnecessary manual quotes from diagnostics.
llvm-svn: 198418
2014-01-03 14:23:03 +00:00
Joey Gouly 96b94e610b [OpenCL] Variables in the constant address space must be initialized.
llvm-svn: 198417
2014-01-03 14:16:55 +00:00
Aaron Ballman 5dff61d322 Removing some more unnecessary manual quotes from diagnostics.
llvm-svn: 198416
2014-01-03 14:06:37 +00:00
Aaron Ballman fee0cd45fe Removing some more unnecessary manual quotes from diagnostics. Updated the related test case to ensure correctness.
llvm-svn: 198412
2014-01-03 13:34:55 +00:00
Aaron Ballman 6d086d7dc1 Removing some more unnecessary manual quotes from diagnostics.
llvm-svn: 198395
2014-01-03 02:20:27 +00:00
Aaron Ballman 25dc1e1d19 Removing some more unnecessary manual quotes from attribute diagnostics.
llvm-svn: 198392
2014-01-03 02:14:08 +00:00
Aaron Ballman c0550740f0 Removing some more unnecessary manual quotes from attribute diagnostics.
llvm-svn: 198391
2014-01-03 02:07:43 +00:00
Aaron Ballman 1bda4596b6 Removing some more unnecessary manual quotes from attribute diagnostics.
llvm-svn: 198387
2014-01-03 01:09:27 +00:00
Reid Kleckner b40a27dad8 [ms-cxxabi] Move VBTableBuilder from CodeGen over to AST/VTableBuilder.cpp
Summary:
No functionality change.

This code should live here long-term because we should be able to use it
to compute correct vftable names.

It turns out that the most natural way to implement the naming algorithm
is to use a caching layer similar to what we already have for virtual
table info in VTableContext.  Subsequent changes will take advantage of
this to fix PR17748, where we have a vbtable name collision.

Reviewers: majnemer

CC: cfe-commits

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

llvm-svn: 198380
2014-01-03 00:14:35 +00:00
Aaron Ballman 3d216a579c Removed an unnecessary %select from the alignas diagnostics. The attribute already knows how it was spelled.
llvm-svn: 198375
2014-01-02 23:39:11 +00:00
Aaron Ballman e2bb78a740 This diagnostic should not have had the manual quotation marks. Its only usage passed in an Attr object, which was already quoted when printing the diagnostic. However, there was no test case that caught this bug -- one has been added.
llvm-svn: 198373
2014-01-02 23:22:40 +00:00
Aaron Ballman 1da282ae2d Removing some more unnecessary manual quotes from attribute diagnostics. Updated the associated testcase because QualType pretty printing was an improvement.
llvm-svn: 198372
2014-01-02 23:15:58 +00:00
Aaron Ballman 9f6fec4419 Removing some more unnecessary manual quotes from attribute diagnostics.
llvm-svn: 198371
2014-01-02 23:02:01 +00:00
Aaron Ballman 34b3475cd3 Reworded the NSObject attribute diagnostics to be more consistent with other attribute diagnostics. Also updated the associated test case.
llvm-svn: 198368
2014-01-02 22:45:33 +00:00
Fariborz Jahanian 5b3105d2cb ObjectiveC. Remove false positive warning for missing property
backing ivar by not issuing this warning if ivar is referenced
somewhere and accessor makes method calls. // rdar://15727325

llvm-svn: 198367
2014-01-02 22:42:09 +00:00
Aaron Ballman 44ebc079b9 Removing some manual quotes from this diagnostic, since the AST diagnostics engine knows how to handle NamedDecl objects.
llvm-svn: 198365
2014-01-02 22:29:41 +00:00
Aaron Ballman 05e420abad Updated the wording of two attribute-related diagnostics so that they print the offending attribute name. Also updates the associated test cases.
llvm-svn: 198355
2014-01-02 21:26:14 +00:00
Alexander Kornienko ce9161a557 Added an option to avoid splitting certain kinds of comments into lines.
Summary: Added CommentPragmas option for this.

Reviewers: djasper, klimek

Reviewed By: klimek

CC: cfe-commits, klimek

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

llvm-svn: 198310
2014-01-02 15:13:14 +00:00
Alp Toker e83b9060cb Verify that clang TargetInfo descriptions match DataLayout strings from LLVM
The backend string is only verified when available as it's possible to run
clang IRGen for targets that haven't been built or don't exist in LLVM.

llvm-svn: 198309
2014-01-02 15:08:04 +00:00
Joey Gouly d4993032a9 [OpenCL] The kernel attribute can only be used on functions.
llvm-svn: 198300
2014-01-02 12:04:42 +00:00
Alp Toker 3ca9c86825 Remove an unused diag left over from r198046
llvm-svn: 198272
2014-01-01 06:07:48 +00:00
Alp Toker 95e7ff2ed1 Eliminate UnaryTypeTraitExpr
Remove UnaryTypeTraitExpr and switch all remaining type trait related handling
over to TypeTraitExpr.

The UTT/BTT/TT enum prefix and evaluation code is retained pending further
cleanup.

This is part of the ongoing work to unify type traits following the removal of
BinaryTypeTraitExpr in r197273.

llvm-svn: 198271
2014-01-01 05:57:51 +00:00
Alp Toker 383d2c478c ExpectAndConsume: Diagnose errors automatically
1) Teach ExpectAndConsume() to emit expected and expected-after diagnostics
    using the generic diagnostic descriptions added in r197972, eliminating another
    set of trivial err_expected_* variations while maintaining existing behaviour.

 2) Lift SkipUntil() recovery out of ExpectAndConsume(). The Expect/Consume
    family of functions are primitive parser operations that now have the
    well-defined property of operating on single tokens. Factoring out recovery
    exposes opportunities for more consistent and tailored error recover at the
    call sites instead of just relying on a bottled SkipUntil formula.

llvm-svn: 198270
2014-01-01 03:08:43 +00:00
Joey Gouly 4ba0f1e2d7 [OpenCL] Produce an error, instead of a warning, for sizeof(void) in OpenCL.
Patch by joey.gouly@arm.com

llvm-svn: 198264
2013-12-31 15:47:49 +00:00
Serge Pavlov 2e3ecb660a Recover from errors in enum definition
Previously any error in enum definition body stopped parsing it. With this
change parser tries to recover from errors.
The patch fixes PR10982.

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

llvm-svn: 198259
2013-12-31 06:26:03 +00:00
Alp Toker fceca50357 Silence g++ 4.9 build issue
lib/ASTMatchers/ASTMatchFinder.cpp:276:28: error: typedef 'traverse_can_only_be_instantiated_with_base_type' locally defined but not used [-Werror=unused-local-typedefs]
                            traverse_can_only_be_instantiated_with_base_type);

llvm-svn: 198256
2013-12-31 03:16:57 +00:00
DeLesley Hutchins bb79c338ed Update DataRecursiveASTVisitor so that it visits attributes.
llvm-svn: 198249
2013-12-30 21:03:02 +00:00
Nick Lewycky 00b9b695c4 Fix two typos in comments. No functionality change.
llvm-svn: 198243
2013-12-30 20:16:30 +00:00
Reid Kleckner 9e3bc72b8d Remove linkage macro from the CXLanguageKind enum
Enums don't have linkage, so clang warns when this expands to dllimport.

llvm-svn: 198227
2013-12-30 17:48:49 +00:00
DeLesley Hutchins c4a82438a7 Update RecursiveASTVisitor so that it visits attributes. This is currently
important for thread safety attributes, which contain expressions that were
not being visited, and were thus invisible to various tools.  There are now
Visit*Attr methods that can be overridden for every attribute.

llvm-svn: 198224
2013-12-30 17:24:36 +00:00
Alp Toker ba5b4dc60c Fix and reword some typos
llvm-svn: 198191
2013-12-30 02:06:29 +00:00
Alp Toker 751d635a2a Cleanup: Switch the preprocessor to err_pp_expected_after
This is approaching consistency but the PP and Parse categories they still have
slightly different wording:

def err_pp_expected_after : Error<"missing %1 after %0">;
def err_expected_after   : Error<"expected %1 after %0">;

llvm-svn: 198189
2013-12-30 01:59:29 +00:00
Alp Toker a724cff01b Rename isBuiltinCall() to getBuiltinCallee()
This better describes what the function does.

Cleanup only.

llvm-svn: 198127
2013-12-28 21:59:02 +00:00
Will Wilson ba2f146c87 Silence compile warning by removing unused SourceMgr member
llvm-svn: 198083
2013-12-27 20:02:27 +00:00
Will Wilson 0fafd34a6e Implement MSVC header search algorithm in MicrosoftMode.
Follows algorithm described here: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx

llvm-svn: 198082
2013-12-27 19:46:16 +00:00
Aaron Ballman e683bd7d7e In an effort to reduce the likelihood of text getting out of sync, reusing the text from some diagnostics explicitly. No functional changes intended.
llvm-svn: 198078
2013-12-27 19:08:57 +00:00
Aaron Ballman 2dfb03f362 Removed a string literal for a diagnostic, and updated the diagnostic to not manually quote. No functional changes intended.
llvm-svn: 198076
2013-12-27 16:30:46 +00:00
Kostya Serebryany ce2c726e99 Bury leaked pointers in a global array to silence a leak detector in --disable-free mode
Summary:
This is an alternative to http://llvm-reviews.chandlerc.com/D2475
suggested by Chandler.

Reviewers: chandlerc, rnk, dblaikie

CC: cfe-commits, earthdok

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

llvm-svn: 198073
2013-12-27 08:11:08 +00:00
Nico Weber 0e6daefe8f Warn on mismatched parentheses in memcmp and friends.
Thisadds a new warning that warns on code like this:

  if (memcmp(a, b, sizeof(a) != 0))

The warning looks like:

test4.cc:5:30: warning: size argument in 'memcmp' call is a comparison [-Wmemsize-comparison]
  if (memcmp(a, b, sizeof(a) != 0))
                   ~~~~~~~~~~^~~~
test4.cc:5:7: note: did you mean to compare the result of 'memcmp' instead?
  if (memcmp(a, b, sizeof(a) != 0))
      ^                          ~
                            )
test4.cc:5:20: note: explicitly cast the argument to size_t to silence this warning
  if (memcmp(a, b, sizeof(a) != 0))
                   ^
                   (size_t)(     )
1 warning generated.

This found 2 bugs in chromium and has 0 false positives on both chromium and
llvm.

The idea of triggering this warning on a binop in the size argument is due to
rnk.

llvm-svn: 198063
2013-12-26 23:38:39 +00:00
Aaron Ballman 3e424b5070 Teach the diagnostics engine about the Attr type to make reporting on semantic attributes easier (and not require hard-coded strings). This requires a getSpelling() function on the Attr class, which is table-driven. Updates a handful of cases where a hard-coded string was being used to test the functionality out. Updating associated test cases for the improved quoting.
llvm-svn: 198055
2013-12-26 18:30:57 +00:00
Aaron Ballman cedaaea691 This diagnostic did not accept arguments, and did not have any test coverage. Parameterized the diagnostic, and made it more consistent with other attribute diagnostic wordings. Added test coverage.
Since this warning was generalized, it was also given a sensible warning group flag and the corresponding test was updated to reflect this.

llvm-svn: 198053
2013-12-26 17:07:49 +00:00
Aaron Ballman 213cf41a58 s/getter_setter/accessor No functional changes intended.
Thanks to Alp Toker for the naming suggestion!

llvm-svn: 198052
2013-12-26 16:35:04 +00:00
Aaron Ballman faed0fa3d7 Simplifying some diagnostics so that they don't need to work with StringRefs. No functional changes intended.
llvm-svn: 198051
2013-12-26 16:30:30 +00:00
Aaron Ballman 9e35bfe3f1 Parameterizing some MS property-related diagnostics. No functional changes intended.
llvm-svn: 198049
2013-12-26 15:46:38 +00:00
Aaron Ballman 6828945dd2 No need for the manual quotes and extra getName() call. No functional changes intended.
llvm-svn: 198047
2013-12-26 15:06:01 +00:00
Alp Toker 5294e6e094 Don't reserve __builtin_types_compatible_p as a C++ keyword
Even g++ considers this a valid C++ identifier and it should only have been
visible in C mode.

Also drop the associated low-value diagnostic.

llvm-svn: 197995
2013-12-25 01:47:02 +00:00
Alp Toker ec543279db Support and use token kinds as diagnostic arguments
Introduce proper facilities to render token spellings using the diagnostic
formatter.

Replaces most of the hard-coded diagnostic messages related to expected tokens,
which all shared the same semantics but had to be multiply defined due to
variations in token order or quote marks.

The associated parser changes are largely mechanical but they expose
commonality in whole chunks of the parser that can now be factored away.

This commit uses C++11 typed enums along with a speculative legacy fallback
until the transition is complete.

Requires corresponding changes in LLVM r197895.

llvm-svn: 197972
2013-12-24 09:48:30 +00:00
Alp Toker 61d41af46b Document the Message parameter of getCustomDiagID()
A lot of callers have been using this facility incorrectly.

llvm-svn: 197920
2013-12-23 21:00:35 +00:00
NAKAMURA Takumi d32e3ef349 clang/Analysis/FlowSensitive/DataflowSolver.h: <functional> should be just a STL header.
llvm-svn: 197912
2013-12-23 16:34:51 +00:00
Aaron Ballman 0390908588 Consolidating some mode attribute diagnostics. No functional changes intended.
llvm-svn: 197911
2013-12-23 15:23:11 +00:00
Alp Toker 054f33c801 Make some f_Group definitions anonymous and test an alternative spelling
These names weren't referred to anywhere in the source so don't need a written
name.

Depends on the TableGen fix for anonymous records in LLVM r197869.

llvm-svn: 197896
2013-12-22 22:38:57 +00:00
Aaron Ballman 888e935978 Removing the alloc_size attribute. The attribute was semantically handled, but silently ignored. Most of this feature was already reverted in June 2012 (r159016), this just cleans up the pieces left over.
llvm-svn: 197866
2013-12-21 17:15:13 +00:00
Richard Trieu 2f024f432d Add -Winfinite-recursion to Clang
This new warning detects when a function will recursively call itself on every
code path though that function.  This catches simple recursive cases such as:

void foo() {
  foo();
}

As well as more complex functions like:

void bar() {
  if (test()) {
    bar();
    return;
  } else {
    bar();
  }
  return;
}

This warning uses the CFG.  As with other CFG-based warnings, this is off
by default.  Due to false positives, this warning is also disabled for
templated functions.

llvm-svn: 197853
2013-12-21 02:33:43 +00:00
Reid Kleckner b60a3d5bc1 Eliminate the ItaniumVTableContext object from CodeGenVTables
Now CodeGenVTables has only one VTableContext object, which is either
Itanium or Microsoft.

Fixes a FIXME with no functionality change intended.

Ideally we could avoid the downcasts by pushing the things that
reference the Itanium vtable context into ItaniumCXXABI.cpp, but we're
not there yet.

llvm-svn: 197845
2013-12-20 23:58:52 +00:00
Hans Wennborg e0053474b9 clang-cl: Support /P and /E (preprocess to file or stdout)
llvm-svn: 197827
2013-12-20 18:40:46 +00:00
Daniel Jasper 92669ee45c Enable layering check in unavailable modules.
If a header file belonging to a certain module is not found on the
filesystem, that header gets marked as unavailable. Now, the layering
warning (-fmodules-decluse) should still warn about headers of this
module being wrongfully included. Currently, headers belonging to those
modules are just treated as not belonging to modules at all which means
they can be included freely from everywhere.

To implement this (somewhat) cleanly, I have moved most of the layering
checks into the ModuleMap. This will also help with showing FixIts
later.

llvm-svn: 197805
2013-12-20 12:09:36 +00:00
Argyrios Kyrtzidis 561fe54a1a Move tools/libclang/RecursiveASTVisitor.h -> include/clang/AST/DataRecursiveASTVisitor.h
This is to make it available so the static analyzer can use it.

llvm-svn: 197766
2013-12-20 02:02:54 +00:00
Dmitri Gribenko 4765252dcb ASTUnit::getMainBufferWithPrecompiledPreamble: use MD5 hash of the remapped
files to tell if they were changed since the last time we have computed the
preamble

We used to check only the buffer size, so if the new remapped buffer has the
same size as the previous one, we would think that the buffer did not change,
and we did not rebuild the preambule, which sometimes caused us to crash.

llvm-svn: 197755
2013-12-20 00:16:25 +00:00
Ted Kremenek 1654511884 Wordsmith "maybe" into "may be" in diagnostic, and move warning under flag.
llvm-svn: 197736
2013-12-19 22:47:11 +00:00
Aaron Ballman 37c5f5da32 After discussing with John McCall, removing the ns_bridged attribute as it is unused.
llvm-svn: 197729
2013-12-19 22:12:51 +00:00
Aaron Ballman d618025910 Type attribute do not get an AST node by default, so these statements can be removed (it's inherited automatically from TypeAttr).
llvm-svn: 197710
2013-12-19 18:16:00 +00:00
Aaron Ballman e615393356 Removing the SourceLocation unused attribute argument type.
llvm-svn: 197707
2013-12-19 18:10:57 +00:00
Dmitri Gribenko 092ab4a9fe Simplify CXXMethodDecl::isVirtual() for __interface case
llvm-svn: 197643
2013-12-19 01:58:52 +00:00
Aaron Ballman 66039937e8 Added a comment about the launch_bounds attribute's AST node being required. Since there were no test cases for the attribute, some have been added. This promptly demonstrated a bug with the semantic handling, which is also fixed.
llvm-svn: 197637
2013-12-19 00:41:31 +00:00
Aaron Ballman 8edb5c2081 Refactor the Microsoft inheritance attribute handling so that it no longer has special treatment. Also fixes a minor bug where the attributes were being parsed as though they were GNU-style attributes when they were in fact keyword attributes.
llvm-svn: 197629
2013-12-18 23:44:18 +00:00
Ted Kremenek b79ee57080 Implemented delayed processing of 'unavailable' checking, just like with 'deprecated'.
Fixes <rdar://problem/15584219> and <rdar://problem/12241361>.

This change looks large, but all it does is reuse and consolidate
the delayed diagnostic logic for deprecation warnings with unavailability
warnings.  By doing so, it showed various inconsistencies between the
diagnostics, which were close, but not consistent.  It also revealed
some missing "note:"'s in the deprecated diagnostics that were showing
up in the unavailable diagnostics, etc.

This change also changes the wording of the core deprecation diagnostics.
Instead of saying "function has been explicitly marked deprecated"
we now saw "'X' has been been explicitly marked deprecated".  It
turns out providing a bit more context is useful, and often we
got the actual term wrong or it was not very precise
 (e.g., "function" instead of "destructor").  By just saying the name
of the thing that is deprecated/deleted/unavailable we define
this issue away.  This diagnostic can likely be further wordsmithed
to be shorter.

llvm-svn: 197627
2013-12-18 23:30:06 +00:00
Fariborz Jahanian cb8c7da266 ObjectiveC. support "section" attribute on properties
and methods. rdar://15450637

llvm-svn: 197625
2013-12-18 23:09:57 +00:00
Douglas Gregor d1e3ceb5ec Require the type of a by-copy capture to be complete before creating its field.
The problem here is more serious than the fix implies. Adding a field
to a class updates the triviality bits for the class (among other
things). Failing to require a complete type before adding the field
meant that these updates don't happen in the well-formed case where
the capture is an uninstantiated class template specialization,
leading the lambda itself to be treated as having a trivial copy
constructor when it shouldn't. Fixes <rdar://problem/15560464>.

llvm-svn: 197623
2013-12-18 23:02:36 +00:00
Douglas Gregor 6878214bc9 Allow Objective-C pointer conversions following an explicit user conversion.
Finishes the work started in r194224, and fixes <rdar://problem/15494681>.

llvm-svn: 197609
2013-12-18 21:46:16 +00:00
Fariborz Jahanian 283bf89506 Objective-C. After providing a fix-it for a
cstring, converted to NSString, produce the
matching AST for it. This also required some
refactoring of the previous code. // rdar://14106083

llvm-svn: 197605
2013-12-18 21:04:43 +00:00
Alp Toker d751fa7868 Revert "[OPENMP] Fix for parsing OpenMP directives with extra braces, brackets and parens"
These parser changes were redundant. The same or better recovery can be
achieved with a one-line fix to SkipUntil() due to land in the next commit.

This reverts commit r197553.

llvm-svn: 197597
2013-12-18 19:10:49 +00:00
Fariborz Jahanian 8ef938972a ObjectiveC. Fixes the sentence in a diagnostic.
// rdar://15397430

llvm-svn: 197586
2013-12-18 16:51:06 +00:00
Aaron Ballman b4ca40bd4d Adding some comments about AST node requirements for attributes which create AST nodes but never actually make use of them. No functional changes.
llvm-svn: 197582
2013-12-18 15:59:41 +00:00
Rafael Espindola af789a05b2 Whitespace cleanup.
llvm-svn: 197580
2013-12-18 15:52:38 +00:00
Alp Toker f22856a415 Remove OpenCL-specific type keywords and specifiers
This commit kills off custom type specifier and keyword handling of OpenCL C
data types.

Although the OpenCL spec describes them as keywords, we can handle them more
elegantly as predefined types. This should provide better error correction and
code completion as well as simplifying the implementation.

The primary intention is however to simplify the C/C++ parser and save some
packed bits on AST structures that had been extended in r170432 just for
OpenCL.

llvm-svn: 197578
2013-12-18 15:29:05 +00:00
Alexey Bataev cb164ab273 [OPENMP] Fix for parsing OpenMP directives with extra braces, brackets and parens
llvm-svn: 197553
2013-12-18 08:46:25 +00:00
Fariborz Jahanian 1b30b593ba ObjectiveC. typo fix in my last patch,
per Jordan's review. 

llvm-svn: 197540
2013-12-18 00:52:54 +00:00
Fariborz Jahanian 7e350d23b2 Objctive-C. warn if dealloc is being overridden in
a category implementation. // rdar://15397430

llvm-svn: 197534
2013-12-17 22:44:28 +00:00
Aaron Ballman f2db7626f0 None of these attributes currently make use of an AST node, so setting ASTNode = 0 to reduce complexity. No functional change intended.
llvm-svn: 197525
2013-12-17 21:35:24 +00:00
Fariborz Jahanian bd714e9bb1 Objective-C. Make diagnostics and fix-its consistent
when diagnosing casting of a cstring literal to
NSString in default and -fobjc-arc mode. 
// rdar://14106083

llvm-svn: 197515
2013-12-17 19:33:43 +00:00
Alp Toker de50ff3c4b Bring order to the OpenCL keywords
Avoid the gratuitous repurposing of C++ keyword 'private' by using a keyword
alias.

Also attempt to document the OpenCL keywords based on scraps of information
found online.

The purpose of this commit is to reduce impact on the C++ parser.

llvm-svn: 197511
2013-12-17 18:17:46 +00:00
Alp Toker a3ebe6ee2b Refactor and micro-optimize ConsumeToken()
1) Introduce TryConsumeToken() to handle the common test-and-consume pattern.
   This brings about readability improvements in the parser and optimizes to avoid
   redundant checks in the common case.

2) Eliminate the ConsumeCodeCompletionTok special case from ConsumeToken(). This
   was used by only one caller which has been switched over to the more
   appropriate ConsumeCodeCompletionToken() function.

llvm-svn: 197497
2013-12-17 14:12:37 +00:00
Alp Toker 53358e43bc Simplify RevertibleTypeTraits as a form of contextual keyword
Now that we emit diagnostics for keyword-as-identifier hacks (-Wkeyword-compat)
we can go ahead and simplify some of the old revertible keyword support.

This commit adds a TryIdentKeywordUpgrade() function to mirror the recently
added TryKeywordIdentFallback() and uses it to replace the hard-coded list of
REVERTIBLE_TYPE_TRAITs.

llvm-svn: 197496
2013-12-17 14:12:30 +00:00
Daniel Jasper 8fb00b0f79 Update comment of changed parameter of ModuleMap constructor.
llvm-svn: 197495
2013-12-17 13:21:13 +00:00
Richard Barton 5828d7b936 LIBRARY_PATH environment variable should only be supported on a native compiler.
llvm-svn: 197490
2013-12-17 11:11:25 +00:00
Daniel Jasper 0761a8a085 Modules: Don't warn upon missing headers while reading the module map.
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.

This works towards the long-term goal of not stat'ing the header files at all
while reading the module map and instead read them only when the module is
being built (there is a corresponding FIXME in parseHeaderDecl()).  However, it
seems non-trivial to get there and this unblock us and moves us into the right
direction.

Also changed the implementation to reuse the same DiagnosticsEngine.

llvm-svn: 197485
2013-12-17 10:31:37 +00:00
Alp Toker 2dea15b53c ASTContext: Refactor implicit record creation
Tidy up built-in record creation to reduce code duplication.

Continuation of r197336.

llvm-svn: 197452
2013-12-17 01:22:38 +00:00
Fariborz Jahanian 381edf5759 ObjectiveC. Further improvements of use
of objc_bridge_related attribute; eliminate
unnecessary diagnostics which is issued elsewhere,
fixit now produces a valid AST tree per convention.
This results in some simplification in handling of
this attribute as well. // rdar://15499111

llvm-svn: 197436
2013-12-16 22:54:37 +00:00
Kaelyn Uhrain 5dfc94b160 Revert "Maybe add new warning for shadowing simple tag types"
This reverts commit 2b43f500cfea10a8c59c986dcfc24fd08eecc77d.

This was accidentally committed because I failed to notice my client
wasn't clean prior to submitting a fix for a crasher.

llvm-svn: 197410
2013-12-16 19:25:47 +00:00
Kaelyn Uhrain a1c32d53fb Maybe add new warning for shadowing simple tag types
llvm-svn: 197408
2013-12-16 19:19:13 +00:00
Daniel Jasper 34dc4811a2 Revert "Modules: Make missing headers in a module.map a warning not an error."
This was committed accidentally.

llvm-svn: 197389
2013-12-16 14:57:22 +00:00
Daniel Jasper 5c6ee49fa0 Modules: Make missing headers in a module.map a warning not an error.
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.

A better long-term strategy might be to not stat the header files at all
while reading the module map and instead read them only when the module
is being built (there is a corresponding FIXME in parseHeaderDecl()).
However, it seems non-trivial to get there and this would be a temporary
solution to unblock us.

Also changed the implementation to reuse the same DiagnosticsEngine as
otherwise warnings can't be enabled or disabled with command-line flags.

llvm-svn: 197388
2013-12-16 14:53:57 +00:00