Commit Graph

31894 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 035674d33c [libclang] Annotate correctly macro argument tokens.
llvm-svn: 137961
2011-08-18 18:03:34 +00:00
Chad Rosier 2f8187933f Use StringRef, rather than C string APIs.
llvm-svn: 137958
2011-08-18 17:56:32 +00:00
Manuel Klimek d9d2138561 Fixes traversal of class template nodes on template instantiations.
Also fixes a spelling error.

llvm-svn: 137945
2011-08-18 16:50:43 +00:00
Francois Pichet 17ed020569 Add support for MSVC __unaligned attribute. Necessary to parse MSVC headers in 64-bit mode (ie: when _M_IA64 or _M_AMD64 is defined)
more info: http://msdn.microsoft.com/en-us/library/ms177389.aspx

llvm-svn: 137935
2011-08-18 09:59:55 +00:00
Chandler Carruth 48b2831d8a Always mark friend function declarations in class templates as
implicitly instantiable, even if we don't see a body on the friend
function declaration. The body may simply have not yet been attached.
This fixes PR10666.

There may be an alternate, preferred implementation strategy, see my
FIXME. Review would definitely be appreciated Doug. =D

llvm-svn: 137934
2011-08-18 09:09:59 +00:00
Douglas Gregor 914eb7c18a Teach ModuleManager::addModule() to check whether a particular module
has already been loaded before allocating a new Module structure. If
the module has already been loaded (uniquing based on file name), then
just return the existing module rather than trying to load it again.

This allows us to load a DAG of modules. Introduce a simple test case
that forms a diamond-shaped module graph, and illustrates that a
source file importing the bottom of the diamond can see declarations
in all four of the modules that make up the diamond.

llvm-svn: 137925
2011-08-18 04:41:58 +00:00
Douglas Gregor df0c151ba6 Keep track of which modules have been loaded directly (e.g., via
-import-module) vs. loaded because some other module depends on
them. As part of doing this, pass down the module that caused a module
to be loaded directly, rather than assuming that we're loading a
chain. Finally, write out all of the directly-loaded modules when
serializing an AST file (using the new IMPORTS record), so that an AST
file can depend on more than one other AST file, all of which will be
loaded when that AST file is loaded. This allows us to form and load a
tree of modules, but we can't yet load a DAG of modules.

llvm-svn: 137923
2011-08-18 04:12:04 +00:00
Ted Kremenek 13fd55d85f Revert r137903, "Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now)."
This currently doesn't work on Windows.

llvm-svn: 137920
2011-08-18 02:18:02 +00:00
Chad Rosier f44aa3fe82 No seriously, remove the unsupported warning options.
llvm-svn: 137918
2011-08-18 02:08:52 +00:00
Anna Zaks ab935f26e6 Fix a regression form r137894. Make sure the custom BugReporterVisitors get registred as they were in EnhancedBugReport. Would be good to add a test for this.
llvm-svn: 137917
2011-08-18 02:05:18 +00:00
Chandler Carruth 2b949c2b4b Remove the last FIXMEs on -Wunused-comparison since it got moved to
entirely use the existing -Wunused-value infrastructure. This also fixes
a few missed cases for -Wunused in general.

llvm-svn: 137916
2011-08-18 02:04:29 +00:00
Chad Rosier ee403fa613 Fix off by one.
llvm-svn: 137915
2011-08-18 01:23:31 +00:00
Chad Rosier 3045386527 [driver] Implement in a more table-like manner and add many more warning options
that aren't handled by llvm-gcc on fallback.
Enhancement to rdar://9964354

llvm-svn: 137912
2011-08-18 01:18:28 +00:00
Ted Kremenek 66bfc1db14 Add documentation on -Weverything.
llvm-svn: 137911
2011-08-18 01:17:05 +00:00
Ted Kremenek fbbdcedc2e Implement '-Weverything', which enables all warnings except those explicitly mapped to be ignored.
Currently this includes -pedantic warnings as well; we'll need to consider whether these should
be included.

This works as expected with -Werror.

Test cases were added to Sema/warn-unused-parameters.c, but they should probably be broken off into
their own test file.

llvm-svn: 137910
2011-08-18 01:12:56 +00:00
Argyrios Kyrtzidis 85a14bbd31 For the MacroExpands preprocessor callback, also pass the SourceRange
of expansion (for function macros it includes the right paren).

llvm-svn: 137909
2011-08-18 01:05:45 +00:00
Eric Christopher cf41632cb1 Add some more options that aren't handled by llvm-gcc on fallback.
This is going to be made a table.

llvm-svn: 137907
2011-08-18 00:26:15 +00:00
Chad Rosier d57133dcca [driver] Don't generate diagnostics (i.e., preprocessed source) if reading
from stdin.  This allows Eli and the like to continue with their debugging 
trickery without loss of limb (or car) on my part. :)

llvm-svn: 137906
2011-08-18 00:22:25 +00:00
Bruno Cardoso Lopes bf9246d1f0 "-mavx" should also enable all other SSE levels.
llvm-svn: 137905
2011-08-18 00:07:03 +00:00
Francois Pichet 4c7269474e Downgrade "err_init_list_variable_narrowing" into a warning in Microsoft mode even if c++0x is enabled. This necessary to parse MSVC code in C++0x mode.
llvm-svn: 137904
2011-08-18 00:04:08 +00:00
Ted Kremenek d5fe9e4d97 Add experimental -Wstrlcpy-size warning that looks to see if the size argument for strlcpy/strlcat is the size of the *source*, and not the size of the *destination*. This warning is off by default (for now).
Warning logic provided by Geoff Keating.

llvm-svn: 137903
2011-08-17 23:40:36 +00:00
Anna Zaks db2acbc5dd Add more comments for BugReport.
llvm-svn: 137901
2011-08-17 23:36:16 +00:00
Anna Zaks 525cfe7d28 Remove DiagBugReport by pulling it into its parent BugReport.
llvm-svn: 137899
2011-08-17 23:21:23 +00:00
Chad Rosier 6fdf38bfbd Fix else style. No functionality change intended.
llvm-svn: 137896
2011-08-17 23:08:45 +00:00
Anna Zaks 3a6bdf8f82 Remove EnhancedBugReport and RangedBugReport - pull all the extra functionality they provided into their parent BugReport. The only functional changes are: made getRanges() non const - it adds default range to Ranges if none are supplied, made getStmt() private, which was another FIXME.
llvm-svn: 137894
2011-08-17 23:00:25 +00:00
Eric Christopher f901e85533 Fix typo.
llvm-svn: 137893
2011-08-17 22:59:59 +00:00
Ted Kremenek 5b8ad40664 [libclang] Workaround potential race condition with code completion AllocatedResults being freed after a CXTranslationUnit.
The Container USR's CXString had its underlying data owned by the CXTranslationUnit's string pool.  This
would result in trying to access freed memory.

llvm-svn: 137887
2011-08-17 22:19:53 +00:00
John McCall 5500ef27be Reorganize the return-type vs. expression checking code in
block returns; no functionality change.

llvm-svn: 137884
2011-08-17 22:09:46 +00:00
John McCall 7d92c70e6f Somehow I fouled up this test.
llvm-svn: 137882
2011-08-17 22:04:02 +00:00
Argyrios Kyrtzidis d5553f1c34 Remove an unnecessary assignment (to InstFromD).
Caught by the static analyzer!

llvm-svn: 137878
2011-08-17 21:35:28 +00:00
John McCall 75f92b519c Gather cleanups correctly in block return statements.
Thanks to Ted for finding this with magic tools.

llvm-svn: 137877
2011-08-17 21:34:14 +00:00
Jordy Rose 217eb9043f [analyzer] Migrate assumption and binding handling from CFRefCount to RetainReleaseChecker. This is mostly a textual move and required no supporting changes. No functionality change intended.
llvm-svn: 137874
2011-08-17 21:27:39 +00:00
Ted Kremenek 897af91e1a Fix incorrect code indentation and silence dead store warning due to idiomatic code.
llvm-svn: 137870
2011-08-17 21:09:35 +00:00
Douglas Gregor 29cc642f68 In the AST file format, eliminate the CHAINED_METADATA record. Instead,
all AST files have a normal METADATA record that has the same form
regardless of whether we refer to a chained PCH or any other kind of
AST file.

Introduce the IMPORTS record, which describes all of the AST files
that are imported by this AST file, and how (as a module, a PCH file,
etc.). Currently, we emit at most one entry to this record, to support
chained PCH.

llvm-svn: 137869
2011-08-17 21:07:30 +00:00
Ted Kremenek c14efa7122 Fix a handful of dead stores found by Clang's static analyzer. There's a bunch of others I haven't touched.
llvm-svn: 137867
2011-08-17 21:04:19 +00:00
Anna Zaks 8af4bbc60a Add a bit more comments to the BugReporter and friends.
llvm-svn: 137859
2011-08-17 20:25:08 +00:00
Argyrios Kyrtzidis d8b87a8b2e [libclang] Implicit objc methods are skipped, no need to check isSynthesized.
Plus, isSynthesized returning true does not mean that there is not a user-declared method declaration.

llvm-svn: 137858
2011-08-17 20:15:55 +00:00
Argyrios Kyrtzidis 004df6e053 Mark objc methods that are implicitly declared for properties (not user-declared) as implicit.
This results in libclang ignoring such methods.

llvm-svn: 137852
2011-08-17 19:25:08 +00:00
Douglas Gregor 14208800fa Fix -ferror-limit= to properly emit notes following the last error
messages. Fi from David Blaikie, tests from Nikola Smiljanic!

llvm-svn: 137851
2011-08-17 19:13:00 +00:00
Chad Rosier 23594f6b44 Fix iterator end for r137842.
llvm-svn: 137849
2011-08-17 18:51:56 +00:00
Chad Rosier bc5ea3d4b9 [driver] Clang doesn't support -mkernel/-fapple-kext for i386, so it's
automatically invoking llvm-gcc's cc1plus, which doesn't support all options
supported by Clang.  Therefore, filter out unsupported options.
rdar://9964354

llvm-svn: 137842
2011-08-17 18:24:55 +00:00
Eli Friedman 872900987d Add additional path to Linux toolchain. Patch by Will Dietz. PR10690.
llvm-svn: 137839
2011-08-17 18:17:26 +00:00
Nico Weber 80806a7b91 Add Gentoo gcc 4.3.4 include paths
llvm-svn: 137834
2011-08-17 17:55:30 +00:00
Argyrios Kyrtzidis 3fce368d87 [python] Fix bug of the SourceLocation binding.
Patch by Anders Waldenborg!

llvm-svn: 137829
2011-08-17 17:20:24 +00:00
Argyrios Kyrtzidis 8f6bd2d653 [python] Add test_type.py by Anders Waldenborg, which I forgot to commit in r137797.
llvm-svn: 137828
2011-08-17 17:01:10 +00:00
Chandler Carruth 463394752b Whitelist operator== and operator!= as valid for unused value warnings,
even when overloaded and user-defined. These operators are both more
valuable to warn on (due to likely typos) and extremely unlikely to be
reasonable for use to trigger side-effects.

llvm-svn: 137823
2011-08-17 09:49:44 +00:00
Chandler Carruth e2669397f1 Treating the unused equality comparisons as something other than part of
-Wunused was a mistake. It resulted in duplicate warnings and lots of
other hacks. Instead, this should be a special sub-category to
-Wunused-value, much like -Wunused-result is.

Moved to -Wunused-comparison, moved the implementation to piggy back on
the -Wunused-value implementation instead of rolling its own, different
mechanism for catching all of the "interesting" statements.

I like the unused-value mechanism for this better, but its currently
missing several top-level statements. For now, I've FIXME-ed out those
test cases. I'll enhance the generic infrastructure to catch these
statements in a subsequent patch.

This patch also removes the cast-to-void fixit hint. This hint isn't
available on any of the other -Wunused-value diagnostics, and if we want
it to be, we should add it generically rather than in one specific case.

llvm-svn: 137822
2011-08-17 09:34:37 +00:00
Chandler Carruth 29027b9352 Fix this test which had encoded the typo fixed in r137814.
llvm-svn: 137821
2011-08-17 08:56:14 +00:00
Chandler Carruth e89ca5f7d2 Don't suggest assignment in implausible situation. We still warn, as the
code is very likely to be buggy, but its going to require more
significant changes on the part of the user to correct it in this case.

llvm-svn: 137820
2011-08-17 08:38:11 +00:00
Chandler Carruth ae51ecc57b Introduce a new warning, -Wtop-level-comparison. This warning is
a complement to the warnings we provide in condition expressions. Much
like we warn on conditions such as:

  int x, y;
  ...
  if (x = y) ... // Almost always a typo of '=='

This warning applies the complementary logic to "top-level" statements,
or statements whose value is not consumed or used in some way:

  int x, y;
  ...
  x == y; // Almost always a type for '='

We also mirror the '!=' vs. '|=' logic.

The warning is designed to fire even for overloaded operators for two reasons:

1) Especially in the presence of widespread templates that assume
   operator== and operator!= perform the expected comparison operations,
   it seems unreasonable to suppress warnings on the offchance that
   a user has written a class that abuses these operators, embedding
   side-effects or other magic within them.
2) There is a trivial source modification to silence the warning for
   truly exceptional cases:

     (void)(x == y); // No warning

A (greatly reduced) form of this warning has already caught a number of
bugs in our codebase, so there is precedent for it actually firing. That
said, its currently off by default, but enabled under -Wall.

There are several fixmes left here that I'm working on in follow-up
patches, including de-duplicating warnings from -Wunused, sharing code
with -Wunused's implementation (and creating a nice place to hook
diagnostics on "top-level" statements), and handling cases where a proxy
object with a bool conversion is returned, hiding the operation in the
cleanup AST nodes.

Suggestions for any of this code more than welcome. Also, I'd really
love suggestions for better naming than "top-level".

llvm-svn: 137819
2011-08-17 08:38:04 +00:00