Commit Graph

12957 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 442dd80715 [PCH] Make sure that all newly introduced visible decls in a DeclContext
coming from an AST file are registered for serialization.

A static data member instantiation of in a chained PCH could be missed
when serializing decls; the result was that when emitting the visible decls
map of its DeclContext, we would use a DeclID that was not actually emitted,
leading to crashes or hangs.

Fix this by making sure such decls are always registered for serialization.
Also introduce extra sanity checks to make sure we don't register new
declarations or types after we have serialized the types/decls block.

rdar://11728990

llvm-svn: 159550
2012-07-02 19:19:01 +00:00
Richard Smith 200f47c65d A ':' after an enum-specifier at class scope is a bitfield, not a typo for a ';'.
llvm-svn: 159549
2012-07-02 19:14:01 +00:00
Dmitri Gribenko 3292d06a1b Add a new libclang completion API to get brief documentation comment that is
attached to a declaration in the completion string.

Since extracting comments isn't free, a new code completion option is
introduced.

A new code completion option that enables including brief comments
into CodeCompletionString should be a, err, code completion option.
But because ASTUnit caches global declarations during parsing before
even completion consumer is created, the option is duplicated as a
translation unit option (in both libclang and ASTUnit, like the option
to cache code completion results).

llvm-svn: 159539
2012-07-02 17:35:10 +00:00
James Dennett 9784d093e1 Documentation cleanup: reformatting/fixing up file comments so that they have
\file and \brief markup and appear in Doxygen's summaries (and eventually at
http://clang.llvm.org/doxygen/files.html).  Fixed up another couple of minor
glitches in the docs at the same time.

llvm-svn: 159517
2012-07-02 07:01:42 +00:00
Meador Inge cfb6090912 PR13189: va_list broken with precompiled headers
For some targets a structure named __va_list_tag is built to help define
the __builtin_va_list type.  However, __va_list_tag was not being treated as a
predefined type thus causing problems when serializing the AST.  This commit
fixes that oversight by adding the necessary support to treat __va_list_tag
as a predefined type.

llvm-svn: 159508
2012-07-01 15:57:25 +00:00
Jordan Rose 58d547200e Add support for the C11 _Alignof keyword.
This behaves like the existing GNU __alignof and C++11 alignof keywords;
most of the patch is simply adding the third token spelling to various places.

llvm-svn: 159494
2012-06-30 21:33:57 +00:00
Arnaud A. de Grandmaison 0fe28a1a84 [libclang] add CompilationDatabase support
llvm-svn: 159484
2012-06-30 11:27:57 +00:00
Matt Beaumont-Gay b5b71fe628 Add a missing argument index, wordsmith a little, and 80(ish) columns
llvm-svn: 159478
2012-06-30 01:37:38 +00:00
Richard Trieu db96a42eba Fix typos from r159463 and update tests. Added Matt Beaumont-Gay's suggestion
to improve wording of a diagnostic message.

llvm-svn: 159473
2012-06-29 23:11:10 +00:00
David Blaikie 5d577a225e Use -frewrite-includes for crash reports.
In future changes we should:
* use __builtin_trap rather than derefing 'random' volatile pointers.
* avoid dumping temporary files into /tmp when running tests, instead
  preferring a location that is properly cleaned up by lit.

Review by Chandler Carruth.

llvm-svn: 159469
2012-06-29 22:03:56 +00:00
Richard Trieu c605844510 Update the %diff modifer to have an alternate string print when a template tree
is selected.  This will allow more flexibility when converting diagnostics to
use template type diffing.

Also updated the internal manual and test cases for correctly keeping the bold
attribute and for tree printing.

llvm-svn: 159463
2012-06-29 21:12:16 +00:00
Richard Trieu cf86744ffe Add a fix-it hint note to -Wunique-enum to suggest that the last element gets
initialized with the next to last element to silence the warning.

llvm-svn: 159458
2012-06-29 20:36:14 +00:00
Fariborz Jahanian 1db30fc071 objc diagnostic: pass IdentifierInfo* to the diagnostic system
to produce quotes instead of adding qoute to the test.

llvm-svn: 159450
2012-06-29 18:43:30 +00:00
Manman Ren 86c3250b82 X86: add more GATHER intrinsics in Clang
Corrected type for index of _mm256_mask_i32gather_pd
  from 256-bit to 128-bit
Corrected types for src|dst|mask of _mm256_mask_i64gather_ps
  from 256-bit to 128-bit

Support the following intrinsics:
  _mm_mask_i32gather_epi64, _mm256_mask_i32gather_epi64,
  _mm_mask_i64gather_epi64, _mm256_mask_i64gather_epi64,
  _mm_mask_i32gather_epi32, _mm256_mask_i32gather_epi32,
  _mm_mask_i64gather_epi32, _mm256_mask_i64gather_epi32

llvm-svn: 159403
2012-06-29 00:54:35 +00:00
Jordan Rose 42ee04d00a [analyzer] Add a test that we are, in fact, doing a DFS on the ExplodedGraph.
Previously:
...the comment said DFS...
...the WorkList being instantiated said BFS...
...and the implementation was actually DFS...
...due to an unintentional change in 2010...
...and everything kept working anyway.

This fixes our std::deque implementation of BFS, but switches back to a
SmallVector-based implementation of DFS.

We should probably still investigate the ramifications of DFS vs. BFS,
especially for large functions (and especially when we hit our block path
limit), since this might completely change our memory use. It can also mask
some bugs and reveal others depending on when we halt analysis. But at least
we will not have this kind of little mistake creep in again.

llvm-svn: 159397
2012-06-29 00:33:10 +00:00
Nico Weber 33fd523df1 Warn on self-assignment to member variables. PR13104.
llvm-svn: 159394
2012-06-28 23:53:12 +00:00
Arnaud A. de Grandmaison 0271b32f00 Factor CXString out of Index.h
No functionnal or interface change. This is done to prepare the landing of
CompilationDatabase in libclang.

llvm-svn: 159382
2012-06-28 22:01:06 +00:00
Matt Beaumont-Gay 1571652af9 Only print a semicolon after "no known conversion for Nth argument" if there
is a following clause.

llvm-svn: 159369
2012-06-28 19:20:41 +00:00
Benjamin Kramer 8652ca8a6a Now that we use the GCC builtin <-> llvm intrinsic, dead code eliminate the handwritten emitter.
The generated code uncovered an invalid prototype for __builtin_mips_shilo, fix it along the way.

llvm-svn: 159368
2012-06-28 19:10:01 +00:00
Simon Atanasyan 07ce7d8fb5 Support MIPS DSP Rev1 intrinsics.
This patch was reviewed in the llvm-commits list by Jim Grosbach.

llvm-svn: 159366
2012-06-28 18:23:16 +00:00
Hans Wennborg f60f6af9e8 Add -ftls-model command-line flag.
This allows for setting the default TLS model. (PR9788)

llvm-svn: 159336
2012-06-28 08:01:44 +00:00
Richard Smith 608c0b65d7 Add warning flag -Winvalid-pp-token for preprocessing-tokens which have
undefined behaviour, and move the diagnostic for '' from an Error into
an ExtWarn in this group. This is important for some users of the preprocessor,
and is necessary for gcc compatibility.

llvm-svn: 159335
2012-06-28 07:51:56 +00:00
Rafael Espindola ecbe2e9795 Fix another issue with devirtualizing calls to final methods by passing them
the correct this pointer. There is some potential for sharing a bit more
code with canDevirtualizeMemberFunctionCalls, but that can be done in an
independent patch.

llvm-svn: 159326
2012-06-28 01:56:38 +00:00
Fariborz Jahanian 91fc39e313 patch to suggest 'static' function should be 'static inline'
when it appears to be unused and occurs in a header.
// rdar://11202617

llvm-svn: 159282
2012-06-27 19:43:29 +00:00
Rafael Espindola b7f5a9c5cd Implement John McCall's review of r159212 other than the this pointer not
being updated. Will fix that in a second.

llvm-svn: 159280
2012-06-27 18:18:05 +00:00
Dmitri Gribenko 1669f70273 Remove unsigned and a pointer from a comment token (so that each token can have only one semantic string value attached to it), at a cost of adding an additional token.
llvm-svn: 159270
2012-06-27 16:53:58 +00:00
Axel Naumann 38179d9693 From Vassil Vassilev:
add interface for removing a FileEntry from the cache.
Forces a re-read the contents from disk, e.g. because a tool (like cling) wants to pick up a modified file.

llvm-svn: 159256
2012-06-27 09:17:42 +00:00
Dmitri Gribenko 9036459167 Initialize RawCommentList::BriefTextValid when deserializing AST.
llvm-svn: 159246
2012-06-27 00:57:00 +00:00
Daniel Jasper 105da6f7c4 Always use getDerived().shouldVisitImplicitCode() so it can be altered
in subclasses.

llvm-svn: 159231
2012-06-26 22:15:38 +00:00
Fariborz Jahanian 0638c15a52 preprocessing: gcc supports #line 0. So, treat this
as a gcc supported extension with usual treatment
with -pedantic (warn) and -pedantic-errors (error).
// rdar://11550996

llvm-svn: 159226
2012-06-26 21:19:20 +00:00
Dmitri Gribenko 5188c4b9cc Implement a lexer for structured comments.
llvm-svn: 159223
2012-06-26 20:39:18 +00:00
Manman Ren add5e9e289 X86: add GATHER intrinsics (AVX2) in Clang
Support the following intrinsics:
  _mm_mask_i32gather_pd, _mm256_mask_i32gather_pd, _mm_mask_i64gather_pd
  _mm256_mask_i64gather_pd, _mm_mask_i32gather_ps, _mm256_mask_i32gather_ps
  _mm_mask_i64gather_ps, _mm256_mask_i64gather_ps

llvm-svn: 159222
2012-06-26 19:55:09 +00:00
Richard Trieu 9184423984 Add template type diffing to Clang. This feature will provide a better
comparison between two templated types when they both appear in a diagnostic.
Type elision will remove indentical template arguments, which can be disabled
with -fno-elide-type.  Cyan highlighting is applied to the differing types.

For more formatting, -fdiagnostic-show-template-tree will output the template
type as an indented text tree, with differences appearing inline. Template
tree works with or without type elision.

llvm-svn: 159216
2012-06-26 18:18:47 +00:00
Dmitri Gribenko 3563c28ab2 Fix comment: refer to documentation comments in general, not just Doxygen comments.
llvm-svn: 159214
2012-06-26 17:54:58 +00:00
Fariborz Jahanian 513b3681de objc: adds diagnostic group to several old objc warnings.
// rdar://11741435 pr13184

llvm-svn: 159213
2012-06-26 17:47:42 +00:00
Rafael Espindola 49e860b248 During codegen of a virtual call we would extract any casts in the expression
to see if we had an underlying final class or method, but we would then
use the cast type to do the call, resulting in a direct call to the wrong
method.

llvm-svn: 159212
2012-06-26 17:45:31 +00:00
Chad Rosier 773d6ae509 [driver] Make -serialize-diagnostics (one dash) and alias for
--serialize-diagnostics.
rdar://11734800

llvm-svn: 159208
2012-06-26 16:57:41 +00:00
Fariborz Jahanian 6362803cfe block literal irgen: several improvements on naming block
literal helper functions. All helper functions (global
and locals) use block_invoke as their prefix. Local literal
helper names are prefixed by their enclosing mangled function
names. Blocks in non-local initializers (e.g. a global variable 
or a C++11 field) are prefixed by their mangled variable name. 
The descriminator number added to end of the name starts off 
with blank (for first block) and _<N> (for the N+2-th block).

llvm-svn: 159206
2012-06-26 16:06:38 +00:00
Richard Smith 369b9f997c Extend the "expected ';' after struct" logic to also apply to enums, and to
struct and enum forward-declarations.

llvm-svn: 159164
2012-06-25 21:37:02 +00:00
Jordan Rose 4688e60861 [analyzer] Be careful about implicitly-declared operator new/delete. (PR13090)
The implicit global allocation functions do not have valid source locations,
but we still want to treat them as being "system header" functions for the
purposes of how they affect program state.

llvm-svn: 159160
2012-06-25 20:48:28 +00:00
Richard Smith 55ce352d4d Unrevert r158887, reverted in r158949, along with a fix for the bug which
resulted in it being reverted. A test for that bug was added in r158950.

Original comment:

If an object (such as a std::string) with an appropriate c_str() member function
is passed to a variadic function in a position where a format string indicates
that c_str()'s return type is desired, provide a note suggesting that the user
may have intended to call the c_str() member.

Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and
move it to SemaChecking in order to facilitate this. Factor the call checking
out of function call checking and block call checking, and extend it to cover
constructor calls too.

Patch by Sam Panzer!

llvm-svn: 159159
2012-06-25 20:30:08 +00:00
Nico Weber 7b5a716f3d Make explicit specializations at class scope work
for non-type template parameters in microsoft mode.
PR12709.

llvm-svn: 159147
2012-06-25 17:21:05 +00:00
Hans Wennborg d3b01bc7c6 Support the tls_model attribute (PR9788)
This adds support for the tls_model attribute. This allows the user to
choose a TLS model that is better than what LLVM would select by
default. For example, a variable might be declared as:

  __thread int x __attribute__((tls_model("initial-exec")));

if it will not be used in a shared library that is dlopen'ed.

This depends on LLVM r159077.

llvm-svn: 159078
2012-06-23 11:51:46 +00:00
Alexis Hunt 6aa9beef50 Clean up a large number of C++11 attribute parse issues, including parsing
attributes in more places where we didn't and catching a lot more issues.

This implements nearly every aspect of C++11 attribute parsing, except for:
 - Attributes are permitted on explicit instantiations inside the declarator
   (but not preceding the decl-spec)
 - Attributes are permitted on friend declarations of functions.
 - Multiple instances of the same attribute in an attribute-list (e.g.
   [[noreturn, noreturn]], not [[noreturn]] [[noreturn]] which is conforming)
   are allowed.
The first two are marked as expected-FIXME in the test file and the latter
is probably a defect and is currently untested.

Thanks to Richard Smith for providing the lion's share of the testcases.

llvm-svn: 159072
2012-06-23 05:07:58 +00:00
Nico Weber 3a691a367c Support L__FUNCTION__ in microsoft mode, PR11789
Heavily based on a patch from
Aaron Wishnick <aaron.s.wishnick@gmail.com>.

I'll clean up the duplicated function in CodeGen as
a follow-up, later today or tomorrow.

llvm-svn: 159060
2012-06-23 02:07:59 +00:00
Richard Smith 19b02cd7fc Minor improvements to some C99 variadic-macro-related diagnostics.
llvm-svn: 159054
2012-06-22 23:59:08 +00:00
Ted Kremenek 72b3452c2b Implement initial static analysis inlining support for C++ methods.
llvm-svn: 159047
2012-06-22 23:55:50 +00:00
Kaelyn Uhrain 9cb8e9fc89 Perform typo correction for base class specifiers.
llvm-svn: 159046
2012-06-22 23:37:05 +00:00
Dmitri Gribenko b31fe09b0f Mark Doxygen warnings DefaultIgnore.
llvm-svn: 159026
2012-06-22 20:19:59 +00:00
Dmitri Gribenko 804b2ab79b Correct include guard to reflect new directory name
llvm-svn: 159007
2012-06-22 16:52:11 +00:00
Dmitri Gribenko 052f60d384 Add a warning about almost-Doxygen trailing comments: //< and /*< ... */
llvm-svn: 159001
2012-06-22 16:02:55 +00:00
Fariborz Jahanian 46e14f8108 objective-c: improve diagnostic when collection expression is
not a pointer to a fast-enumerable object. // rdar://11488666

llvm-svn: 158998
2012-06-22 15:37:00 +00:00
James Dennett 91738ffda3 Documentation cleanup: making \param and \returns docs match the code.
llvm-svn: 158985
2012-06-22 10:32:46 +00:00
James Dennett 41725129a4 Documentation cleanup: making \param docs match the code.
llvm-svn: 158982
2012-06-22 10:16:05 +00:00
James Dennett ffad8b75e5 Documentation cleanup:
* Primarily fixed \param commands with names not matching any actual
  parameters of the documented functions.  In many cases this consists
  just of fixing up the parameter name in the \param to match the code,
  in some it means deleting obsolete documentation and occasionally it
  means documenting the parameter that has replaced the older one that
  was documented, which sometimes means some simple reverse-engineering
  of the docs from the implementation;
* Fixed \param ParamName [out] to the correct format with [out] before
  the parameter name;
* Fixed some \brief summaries.

llvm-svn: 158980
2012-06-22 08:10:18 +00:00
James Dennett c6bff718c2 Documentation cleanup:
* Added \file documentation for PPCallbacks.h;
* Added/formated \brief summaries;
* Deleted documentation for parameters that no longer exist;
* Used \param more systematically for documentation of parameters;
* Escaped # characters in Doxygen comments.

llvm-svn: 158978
2012-06-22 05:59:27 +00:00
James Dennett 7ad7aa79b6 Documentation cleanup:
* Add \file documentation;
* Add \verbatim...\endverbatim markup as needed;
* Add \brief summaries;
* Escaped "::" in Doxygen comments when preceded by space, to avoid a
  Doxygen warning where Doxygen takes this as an explicit link request;
* Add \code...\endcode markup to code examples;
* Fix a grammatical glitch in "is this declarator is a".

llvm-svn: 158977
2012-06-22 05:54:32 +00:00
James Dennett d3e68abfd3 Documentation cleanup:
* Add \brief summaries;
* Escaped # characters in Doxygen comments;
* Added some \see cross-references.

llvm-svn: 158975
2012-06-22 05:43:45 +00:00
James Dennett 24d3d4ae6d Documentation cleanup: rephrase, and so avoid a Doxygen warning.
llvm-svn: 158973
2012-06-22 05:40:23 +00:00
James Dennett cfdec5c6c3 Documentation cleanup: escape # characters in Doxygen comments as needed.
llvm-svn: 158972
2012-06-22 05:39:17 +00:00
James Dennett a4cfa38429 Documentation cleanup: escape # characters in Doxygen comments as needed.
llvm-svn: 158969
2012-06-22 05:35:25 +00:00
James Dennett a883c0254c Documentation cleanup: Fixed the format of the file header (that I broke in
a recent commit), and eliminated a Doxygen error by changing a comment inside
a function to not be a Doxygen comment.

llvm-svn: 158967
2012-06-22 05:32:40 +00:00
James Dennett b07ed9693e Documentation cleanup:
* Escaped # and < characters in Doxygen comments as needed;
* Fixed up some \brief summaries;
* Marked up some parameter references with \p;
* Added \code...\endcode around code examples;
* Used \returns a little more.

llvm-svn: 158966
2012-06-22 05:20:59 +00:00
James Dennett ca850aed37 Documentation cleanup:
* Made \brief documentation be brief, mostly by adding a blank line to make
  the rest of the text be part of the detailed description only;
* Removed "FunctionOrClassName - " and other redundant text from the start
  of Doxygen comments.

llvm-svn: 158964
2012-06-22 05:06:35 +00:00
Rafael Espindola c368817101 Revert r158887. This fixes pr13168.
Revert "If an object (such as a std::string) with an appropriate c_str() member function"

This reverts commit 7d96f6106bfbd85b1af06f34fdbf2834aad0e47e.

llvm-svn: 158949
2012-06-21 23:44:21 +00:00
Dmitri Gribenko fecc2e0245 VC9 does not like heterogenous compare function objects.
llvm-svn: 158936
2012-06-21 21:02:45 +00:00
Anna Zaks 0760470371 [analyzer] Do not step into statements while collecting function decls.
CallGraph's recursive visitor only needs to collect declarations; their
bodies will be processed later on. RecursiveASTVisitor will recurse on
the bodies if the definition is provided along with declaration.
Optimize, by not recursing on any of the statements.

llvm-svn: 158934
2012-06-21 20:36:11 +00:00
Fariborz Jahanian 45337f53df objective-c: deprecated C-like parameters in Objective-C
method declarations.
// rdar://11578353.

llvm-svn: 158929
2012-06-21 18:43:08 +00:00
Daniel Jasper c4dabab941 Make the RecursiveASTVisitor visit the body of a range-based for loop
again. This was broken in r158395.

llvm-svn: 158907
2012-06-21 08:50:04 +00:00
Alexey Samsonov f50a9ffd0b Improve support for -g options accepted by Clang:
1. Accept flags -g[0-3], -ggdb[0-3], -gdwarf-[2-4] and collapse them to simple -g (except -g0/-ggdb0).
2. Produce driver error on unsupported formats (-gcoff, -gstabs, -gvms) and options (-gtoggle).
3. Recognize and ignore flags -g[no-]strict-dwarf, -g[no-]record-gcc-switches.

llvm-svn: 158906
2012-06-21 08:22:39 +00:00
Richard Smith c7b0bdffe7 If an object (such as a std::string) with an appropriate c_str() member function
is passed to a variadic function in a position where a format string indicates
that c_str()'s return type is desired, provide a note suggesting that the user
may have intended to call the c_str() member.

Factor the non-POD-vararg checking out of DefaultVariadicArgumentPromotion and
move it to SemaChecking in order to facilitate this. Factor the call checking
out of function call checking and block call checking, and extend it to cover
constructor calls too.

Patch by Sam Panzer!

llvm-svn: 158887
2012-06-21 01:08:35 +00:00
Fariborz Jahanian 1501987951 objective-c: place quotes around named items in a diagnostic.
// rdar://11671080

llvm-svn: 158874
2012-06-20 23:33:16 +00:00
Fariborz Jahanian 876cc65a3f objective-c: Normally, a property cannot be both 'readonly' and having a
"write" attribute (copy/retain/etc.). But, property declaration in 
primary class and protcols are tentative as they may be overridden 
into a 'readwrite' property in class extensions. Postpone diagnosing 
such warnings until the class implementation is seen. 
// rdar://11656982

llvm-svn: 158869
2012-06-20 22:57:42 +00:00
James Dennett 8618cb7ef8 Documentation cleanup: escape a < character in a Doxygen comment
llvm-svn: 158861
2012-06-20 22:06:21 +00:00
John McCall 18ac1632f0 Introduce ObjCRuntime::hasWeakClassImport() and use it in the appropriate
places.  I've turned this off for the GNU runtimes --- I don't know if
they support weak class import, but it's easy enough for them to opt in.

Also tweak a comment per review by Jordan.

llvm-svn: 158860
2012-06-20 21:58:02 +00:00
James Dennett 8811865e49 Documentation cleanup:
* Escape < characters in Doxygen comments as needed;
* Add \code...\endcode around code examples;
* Remove an incorrect use of Doxygen's \arg command.

llvm-svn: 158859
2012-06-20 21:55:51 +00:00
Jordan Rose dc753b625f Reword -Winternal-linkage-in-inline, and rename it to -Wstatic-in-inline.
Now that this is a C-only warning, we can use "static" instead of "internal
linkage", which is a term developers are probably more familiar with.
This makes for a better warning message. The warning name was changed to match,
since "internal linkage" is not mentioned in the warning text anymore.

llvm-svn: 158853
2012-06-20 21:09:10 +00:00
James Dennett 0187a05e35 Documentation cleanup:
* Many fixes for \brief summaries (adding some, and making others shorter);
* Don't try to explicit tell Doxygen a namespace name (and particularly
  don't get it wrong);
* Typo fix: instantitions -> instantiations;
* Slightly more use of \pre for documenting preconditions.

llvm-svn: 158852
2012-06-20 21:03:59 +00:00
Anna Zaks b3fea8741f [analyzer] Do not walk the types for call graph construction.
Similar to r156661. This should be beneficial performance wise and
hopefully, resolve a RecursiveASTVisitor crash that we are seeing in the
wild, but are incapable of reproducing.

llvm-svn: 158851
2012-06-20 20:57:49 +00:00
Anna Zaks 51b7357159 [analyzer] Remove dead code.
llvm-svn: 158849
2012-06-20 20:57:42 +00:00
James Dennett 6eac20e8df Documentation cleanup: escaping # characters in Doxygen comments.
llvm-svn: 158847
2012-06-20 20:49:07 +00:00
Dmitri Gribenko 93b9ecba9b Remove unused ASTContext& arg in RawCommentList::addComment, as pointed out by Chandler in commit message for r158807.
llvm-svn: 158845
2012-06-20 20:39:04 +00:00
Jordan Rose de9e976468 Remove -Winternal-linkage-in-inline in C++.
It's very easy for anonymous external linkage to propagate in C++ through
return types and parameter types. Likewise, it's possible that a template
containing an inline function is only used with parameters that have internal
linkage. Actually diagnosing where the internal linkage comes from is fairly
difficult (both to locate and then to print nicely). Finally, since we only
have one translation unit available, we can't even prove that any of this
violates the ODR.

This warning needs better-defined behavior in C++ before it can really go in.

Rewording of the C warning (which /is/ specified by C99) coming shortly.

llvm-svn: 158836
2012-06-20 18:50:06 +00:00
Chad Rosier 43b7c021b3 [ms-style asm] Change the fatal error to an extension warning. Apparently, this
error was asserting on anything that included Windows.h.  MS-style inline asm is
still dropped, but at least now we're not completely silent about it.

llvm-svn: 158833
2012-06-20 18:28:37 +00:00
Fariborz Jahanian edc2971c4d objc: improved diagnostic when property autosynthesis may cause
change in behavior. // rdar://11671080

llvm-svn: 158828
2012-06-20 17:18:31 +00:00
Alexis Hunt 6c19063a1c Fix a thinko and a stray debugging hunk in my attributes patch. Thanks to Jordan
Rose and Richard Smith for catching these.

llvm-svn: 158826
2012-06-20 16:05:42 +00:00
Chandler Carruth 39a3e7544a Fix a big layering violation introduced by r158771.
That commit added a new library just to hold the RawCommentList. I've
started a discussion on the commit thread about whether that is really
meritted -- it certainly doesn't seem necessary at this stage.

However, the immediate problem is that the AST library has a hard
dependency on the Comment library, but the dependencies were set up
completely backward. In addition to the layering violation, this had an
unfortunate effect if scattering the Comments library dependency
throughout the build system, but inconsistently so -- several parts of
the CMake dependencies were missing and only showed up due to transitive
deps or the fact that the target wasn't being built by tho bots.

It turns out that the Comments library can't (currently) be a well
formed layer *below* the AST library either, as it has an API that
accepts an ASTContext. That parameter is currently unused, so maybe that
was a mistake?

Anyways, it really seems like this is logically part of the AST --
that's the whole point of the ASTContext providing access to it as far
as I can tell -- so I've merged it into the AST library to solve the
immediate layering violation problems and remove some of the churn from
our library dependencies.

llvm-svn: 158807
2012-06-20 09:53:52 +00:00
Chandler Carruth e813806462 Remove a 'static' specifier from an 'inline' function in a header file.
This issue was caught by the new '-Winternal-linkage-in-inline' warning.

llvm-svn: 158801
2012-06-20 08:43:50 +00:00
Ted Kremenek c26328afa6 Revert "Provide a -no-pedantic to cancel out -pedantic." This needs to be designed
a bit further.  We may wish to just have -Wno flags to silence warnings, and not have a -no-pedantic.

llvm-svn: 158796
2012-06-20 07:03:37 +00:00
John McCall 5fb5df9c83 Restructure how the driver communicates information about the
target Objective-C runtime down to the frontend:  break this
down into a single target runtime kind and version, and compute
all the relevant information from that.  This makes it
relatively painless to add support for new runtimes to the
compiler.  Make the new -cc1 flag, -fobjc-runtime=blah-x.y.z,
available at the driver level as a better and more general
alternative to -fgnu-runtime and -fnext-runtime.  This new
concept of an Objective-C runtime also encompasses what we
were previously separating out as the "Objective-C ABI", so
fragile vs. non-fragile runtimes are now really modelled as
different kinds of runtime, paving the way for better overall
differentiation.

As a sort of special case, continue to accept the -cc1 flag
-fobjc-runtime-has-weak, as a sop to PLCompatibilityWeak.

I won't go so far as to say "no functionality change", even
ignoring the new driver flag, but subtle changes in driver
semantics are almost certainly not intended.

llvm-svn: 158793
2012-06-20 06:18:46 +00:00
Dmitri Gribenko 17e147fa9d Unbreak GCC build: GCC doesn't like clang::Parser::CommentHandler and class clang::CommentHandler to have same name.
llvm-svn: 158780
2012-06-20 01:06:08 +00:00
James Dennett 35ad6f9ac7 Documentation cleanup: adding/fixing Doxygen markup, particularly \brief,
\code...\endcode, \file commands and escaing for angle brackets.

llvm-svn: 158779
2012-06-20 01:00:18 +00:00
James Dennett 250c865c15 Documentation cleanup: escape # character in a Doxygen comment.
llvm-svn: 158775
2012-06-20 00:51:53 +00:00
James Dennett e5f16ae679 Documentation cleanup:
* Escape < characters in Doxygen comments as needed;
* Demote one Doxygen comment to a regular comment to fix a Doxygen warning.

llvm-svn: 158774
2012-06-20 00:50:53 +00:00
James Dennett e12128361d Documentation cleanup:
* Escaped # characters in Doxygen comments as needed;
* Added/fixed \file and \brief markup to add summaries to Doxygen output.

llvm-svn: 158773
2012-06-20 00:48:54 +00:00
Kaelyn Uhrain 272d718808 Add the PCH file name to the message about not being able to read the PCH.
Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.

llvm-svn: 158772
2012-06-20 00:36:03 +00:00
Dmitri Gribenko aab8383a2b Structured comment parsing, first step.
* Retain comments in the AST
* Serialize/deserialize comments
* Find comments attached to a certain Decl
* Expose raw comment text and SourceRange via libclang

llvm-svn: 158771
2012-06-20 00:34:58 +00:00
Alexis Hunt 3bc72c1ec2 Reapply r158700 and fixup patches, minus one hunk that slipped through and
caused a crash in an obscure case. On the plus side, it caused me to catch
another bug by inspection.

llvm-svn: 158767
2012-06-19 23:57:03 +00:00
DeLesley Hutchins 312e742c99 Thread Safety Analysis: Move some warnings on thread safety
attributes into the ThreadSafetyAttributes group, where the other
warnings currently live.

llvm-svn: 158761
2012-06-19 23:25:19 +00:00
Tanya Lattner 4fdce3faa8 Extend the support for cl-std to include 1.2.
Add error checking for the static qualifier which is now allowed in certain situations for OpenCL 1.2. Use the CL version to turn on this feature.
Added test case for 1.2 static storage class feature.

llvm-svn: 158759
2012-06-19 23:09:52 +00:00
Fariborz Jahanian 63d40202fb objective-c: warn when autosynthesizing a property which has same
name as an existing ivar since this is common source of error
when people remove @synthesize to take advantage of autosynthesis. 
// rdar://11671080

llvm-svn: 158756
2012-06-19 22:51:22 +00:00
Aaron Ballman 478faed4b0 Reapplying the changes from r158717 as they were rolled back to avoid merge conflicts from a separate problematic patch.
llvm-svn: 158750
2012-06-19 22:09:27 +00:00
Jakob Stoklund Olesen e1c0ae6fda Revert r158700 and dependent patches r158716, r158717, and r158731.
The original r158700 caused crashes in the gcc test suite,
g++.abi/vtable3a.C among others. It also caused failures in the libc++
test suite.

llvm-svn: 158749
2012-06-19 21:48:43 +00:00
Meador Inge cdc0057e3c Revert predefined decl tracking.
r158085 added some logic to track predefined declarations.  The main reason we
had predefined declarations in the input was because the __builtin_va_list
declarations were injected into the preprocessor input.  As of r158592 we 
explicitly build the __builtin_va_list declarations.  Therefore the predefined
decl tracking is no longer needed.

llvm-svn: 158732
2012-06-19 18:17:30 +00:00
Aaron Ballman 38c9ad9e72 Improves parsing and semantic analysis for MS __declspec attributes. This includes support for the align (which fixes PR12631).
llvm-svn: 158717
2012-06-19 13:49:26 +00:00
Alexis Hunt 7b28cdb3da Improve the specification of spellings in Attr.td.
Note that this is mostly a structural patch that handles the change from the old
spelling style to the new one. One consequence of this is that all AT_foo_bar
enum values have changed to not be based off of the first spelling, but rather
off of the class name, so they are now AT_FooBar and the like (a straw poll on
IRC showed support for this). Apologies for code churn.

Most attributes have GNU spellings as a temporary solution until everything else
is sorted out (such as a Keyword spelling, which I intend to add if someone else
doesn't beat me to it). This is definitely a WIP.

I've also killed BaseCheckAttr since it was unused, and I had to go through
every attribute anyway.

llvm-svn: 158700
2012-06-19 03:39:03 +00:00
Rafael Espindola 66aa045fd9 Add a -fuse-init-array option to cc1 and map to the UseInitArray target
option. On the driver, check if we are using libraries from gcc 4.7 or newer
and if so pass -fuse-init-array to the frontend.
The crtbegin*.o files in gcc 4.7 no longer call the constructors listed in
.ctors, so we have to use .init_array.

llvm-svn: 158694
2012-06-19 01:26:10 +00:00
Kaelyn Uhrain 9ea8f7e6c5 Improve the error message when a function overload candidate is rejected
because it expects a reference and receives a non-l-value.

For example, given:

  int foo(int &);
  template<int x> void b() { foo(x); }

clang will now print "expects an l-value for 1st argument" instead of
"no known conversion from 'int' to 'int &' for 1st argument". The change
in wording (and associated code to detect the case) was prompted by
comment #5 in PR3104, and should be the last bit of work needed for the
bug.

llvm-svn: 158691
2012-06-19 00:37:47 +00:00
Jordan Rose 8cea63c5cd Change -Winternal-linkage-in-inline from ExtWarn to Warning in C++.
Per post-commit review, it's not appropriate to use ExtWarn in C++, because
we can't prove that the inline function will actually be defined in more than
one place (and thus we can't prove that this violates the ODR).

This removes the warning entirely from uses in the main source file in C++.

llvm-svn: 158689
2012-06-18 23:58:49 +00:00
Tanya Lattner 794250474b Add language std for OpenCL 1.1 and 1.2.
llvm-svn: 158686
2012-06-18 22:55:02 +00:00
Jordan Rose 28cd12f265 Support -Winternal-linkage-in-inline in C++ code.
This includes treating anonymous namespaces like internal linkage, and allowing
const variables to be used even if internal. The whole thing's been broken out
into a separate function to avoid nested ifs.

llvm-svn: 158683
2012-06-18 22:09:19 +00:00
Matt Beaumont-Gay 50911a9d60 Move a few static functions from DiagnosticRenderer.cpp into SourceManager.
This simplifies the code a little bit, since these functions all took a
SourceManager parameter and called a bunch of methods on it, and makes
the functions available to other users.

llvm-svn: 158676
2012-06-18 20:12:05 +00:00
James Dennett 7b33767275 Documentation cleanup:
* Escaped "::" where needed to prevent Doxygen trying to make links;
* Updated one mention of C++0x to refer to C++11;
* Fixed a \brief summary to make it somewhat concise.

llvm-svn: 158667
2012-06-18 18:42:20 +00:00
Jordan Rose edff020011 Allow internal decls in inline functions if the function is in the main file.
This handles the very common case of people writing inline functions in their
main source files and not tagging them as inline. These cases should still
behave as the user intended. (The diagnostic is still emitted as an extension.)

I'm reworking this code anyway to account for C++'s equivalent restriction in
[basic.def.odr]p6, but this should get some bots back to green.

llvm-svn: 158666
2012-06-18 17:49:58 +00:00
Nuno Lopes e44e93aa6b alloc_size attribute: there's nothing wrong with alloc_size(1,1). It just means the function allocates x^2 bytes. GCC also accepts this syntax
llvm-svn: 158662
2012-06-18 16:27:56 +00:00
Alexis Hunt a0e54d453b Handle C++11 attribute namespaces automatically.
Now, as long as the 'Namespaces' variable is correct inside Attr.td, the
generated code will correctly admit a C++11 attribute only when it has the
appropriate namespace(s).

llvm-svn: 158661
2012-06-18 16:13:52 +00:00
Michael J. Spencer f97bd8c9cb [MSExtensions] Add support for __forceinline.
__forceinline is a combination of the inline keyword and __attribute__((always_inline))

llvm-svn: 158653
2012-06-18 07:00:48 +00:00
Richard Smith 7b3f322517 Extend the error recovery for a template-argument-list terminated by '>>' to
also deal with '>>>' (in CUDA), '>=', and '>>='. Fix the FixItHints logic to
deal with cases where the token is followed by an adjacent '=', '==', '>=',
'>>=', or '>>>' token, where a naive fix-it would result in a differing token
stream on a re-lex.

llvm-svn: 158652
2012-06-18 06:11:04 +00:00
Chandler Carruth 7a39ad6444 Switch users of SmallMap to use SmallDenseMap instead.
The most important change here is that the destructor and copy
constructor for StoredDeclsList will now reliably be run. Previously,
the destructors at least were missed in some cases. See the LLVM commits
discussions for why SmallMap is broken and going away.

llvm-svn: 158642
2012-06-17 11:47:03 +00:00
James Dennett eb9cb80810 Documentation cleanup:
* Escaped # characters in Doxygen comments as needed;
* Exposed summaries using the \brief command.

llvm-svn: 158636
2012-06-17 07:39:14 +00:00
James Dennett 819ff4f11c Documentation cleanup:
* Escaped # characters in Doxygen comments as needed;
* Added/reformatted \brief docs;
* Used a \file comment to document the file (MultipleIncludeOpt.h).

llvm-svn: 158635
2012-06-17 06:45:58 +00:00
James Dennett d6f1723838 Documentation cleanup:
* For Doxygen, escaped "::std" as "\::std";
* For humans, fixed "namespaecs" to "namespaces".

llvm-svn: 158634
2012-06-17 06:43:43 +00:00
James Dennett 9000bfee46 Documentation cleanup: add parameter name to \param
llvm-svn: 158633
2012-06-17 05:54:50 +00:00
James Dennett 28c68d7ddd Documentation cleanup:
* Escaped # characters in Doxygen comments;
* Added \brief markup to provide summaries.

llvm-svn: 158632
2012-06-17 05:49:13 +00:00
James Dennett 6b47ebb0ae Documentation cleanup: escaped a < character in a Doxygen comment.
llvm-svn: 158631
2012-06-17 05:37:49 +00:00
James Dennett d9faf1c7db Documentation cleanup: escaping #define in Doxygen comments
llvm-svn: 158629
2012-06-17 04:46:54 +00:00
James Dennett e16f3aa5d7 Documentation cleanup: escaping # characters and adding \brief markup
llvm-svn: 158627
2012-06-17 04:08:41 +00:00
James Dennett 946de9ea28 Documentation cleanup: escaping # characters and adding \brief markup
llvm-svn: 158626
2012-06-17 04:04:08 +00:00
James Dennett 1de0f83360 Documentation cleanup: escape #undef in Doxygen comments.
llvm-svn: 158625
2012-06-17 04:00:01 +00:00
James Dennett 3da20af2d5 Documentation cleanup: delete an erroneous use of \link
llvm-svn: 158624
2012-06-17 03:58:59 +00:00
James Dennett 464df1bfd5 Documentation cleanup: typo fix, \briaf -> \brief
llvm-svn: 158622
2012-06-17 03:57:24 +00:00
James Dennett cb620fdd03 Documentation cleanup: Add missing parameter name to a \param command
llvm-svn: 158621
2012-06-17 03:52:50 +00:00
James Dennett 9cb0a0887b Documentation cleanup: escape "::" to eliminate a Doxygen warning
llvm-svn: 158620
2012-06-17 03:43:32 +00:00
Hal Finkel 49bba70ec5 For compatibility with gcc, accept -maltivec as an alias of -faltivec.
llvm-svn: 158613
2012-06-17 02:29:23 +00:00
Benjamin Kramer cc7c710fb0 Guard private fields that are unused in Release builds with #ifndef NDEBUG.
llvm-svn: 158609
2012-06-16 21:48:23 +00:00
Meador Inge 5d3fb22bac Explicitly build __builtin_va_list.
The target specific __builtin_va_list types are now explicitly built instead
of injecting strings into the preprocessor input.

llvm-svn: 158592
2012-06-16 03:34:49 +00:00
Argyrios Kyrtzidis 33b4bfcef5 [AST/libclang] Fix the selector locations that are reported for a
method definition that has its '{' attached to the method name without
a space.

With a method like:

-(id)meth{
.....
}

the logic in ObjCMethodDecl that determined the selector locations got
confused because it was initialized based on an end location for '{' but
that end location changed to '}' after the method was finished.

Fix this by having an immutable end location for the declarator and
for getLocEnd() get the end location from the body itself.

Fixes rdar://11659739.

llvm-svn: 158583
2012-06-16 00:46:02 +00:00
Kaelyn Uhrain b5b17fe9fc Recover when correcting an unknown type name to a keyword like "struct".
llvm-svn: 158573
2012-06-15 23:45:58 +00:00
Kaelyn Uhrain 237c7d33b9 Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.
llvm-svn: 158572
2012-06-15 23:45:51 +00:00
James Dennett a0e9572674 Documentation cleanup: escape < characters in Doxygen comments.
llvm-svn: 158569
2012-06-15 22:43:14 +00:00
James Dennett 16ca63a0f7 Documentation cleanup: Escaped # characters in Doxygen comments.
llvm-svn: 158568
2012-06-15 22:38:06 +00:00
Dmitri Gribenko aff65827fb Add a missing initializer in ASTBitCodes.h
llvm-svn: 158558
2012-06-15 22:07:06 +00:00
James Dennett e62a0e0fda Documentation cleanup:
* Escaped # characters in Doxygen comments;
* Added Doxygen markup (\brief, \code, \file, \namespace).

llvm-svn: 158557
2012-06-15 21:59:54 +00:00
James Dennett 5586340b78 Documentation cleanup: fixed/created some /brief function summaries.
llvm-svn: 158555
2012-06-15 21:54:36 +00:00
James Dennett f01a35d678 Documentation cleanup:
* Escaped the # of #define in Doxygen comments;
* Formatting: Annotated __VA_ARGS__ with \c;
* Converted docs to use \brief to provide summaries;
* Fixed a typo: disbles -> disables.

llvm-svn: 158553
2012-06-15 21:43:55 +00:00
James Dennett 98bde98897 Documentation fix (cleaning up my own breakage): close <tt> with </tt>,
not with another <tt>.

llvm-svn: 158546
2012-06-15 21:23:13 +00:00
Alexis Hunt 2178f14c10 Stop referring to functions as methods in per-function fallthrough-checking.
llvm-svn: 158545
2012-06-15 21:22:05 +00:00
Jordan Rose 2684c68ddc Warn when a static variable is referenced in a non-static inline function.
This is explicitly forbidden in C99 6.7.4p3. This is /not/ forbidden in C++,
probably because by default file-scope const/constexpr variables have internal
linkage, while functions have external linkage. There's also the issue of
anonymous namespaces to consider. Nevertheless, there should probably be a
similar warning, since the semantics of inlining a function that references
a variable with internal linkage do not seem well-defined.

<rdar://problem/11577619>

llvm-svn: 158531
2012-06-15 18:19:48 +00:00
Douglas Gregor 7efd007cfb Check the parameter lists and return type of both blocks and lambdas
for unexpanded parameter packs. Fixes the crash-on-invalid in
PR13117.

llvm-svn: 158525
2012-06-15 16:59:29 +00:00
James Dennett 84aa05287d Documentation fix: Add a missing parameter name for a \param command
llvm-svn: 158512
2012-06-15 09:04:10 +00:00
James Dennett 7e704c87db Documentation cleanup:
* Converted comments to use \brief to provide summaries;
* Fixed uses of \arg that should be \p;
* Fixed \param [in] [out] to \param [in,out];
* Made minor formatting fixes.

llvm-svn: 158510
2012-06-15 08:55:05 +00:00
James Dennett 01f7a63ebc Documentation cleanup: use \p ParameterName when referring to a parameter,
not \arg ParameterName (which should be used only when documenting that
parameter, not when referring to it from elsewhere).

llvm-svn: 158509
2012-06-15 08:49:07 +00:00
James Dennett 15d9e461bf Fix a documentation typo: \\brief -> \brief
llvm-svn: 158507
2012-06-15 08:37:50 +00:00
James Dennett 804664c82d Documentation cleanup: fix \params to match the code.
llvm-svn: 158506
2012-06-15 08:35:42 +00:00
James Dennett a70437956d Documentation cleanup:
* Escaped @ symbols that shouldn't be interpreted by Doxygen;
* Deleted \param documentation for function parameters that no longer exist;
* Fixed parameter names in \param Doxygen commands;
* Fixed some broken formatting.

llvm-svn: 158505
2012-06-15 08:32:48 +00:00
James Dennett 89c503ff65 Documentation cleanup: fix erroneous uses of \arg.
llvm-svn: 158494
2012-06-15 06:48:13 +00:00
Craig Topper 9e28bf9345 Add XOP frcz instrinsics.
llvm-svn: 158492
2012-06-15 06:33:42 +00:00
James Dennett 1f8b48ebb1 Ongoing documentation cleanup:
* Added/tidied \brief summaries;
* Escaped # as needed for Doxygen;
* Drive-by: Fixed a rogue line > 80 columns.

llvm-svn: 158491
2012-06-15 06:26:16 +00:00
James Dennett 574cb4c2af Documentation cleanup for clang-c:
* Add parameter names to various \param commands;
* Ensure that \brief summaries are followed by blank lines where needed to
  prevent subsequent text being merged into the summary;
* Mark code examples with \code...\endcode so that they're appropriately
  formatted by Doxygen.
* Add qualification for links to field of structs (specifically callbacks);
* Escape #, @ and < as needed to avoid them being interpreted by Doxygen;
* Remove incorrect uses of "\see name", preferring #name;
* Fix a glitchy "\param Returns..." to be "\returns";
* Fix parameter names given to \param, typos and otherwise.

llvm-svn: 158489
2012-06-15 05:41:51 +00:00
James Dennett 261a941a12 Ongoing documentation cleanup: fixed Doxygen markup errors, added \brief
annotations in many places where it involved little change, fixed some
examples and marked code examples with \code...\endcode, and changed a few
nearby mentions of C++0x to refer to C++11.

llvm-svn: 158486
2012-06-15 04:35:30 +00:00
David Blaikie 690f21e25c Support -f[no-]rewrite-includes from the driver.
Review by Chandler Carruth.

llvm-svn: 158463
2012-06-14 18:55:27 +00:00
David Blaikie e993e4cd9b Support -frewrite-includes as an option while preprocessing.
llvm-svn: 158460
2012-06-14 17:36:09 +00:00
David Blaikie 619117a31d Rename -rewrite-includes to -frewrite-includes.
llvm-svn: 158458
2012-06-14 17:36:01 +00:00
James Dennett b9199ee5c1 More doxygen/documentation cleanups.
This reduces the number of warnings generated by Doxygen by about 100
(roughly 10%).  Issues addressed:
(1) Primarily, backslash-escaped "@foo" and "#bah" in Doxygen comments
when they're not supposed to be Doxygen commands or links, and
similarly for "<baz>" when it's not intended as as HTML tag;
(2) Changed some \t commands (which don't exist) to \c ("to refer to a
word of code", as the Doxygen manual says);
(3) \precondition becomes \pre;
(4) When touching comments, deleted a couple of spurious spaces in them;
(5) Changed some \n and \r to \\n and \\r;
(6) Fixed one tiny typo: #pragms -> #pragma.

This patch touches documentation/comments only.

llvm-svn: 158422
2012-06-13 22:07:09 +00:00
Richard Smith 8acadcb84b Add -isystem-prefix and -ino-system-prefix arguments, which can be used to
override whether headers are system headers by checking for prefixes of the
header name specified in the #include directive.

This allows warnings to be disabled for third-party code which is found in
specific subdirectories of include paths.

llvm-svn: 158418
2012-06-13 20:27:03 +00:00
Richard Trieu dc3559106b Moved the StringLiteral printing code from StmtPrinter into the StringLiteral
class and have StmtPrinter and StmtDumper refer to it.  This fixes an
assertion failure when dumping wchar string literals.

llvm-svn: 158417
2012-06-13 20:25:24 +00:00
John McCall 7dd1783c5e Provide a -no-pedantic to cancel out -pedantic.
llvm-svn: 158416
2012-06-13 19:48:01 +00:00
Daniel Jasper 4e525e216d Rename shouldVisitImplicitDeclarations to shouldVisitImplicitCode.
Fix RecursiveASTVisitor to visit CXXForRangeStmts accordingly to visit
implicit or explicit code.

The key bug that inspired this was the Visitor not visiting the range
initializer of such a loop, which is explicit code.

llvm-svn: 158395
2012-06-13 07:12:33 +00:00
Craig Topper db0fbf0a50 Add XOP permute intrinsics.
llvm-svn: 158351
2012-06-12 06:03:35 +00:00
Richard Smith 700537cddf If parsing a trailing-return-type fails, don't pretend we didn't have one at
all. Suppresses follow-on errors mentioned in PR13074.

llvm-svn: 158348
2012-06-12 01:51:59 +00:00
Dmitri Gribenko c69a5be0cc Correct comment. The return type was changed to const Type* in r123814. Patch by David Röthlisberger.
llvm-svn: 158347
2012-06-12 01:21:44 +00:00
Chad Rosier 32503020a4 Etch out the code path for MS-style inline assembly.
llvm-svn: 158325
2012-06-11 20:47:18 +00:00
Benjamin Kramer 697067fae9 Enable -Wunused-private-field with -Wunused.
It found a lot of cruft in LLVM that I removed last week and I couldn't find any
false positives. Time to give it more testing.

llvm-svn: 158317
2012-06-11 16:06:57 +00:00
Craig Topper ce8dbaadb6 Add XOP shift and compare intrinsics.
llvm-svn: 158300
2012-06-11 07:01:43 +00:00
James Dennett 1355bd17c6 Documentation cleanup, fixing Doxygen markup. Mostly this avoids common terms
such as "protocol" and "expression" being implicitly turned into links to
mistakenly-generated Doxygen pages:
- Escaping @ symbols when Doxygen would otherwise incorrectly interpret them;
- Escaping # symbols when they're not intended as explicit Doxygen link 
  requests, such as when discussing preprocessor directives;
- In one odd case, unescaping @ in @__experimental_modules_import, because
  Doxygen wrote '\@' to the output in that case, causing the example in the
  description of ImportDecl to be wrong; and
- Fixing a typo: @breif -> @brief.

llvm-svn: 158299
2012-06-11 06:19:40 +00:00
Argyrios Kyrtzidis ff32674d3a Const'ify CompilerInvocation::toArgs().
llvm-svn: 158298
2012-06-11 03:34:26 +00:00
Craig Topper a3c5fbf54b Add XOP vprot* instruction intrinsics
llvm-svn: 158292
2012-06-10 07:47:32 +00:00
Richard Smith 4086a13df8 Remove CXXRecordDecl flags which are unused after r158289.
We need an efficient mechanism to determine whether a defaulted default
constructor is constexpr, in order to determine whether a class is a literal
type, so keep the incrementally-built form on CXXRecordDecl. Remove the
on-demand computation of same, so that we only have one method for determining
whether a default constructor is constexpr. This doesn't affect correctness,
since default constructor lookup is much simpler than selecting a constructor
for copying or moving.

We don't need a corresponding mechanism for defaulted copy or move constructors,
since they can't affect whether a type is a literal type. Conversely, checking
whether such functions are constexpr can require non-trivial effort, so we defer
such checks until the copy or move constructor is required.

Thus we now only compute whether a copy or move constructor is constexpr on
demand, and only compute whether a default constructor is constexpr in advance.
This is unfortunate, but seems like the best solution.

llvm-svn: 158290
2012-06-10 07:07:24 +00:00
Richard Smith 2b013185f8 PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.

llvm-svn: 158288
2012-06-10 03:12:00 +00:00
Craig Topper 02b3d81a97 More XOP intrinsics
llvm-svn: 158287
2012-06-10 02:46:15 +00:00
Craig Topper 33b6d5e20b Begin adding XOP intrinsics
llvm-svn: 158286
2012-06-10 00:39:38 +00:00
James Dennett f3d90890ec Fix the top-of-file comment in Attr.h to say that it's about attributes, not
expressions.

llvm-svn: 158285
2012-06-09 23:00:13 +00:00
Benjamin Kramer 8ea1fe028c Reorder ParsedTemplateArg's members to reduce padding on x86_64.
llvm-svn: 158275
2012-06-09 15:15:27 +00:00
Benjamin Kramer a74cf08e68 Replace constant-sized BitVector with std::bitset.
llvm-svn: 158270
2012-06-09 12:56:12 +00:00
Argyrios Kyrtzidis 091b87bb9d [libclang] When doing the cursor visitation make sure declarations
in the same line do not override getting a cursor for the previous declaration.

e.g:

int x, y;
@synthesize prop1, prop2;

pointing at 'x'/'prop1' would give 'y'/'prop2' because their source ranges overlap.

rdar://11361113

llvm-svn: 158258
2012-06-09 03:03:02 +00:00
Dmitri Gribenko 702b732d6f Correct method name in comment: from LexRawToken to LexFromRawLexer, according
to a change done long ago in r57393.

llvm-svn: 158243
2012-06-08 23:19:37 +00:00
Dmitri Gribenko 4280e5cf97 Convert comments to proper Doxygen comments.
llvm-svn: 158241
2012-06-08 23:13:42 +00:00
Jordan Rose d8d5669435 Warn in ObjC++ when an 'auto' variable deduces type 'id'.
This could happen for cases like this:

- (NSArray *)getAllNames:(NSArray *)images {
  NSMutableArray *results = [NSMutableArray array];
  for (auto img in images) {
    [results addObject:img.name];
  }
  return results;
}

Here the property access will fail because 'img' has type 'id', rather than,
say, NSImage.

This warning will not fire in templated code, since the 'id' could have
come from a template parameter.

llvm-svn: 158239
2012-06-08 22:46:07 +00:00
Jordan Rose d49a33e86c Disallow using ObjC literals in direct comparisons (== and friends).
Objective-C literals conceptually always create new objects, but may be
optimized by the compiler or runtime (constant folding, singletons, etc).
Comparing addresses of these objects is relying on this optimization
behavior, which is really an implementation detail.

In the case of == and !=, offer a fixit to a call to -isEqual:, if the
method is available. This fixit is directly on the error so that it is
automatically applied.

Most of the time, this is really a newbie mistake, hence the fixit.

llvm-svn: 158230
2012-06-08 21:14:25 +00:00
Richard Smith 12f247f43f PR13051: If a constructor is explicitly defaulted, it isn't marked as being
constexpr until we get to the end of the class definition. When that happens,
be sure to remember that the class actually does have a constexpr constructor.

This is a stopgap solution, which still doesn't cover the case of a class with
multiple copy constructors (only some of which are constexpr). We should be
performing constructor lookup when implicitly defining a constructor in order
to determine whether all constructors it invokes are constexpr.

llvm-svn: 158228
2012-06-08 21:09:22 +00:00
Jordan Rose de1a29277e Disable _Pragma during HTML macro rewriting to keep from crashing.
The preprocessor's handling of diagnostic push/pops is stateful, so
encountering pragmas during a re-parse causes problems. HTMLRewrite
already filters out normal # directives including #pragma, so it's
clear it's not expected to be interpreting pragmas in this mode.

This fix adds a flag to Preprocessor to explicitly disable pragmas.
The "right" fix might be to separate pragma lexing from pragma
parsing so that we can throw away pragmas like we do preprocessor
directives, but right now it's important to get the fix in.

Note that this has nothing to do with the "hack" of re-using the
input preprocessor in HTMLRewrite. Even if we someday copy the
preprocessor instead of re-using it, the copy would (and should) include
the diagnostic level tables and have the same problems.

llvm-svn: 158214
2012-06-08 18:06:21 +00:00
Douglas Gregor 02c2dbf45e Switch LineTableInfo to use FileID instead of int for file references,
from Tom Honermann!

llvm-svn: 158211
2012-06-08 16:40:28 +00:00
Argyrios Kyrtzidis 1416e17c89 [libclang] Don't crash when saving a PCH from a prefix header
that does not exist.

rdar://11607033

llvm-svn: 158193
2012-06-08 05:48:06 +00:00
Douglas Gregor fed6699dd9 Add ext_vector type code for builtins, from John Garvin!
llvm-svn: 158156
2012-06-07 18:08:25 +00:00
Chandler Carruth 48687a5a00 Fix many doxygen formatting errors.
This patch affects docs only, and includes formatting changes only
(though those include some fixes for broken Doxygen markup that caused
some content to be missing from generated pages).  It avoids generating
many spurious pages such as
http://clang.llvm.org/doxygen/classRepresents.html, but likely not all
yet.

Patch by James Dennett.

llvm-svn: 158155
2012-06-07 17:55:42 +00:00
Benjamin Kramer 5d4cff72b4 Reuse APInt's getNumWords, which gets rounding right (my ad-hoc solution missed it).
llvm-svn: 158151
2012-06-07 15:54:03 +00:00
Benjamin Kramer 6003ad5848 Plug a long standing memory leak in TemplateArgument.
The integral APSInt value is now stored in a decomposed form and the backing
store for large values is allocated via the ASTContext. This way its not
leaked as TemplateArguments are never destructed when they are allocated in
the ASTContext. Since the integral data is immutable it is now shared between
instances, making copying TemplateArguments a trivial operation.

Currently getting the integral data out of a TemplateArgument requires creating
a new APSInt object. This is cheap when the value is small but can be expensive
if it's not. If this turns out to be an issue a more efficient accessor could
be added.

llvm-svn: 158150
2012-06-07 15:09:51 +00:00
Anna Zaks 3563fde6a0 [analyzer] Anti-aliasing: different heap allocations do not alias
Add a concept of symbolic memory region belonging to heap memory space.
When comparing symbolic regions allocated on the heap, assume that they
do not alias. 

Use symbolic heap region to suppress a common false positive pattern in
the malloc checker, in code that relies on malloc not returning the
memory aliased to other malloc allocations, stack.

llvm-svn: 158136
2012-06-07 03:57:32 +00:00
Jordan Rose 288c421b3d Insert a space if necessary when suggesting CFBridgingRetain/Release.
This was a problem for people who write 'return(result);'

Also fix ARCMT's corresponding code, though there's no test case for this
because implicit casts like this are rejected by the migrator for being
ambiguous, and explicit casts have no problem.

<rdar://problem/11577346>

llvm-svn: 158130
2012-06-07 01:10:31 +00:00
Douglas Gregor 91c25eadea Whenever we have a BalancedDelimiterTracker, we have a 'nested' scope
where '>' is going to behave as an operator (and not as a '>' closing
a template argument list).

llvm-svn: 158111
2012-06-06 21:18:07 +00:00
Jordan Rose 0da4e77880 [analyzer] Provide debug descriptions for all memory space regions.
Patch by Guillem Marpons!

llvm-svn: 158106
2012-06-06 20:47:00 +00:00
Jordan Rose a929f2c863 Fix Makefile: Options.td depends on CC1Options.td.
llvm-svn: 158105
2012-06-06 20:46:55 +00:00
David Blaikie 40ed29730b Revert Decl's iterators back to pointer value_type rather than reference value_type
In addition, I've made the pointer and reference typedef 'void' rather than T*
just so they can't get misused. I would've omitted them entirely but
std::distance likes them to be there even if it doesn't use them.

This rolls back r155808 and r155869.

Review by Doug Gregor incorporating feedback from Chandler Carruth.

llvm-svn: 158104
2012-06-06 20:45:41 +00:00
David Blaikie d5321247c4 Add a -rewrite-includes option, which is similar to -rewrite-macros, but only expands #include directives.
Patch contributed by Lubos Lunak (l.lunax@suse.cz).
Review by Matt Beaumont-Gay (matthewbg@google.com).

llvm-svn: 158093
2012-06-06 18:52:13 +00:00
Benjamin Kramer d1d76b2da7 Remove unused private member variables found by clang's new -Wunused-private-field.
llvm-svn: 158086
2012-06-06 17:32:50 +00:00
Jordan Rose ccf43ca05c Add pedantic warning -Wempty-translation-unit (C11 6.9p1).
In standard C since C89, a 'translation-unit' is syntactically defined to have
at least one "external-declaration", which is either a decl or a function
definition. In Clang the latter gives us a declaration as well.

The tricky bit about this warning is that our predefines can contain external
declarations (__builtin_va_list and the 128-bit integer types). Therefore our
AST parser now makes sure we have at least one declaration that doesn't come
from the predefines buffer.

Also, remove bogus warning about empty source files. This doesn't catch source
files that only contain comments, and never fired anyway because of our
predefines.

PR12665 and <rdar://problem/9165548>

llvm-svn: 158085
2012-06-06 17:25:21 +00:00
Daniel Jasper 0baec549a3 Introduce -Wunused-private-field. If enabled, this warning detects
unused private fields of classes that are fully defined in the current
translation unit.

llvm-svn: 158054
2012-06-06 08:32:04 +00:00
Richard Smith b34dc87826 RecursiveASTVisitor: add ability to visit implicit declarations. Patch by
James Dennett!

llvm-svn: 158002
2012-06-05 16:18:26 +00:00
Richard Smith eb3cad53e7 Add a warning for when an array-to-pointer decay is performed on an array
temporary or an array subobject of a class temporary, and the resulting value
is used to initialize a pointer which outlives the temporary. Such a pointer
is always left dangling after the initialization completes and the array's
lifetime ends.

In order to detect this situation, this change also adds an
LValueClassification of LV_ArrayTemporary for temporaries of array type which
aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++
(T){...} expressions, when T is an array type. Previously we treated the former
as a generic prvalue and the latter as a class temporary.

llvm-svn: 157955
2012-06-04 22:27:30 +00:00
Argyrios Kyrtzidis 6310fdd982 [objcmt] Don't migrate to subscripting syntax if the required methods have not
been declared on NSArray/NSDictionary.

rdar://11581975

llvm-svn: 157951
2012-06-04 21:23:26 +00:00
Alexander Kornienko 8388d24701 Fixed a problem related to resolution of built-in headers in case a path of tool's binary contains sym-links.
llvm-svn: 157944
2012-06-04 19:02:59 +00:00
Aaron Ballman f0b67b6f5c Removing the lambda extension warning concerning single return statements, as it no longer applies.
llvm-svn: 157943
2012-06-04 18:57:41 +00:00
Evgeniy Stepanov ea155f0153 Require -pie when linking with ASan on Android.
llvm-svn: 157923
2012-06-04 11:15:05 +00:00
Hans Wennborg 96fe81069b Test the '__thread' before 'static' warning.
Also fix the '__thread' before 'extern' case.

llvm-svn: 157921
2012-06-04 10:19:34 +00:00
Benjamin Kramer 474261af7b Fix typos found by http://github.com/lyda/misspell-check
llvm-svn: 157886
2012-06-02 10:20:41 +00:00
Alexander Kornienko 06caf7d59f Implementation of a "soft opt-in" option for -Wimplicit-fallthrough diagnostics: -Wimplicit-fallthrough-per-method
llvm-svn: 157871
2012-06-02 01:01:07 +00:00
Anna Zaks 7ba2615047 [analyzer] Rely on canBeInlined utility instead of checking CallExpr
explicitly.

This will make it easier to add inlining support to more expressions.

llvm-svn: 157870
2012-06-02 00:40:52 +00:00
Ted Kremenek c3da376fbc static analyzer: add inlining support for directly called blocks.
llvm-svn: 157833
2012-06-01 20:04:04 +00:00
Argyrios Kyrtzidis 273c7c40b2 [arcmt] Use CFBridgingRetain/CFBridgingRelease instead of __bridge_retained/__bridge_transfer
when migrating.

rdar://11569198

llvm-svn: 157785
2012-06-01 00:10:47 +00:00
Alexander Kornienko 21d6ec9224 Fix an object lifetime issue in clang/Tooling.
llvm-svn: 157759
2012-05-31 17:58:43 +00:00
Ted Kremenek 16704bb15b Allow some BugReports to opt-out of PathDiagnostic callstack pruning until we have significantly
improved the pruning heuristics.  The current heuristics are pretty good, but they make diagnostics
for uninitialized variables warnings particularly useless in some cases.

llvm-svn: 157734
2012-05-31 06:03:17 +00:00
Craig Topper 3f122a7636 Add builtin for pclmulqdq instruction.
llvm-svn: 157733
2012-05-31 05:18:48 +00:00
Richard Smith ee48633937 Only visit default arguments for template declarations when visiting the template declaration which introduced them. Patch by Yang Chen!
llvm-svn: 157723
2012-05-30 23:55:51 +00:00
Anna Zaks d08d9159c2 Change wording of 'memcpy' type mismatch warning and remove fixit.
As per comments following r157659.

llvm-svn: 157722
2012-05-30 23:14:52 +00:00
David Blaikie 7e6ad46275 Disable -Wunique-enum for anonymous enums.
This is a large class of false positives where anonymous enums are used to
declare constants (see Clang's Diagnostics.h for example). A small number of
true positives could probably be found in this bucket by still warning if the
anonymous enum is used in a declarator (enum { ... } x;) but so far we don't
believe this to be a source of significant benefit so I haven't bothered to
preserve those cases.

General offline review/acknowledgment by rtrieu.

llvm-svn: 157713
2012-05-30 20:45:14 +00:00
Manuel Klimek 8b1c60220d Adds a toString method to Replacement, which helps debugging.
Adds missing header guards to Refactoring.h.

llvm-svn: 157694
2012-05-30 16:04:29 +00:00
Craig Topper 85e100ff37 Mark extrqi and insertqi immediate arguments as being ICE.
llvm-svn: 157675
2012-05-30 04:45:24 +00:00
Richard Trieu 01cf09302d Add new -Wunique-enum which will warn on enums which all elements have the
same value and were initialized with literals.  Clang will warn on code like
this:

enum A {
  FIRST = 1,
  SECOND = 1
};

llvm-svn: 157666
2012-05-30 01:01:11 +00:00
Anna Zaks 869aeccada Add fixits for memory access warnings.
Also, do not display the builtin name and macro expansion when the
function is a builtin.

llvm-svn: 157659
2012-05-30 00:34:21 +00:00
Benjamin Kramer ba6e2528fa Add an ammintrin.h header for SSE4a intrinsics.
This is a clean-room implementation based on public documentation and
I tried to validate it as much as possible against gcc.

llvm-svn: 157638
2012-05-29 19:10:17 +00:00
Simon Atanasyan a16b7fd029 Factor out the code retrieves the last PIC related argument from
the Clang::ConstructJob() to the new ArgList::getLastArg() routine
with eight argument. That simplifies reusing of this code.

llvm-svn: 157633
2012-05-29 18:50:33 +00:00
Chad Rosier 68d2ca7ecc Revert r155737, restoring the MaxDepth in the BalancedDelimiterTracker to 256.
r155737 turned out to be a temporary work around.  The correct fix was in r155823.

llvm-svn: 157627
2012-05-29 16:57:50 +00:00
Benjamin Kramer 938a71ff18 Fix suspicous isIntegerType() check, found by PVS Studio (PR12357).
llvm-svn: 157593
2012-05-28 21:01:59 +00:00
David Blaikie 7e64fd9d53 Address minor FIXME in RedeclLink to contain a PointerIntPair instead of derive from it.
Use actual factory functions rather than derived classes acting as named constructors/factories.

llvm-svn: 157588
2012-05-28 19:38:42 +00:00
Benjamin Kramer 443488eba9 Pass ProgramStateRef by reference.
Retain + Release on a ref counted pointer is cheap, but not free (it adds a function call in this case).

llvm-svn: 157534
2012-05-27 15:32:10 +00:00
Benjamin Kramer b33ffee04f Use the SelectorSet typedef more widely throughout Sema.
While there make it a SmallPtrSet.

llvm-svn: 157532
2012-05-27 13:28:52 +00:00
Benjamin Kramer 69b5a60d96 Replace some custom hash combines with the standard stuff from DenseMapInfo.
llvm-svn: 157531
2012-05-27 13:28:44 +00:00
Fariborz Jahanian f3b7681f2b Change warning to error when property setter names conflict.
// rdar://11528439

llvm-svn: 157517
2012-05-26 16:10:06 +00:00
Richard Smith 1bb8edb8ac In response to some discussions on IRC, tweak the wording of the new
-Wsometimes-uninitialized diagnostics to make it clearer that the cause
of the issue may be a condition which must always evaluate to true or
false, rather than an uninitialized variable.

To emphasize this, add a new note with a fixit which removes the
impossible condition or replaces it with a constant.

Also, downgrade the diagnostic from -Wsometimes-uninitialized to
-Wconditional-uninitialized when it applies to a range-based for loop,
since the condition is not written explicitly in the code in that case.

llvm-svn: 157511
2012-05-26 06:20:46 +00:00
Richard Smith 4323bf8e2e Split a chunk of -Wconditional-uninitialized warnings out into a separate flag,
-Wsometimes-uninitialized. This detects cases where an explicitly-written branch
inevitably leads to an uninitialized variable use (so either the branch is dead
code or there is an uninitialized use bug).

This chunk of warnings tentatively lives within -Wuninitialized, in order to
give it more visibility to existing Clang users.

llvm-svn: 157458
2012-05-25 02:17:09 +00:00
Fariborz Jahanian 3f88afad2f objective-c: warn on use of property setters
backing two propeties because proprty names
match except for first letter being of different
case. // rdar://11528439, [PR12936].

llvm-svn: 157435
2012-05-24 22:48:38 +00:00
Justin Holewinski 83e9668133 Replace PTX back-end with NVPTX back-end in all places where Clang cares
NV_CONTRIB

llvm-svn: 157403
2012-05-24 17:43:12 +00:00
Fariborz Jahanian 870265636c objc: change option to be -Wobjc-interface-ivars
llvm-svn: 157394
2012-05-24 16:19:51 +00:00
Manuel Klimek 9ffebff74c Apply review comment from Jordan Rose.
llvm-svn: 157387
2012-05-24 12:46:43 +00:00
Eli Friedman c11535c248 Add a warning to diagnose statements in C++ like "*(volatile int*)x;". Conceptually, this is part of -Wunused-value, but I added a separate flag -Wunused-volatile-lvalue so it doesn't get turned off by accident with -Wno-unused-value. I also made a few minor improvements to existing unused value warnings in the process. <rdar://problem/11516811>.
llvm-svn: 157362
2012-05-24 00:47:05 +00:00
Nuno Lopes 5c7ad16fdd implement Sema support for the alloc_size attribute
Portions of this patch by Xi Wang. Reviewed by Jordy Rose. Thank you both.

Codegen support will follow soon.

llvm-svn: 157360
2012-05-24 00:22:00 +00:00
Manuel Klimek 3f00134c05 Adds the Refactoring library, which is a layer on top of the Tooling library
that allows easy refactoring across translation units.

llvm-svn: 157331
2012-05-23 16:29:20 +00:00
John McCall 8d32c05ed4 Recognize the MS inheritance attributes and turn them into attributes
on the RecordDecl.  Persist the MS portability type attributes and
ignore them in Sema rather than the parser.

Patch by João Matos!

llvm-svn: 157288
2012-05-22 21:28:12 +00:00
Nuno Lopes a425589fea wire -fbounds-checking to the new LLVM bounds checking pass
llvm-svn: 157262
2012-05-22 17:19:45 +00:00
Manuel Klimek 78d084d942 Adds a method overwriteChangedFiles to the Rewriter. This is implemented by
first writing the changed files to a temporary location and then overwriting
the original files atomically.

Also adds a RewriterTestContext to aid unit testing rewrting logic in general.

llvm-svn: 157260
2012-05-22 17:01:35 +00:00