Commit Graph

21960 Commits

Author SHA1 Message Date
John McCall 3155f573f5 Turn access control on by default in -cc1.
Remove -faccess-control from -cc1; add -fno-access-control.
Make the driver pass -fno-access-control by default.
Update a bunch of tests to be correct under access control.

llvm-svn: 100880
2010-04-09 19:03:51 +00:00
John McCall da6841bade Suppress access control diagnostics when looking up a base or member name
fails to find a type.  There are no cases where it's valid for this to produce
an error.

llvm-svn: 100878
2010-04-09 19:01:14 +00:00
Douglas Gregor b10646d4ce Improve diagnostics like "initializing <type> from an expression of
type..." with "initializing <type> with an expression of type...",
which reads better. Thanks to John for the improved wording.

llvm-svn: 100873
2010-04-09 17:53:29 +00:00
Douglas Gregor fb8b27d530 Remove all "used" static functions *after* we have performed all of
the implicit template instantiations we need to perform. Otherwise, we
end up erroneously diagnosing static functions as used if they were
only used within an implicit template instantiation. Fixes a bunch of
spurious failures when building Clang with Clang.

llvm-svn: 100872
2010-04-09 17:41:13 +00:00
John McCall b29f78fb9e Instantiate default argument expressions even if their associated parameter
type isn't dependent.  Fixes rdar://problem/7838962.

llvm-svn: 100871
2010-04-09 17:38:44 +00:00
Chris Lattner 8a651c7116 Don't warn about unused static functions if they are marked with
attr constructor or destructor.  Patch by Jean-Daniel Dupas!

llvm-svn: 100870
2010-04-09 17:25:05 +00:00
Douglas Gregor 08288f2846 On Windows, disable the modification-time check for files used in
precompiled headers and/or when reading the contents of the file into
memory. These checks seem to be causing spurious regression-test
failures on Windows.

llvm-svn: 100866
2010-04-09 15:54:22 +00:00
Fariborz Jahanian cdabb31d6f Fixes a regression caused by implementing cstyle methods
for objc.

llvm-svn: 100865
2010-04-09 15:40:42 +00:00
Daniel Dunbar 524b4606f7 Forcibly disable test/PCH/pr4489.c, it is flaky on one of the buildbots.
llvm-svn: 100864
2010-04-09 15:30:57 +00:00
John McCall 81a4a72e84 Add a note to the C++ compatibility page about templates with no
valid instantiations.

llvm-svn: 100836
2010-04-09 01:07:07 +00:00
Douglas Gregor c68e140657 Improve diagnostics when we fail to convert from a source type to a
destination type for initialization, assignment, parameter-passing,
etc. The main issue fixed here is that we used rather confusing
wording for diagnostics such as

t.c:2:9: warning: initializing 'char const [2]' discards qualifiers,
      expected 'char *' [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

We're not initializing a 'char const [2]', we're initializing a 'char
*' with an expression of type 'char const [2]'. Similar problems
existed for other diagnostics in this area, so I've normalized them all
with more precise descriptive text to say what we're
initializing/converting/assigning/etc. from and to. The warning for
the code above is now:

t.c:2:9: warning: initializing 'char *' from an expression of type
      'char const [2]' discards qualifiers [-pedantic]
  char *name = __func__;
        ^      ~~~~~~~~

Fixes <rdar://problem/7447179>.

llvm-svn: 100832
2010-04-09 00:35:39 +00:00
Ted Kremenek e1a38ab422 Use '%clang_cc1' instead of '%clang' to make the warning output more consistent across
platforms (for this test).

llvm-svn: 100827
2010-04-08 23:17:16 +00:00
Ted Kremenek 212182d12b For 'open' check in UnixAPIChecker, hard code value of 'O_CREAT' on Darwin.
This is still not an ideal solution, but should disable the check for other
targets where the value of O_CREAT is different.

llvm-svn: 100818
2010-04-08 22:15:34 +00:00
Douglas Gregor 5e349b5469 Reorder diagnostics to separate the Sema::AssignmentAction diagnostics from other diagnostics
llvm-svn: 100817
2010-04-08 22:07:57 +00:00
Ted Kremenek 769b06cba3 Temporarily only enable 'open' check on Mac OS X to unbreak Windows buildbot. I'm
looking into an alternate fix right now.

llvm-svn: 100816
2010-04-08 21:54:13 +00:00
Douglas Gregor f19ac0ede9 Downgrade the "declaration does not declare anything" error to a
warning. It's not harmful to have such pointless declarations, and GCC
does not diagnose this issue consistently.

llvm-svn: 100814
2010-04-08 21:33:23 +00:00
Fariborz Jahanian d9235dbc02 Implement method type encoding in the presense
of c-style arguments. Completes radar 7445205.

llvm-svn: 100813
2010-04-08 21:29:11 +00:00
Ted Kremenek 5c7f596b4c Match GCC's behavior and do not include '-Wunused-parameter' in '-Wunused'.
llvm-svn: 100810
2010-04-08 21:10:56 +00:00
Jeffrey Yasskin 54eba427ed Explain that a template needs arguments to make it into a type, for
variable declarations.

llvm-svn: 100809
2010-04-08 21:04:54 +00:00
John McCall 17762b8a5d Set access properly on instantiated friend class template declarations.
Fixes PR6752.

llvm-svn: 100806
2010-04-08 20:25:50 +00:00
Ted Kremenek ea4a5abf61 Add static analyzer check for calls to 'pthread_once()' where the control-flow has
automatic storage.  This matches the corresponding check for 'dispatch_once()'.

llvm-svn: 100803
2010-04-08 19:53:31 +00:00
Ted Kremenek a0859f1e7d Update test case.
llvm-svn: 100801
2010-04-08 18:51:47 +00:00
Ted Kremenek afed24b472 Remove micro-optimization for not issueing CFG-based warnings for 'static inline' functions
unless they are used.  I discussed this with Daniel Dunbar, and we agreed that this
provides an inconsistent warnings experience for the user and that there were
genuine cases where we wouldn't want to do this optimization.

llvm-svn: 100800
2010-04-08 18:51:44 +00:00
Douglas Gregor 01e09d9d91 Introduce an egregious hack to work around a bug in libstdc++ 4.2.x's
<tr1/hashtable> header, where a friend class template
std::tr1::__detail::_Map_base is declared with the wrong template
parameters. GCC doesn't catch the problem, so Clang does a little
back-flip to avoid diagnosing just this one instance of the problem.

llvm-svn: 100790
2010-04-08 18:16:15 +00:00
Fariborz Jahanian 590c3524ac Fix a misuse of iterators when iterating through block's
parameters list for encoding.

llvm-svn: 100788
2010-04-08 18:06:22 +00:00
Ted Kremenek a1de6fc575 Include all warnings under '-Wunused' in '-Wmost' and '-Wall'.
llvm-svn: 100786
2010-04-08 17:54:28 +00:00
Ted Kremenek 9f6bcf7b45 Sort entries in diagnostic group "Most".
llvm-svn: 100785
2010-04-08 17:54:24 +00:00
John McCall cf75c1e4ed Maybe we should store template arguments in the position we allocated for them
instead of scribbling over random memory.  Maybe.

Hopefully this fixes the -vg buildbot.

llvm-svn: 100784
2010-04-08 17:47:15 +00:00
Jeffrey Yasskin c76498d409 Make CXXScopeSpec invalid when incomplete, and propagate that into any
Declarator that depends on it.  This fixes several redundant errors and bad
recoveries.

llvm-svn: 100779
2010-04-08 16:38:48 +00:00
Anders Carlsson af2a317e05 Rename CGVtable files to CGVTables.
llvm-svn: 100778
2010-04-08 16:30:25 +00:00
Anders Carlsson ae9e9a63bd Clarify an assert.
llvm-svn: 100776
2010-04-08 16:18:36 +00:00
Douglas Gregor bc6a434773 Unbreak the build
llvm-svn: 100775
2010-04-08 16:07:47 +00:00
Benjamin Kramer 31160e8469 CIndex: move extractUSRSuffix out of extern "C" and simplify it.
llvm-svn: 100773
2010-04-08 15:54:07 +00:00
Douglas Gregor eadd3cace9 Eliminate excessive PCH deserialization caused by the search for
__cxxabiv1::__fundamental_type_info in every translation
unit. Previously, we would perform name lookup for
__cxxabiv1::__fundamental_type_info at the end of IRGen for a each
translation unit, to determine whether it was present. If so, we we
produce type information for all of the fundamental types. However,
this name lookup causes PCH deserialization of a significant part of the
translation unit, which has a woeful impact on performance.

With this change, we now look at each record type after we've
generated its vtable to see if it is
__cxxabiv1::__fundamental_type_info. If so, we generate type info for
all of the fundamental types. This works because
__cxxabiv1::__fundamental_type_info should always have a key function
(typically the virtual destructor), that will be defined once in the
support library. The fundamental type information will end up there.

Fixes <rdar://problem/7840011>.

llvm-svn: 100772
2010-04-08 15:52:03 +00:00
Benjamin Kramer f41ccef5eb Remove caseless switch.
llvm-svn: 100770
2010-04-08 15:44:22 +00:00
John McCall b9c7848ba7 Implement dependent friend function template specializations.
llvm-svn: 100753
2010-04-08 09:05:18 +00:00
Ted Kremenek fc58c37b8c Removed unused object.
llvm-svn: 100750
2010-04-08 07:30:50 +00:00
Daniel Dunbar 8ee6760971 Fronted: Kill overly specialized RecordLayoutDumper, just make -dump-record-layouts a bit that Sema honors.
llvm-svn: 100747
2010-04-08 02:59:56 +00:00
Daniel Dunbar aa423afffc AST: Move C++ record layout dumping to ASTContext::DumpRecordLayout.
llvm-svn: 100746
2010-04-08 02:59:49 +00:00
Daniel Dunbar c75c8bd757 IRgen: Move the bit-field access type into CGBitFieldInfo, and change bit-field LValues to just store the base address of object containing the bit-field.
llvm-svn: 100745
2010-04-08 02:59:45 +00:00
Fariborz Jahanian 60462098d4 Patch to implement gcc's cstyle arguments in objc
methods. wip.

llvm-svn: 100734
2010-04-08 00:30:06 +00:00
Chris Lattner 79f67a7495 refactor out a function.
llvm-svn: 100733
2010-04-08 00:23:06 +00:00
John McCall 3a65ef4504 Fix a (bogus) uninitialized-member-of-local warning.
llvm-svn: 100732
2010-04-08 00:13:37 +00:00
Ted Kremenek 465dffa736 Use SmallVector instead of an std::queue.
llvm-svn: 100730
2010-04-08 00:05:00 +00:00
Jeffrey Yasskin 823015d627 When a template (without arguments) is passed as a template type
parameter, explicitly ask the user to give it arguments.  We used to
complain that it wasn't a type and expect the user to figure it out.

llvm-svn: 100729
2010-04-08 00:03:06 +00:00
Jeffrey Yasskin 4e150f8d35 Fix some redundant errors by changing CXXScopeSpec::isSet calls into
isNotEmpty calls.

llvm-svn: 100722
2010-04-07 23:29:58 +00:00
Chris Lattner 1f054ecca2 update for api change.
llvm-svn: 100718
2010-04-07 23:12:35 +00:00
Alexis Hunt 7dd2617e9c Implement checking for template literal operator functions. This
code won't actually get used yet because we don't handle non-type
parameter packs, but when we do, this code should jump in and work.

llvm-svn: 100716
2010-04-07 23:11:06 +00:00
Eric Christopher 75553d9de5 Add support for stpncpy_chk.
llvm-svn: 100711
2010-04-07 23:00:44 +00:00
Chris Lattner 4b73cfabac rename llvm::llvm_report_error -> llvm::report_fatal_error
llvm-svn: 100708
2010-04-07 22:58:06 +00:00
Alexis Hunt 079a6f7fe5 Updated comment to reflect changes made in the most recent draft.
llvm-svn: 100707
2010-04-07 22:57:35 +00:00
Alexis Hunt a0c80c55c3 Fixed 80-cols violation
llvm-svn: 100704
2010-04-07 22:52:07 +00:00
Chris Lattner b35583df52 add a new driver-level -ferror-limit=412 option, which causes clang to stop
emitting diagnostics after it has produced that many errors.  Give this a
default value of 20 which produces plenty of errors for people to fix before
recompiling but not so many that their entire console scrolls away when the
compiler gets confused.  The experience looks like this:

$ clang foo.c
<tons of crap>
foo.c:102:3: error: unknown type name 'somethingbad'
  somethingbad x;
  ^
fatal error: too many errors emitted, stopping now
36 warnings and 20 errors generated.

llvm-svn: 100689
2010-04-07 20:49:23 +00:00
Chris Lattner dec49e77e5 add clang -cc1 level support for "-ferror-limit 42"
llvm-svn: 100687
2010-04-07 20:37:06 +00:00
Douglas Gregor fd27fed584 Return early from Sema::MarkDeclarationReferenced when we know there
isn't any extra work to perform. Also, don't check for unused
parameters when the warnings will be suppressed anyway. Improves
performance of -fsyntax-only on 403.gcc's combine.c by ~2.5%. 
<rdar://problem/7836787>

llvm-svn: 100686
2010-04-07 20:29:57 +00:00
Chris Lattner 75a0393eb5 add capabilities to stop emitting errors after some limit.
Right now the limit is 0 (aka disabled)

llvm-svn: 100684
2010-04-07 20:21:58 +00:00
Ted Kremenek 43a9c9626f Don't emit an 'unused expression' warning for '||' and '&&' expressions that contain assignments
or similar side-effects.

llvm-svn: 100676
2010-04-07 18:49:21 +00:00
Chris Lattner 198cb4df6e Instead of counting totally diagnostics, split the count into a count
of errors and warnings.  This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.

llvm-svn: 100675
2010-04-07 18:47:42 +00:00
Chris Lattner a503f7c9d2 convert to -verify mode.
llvm-svn: 100674
2010-04-07 18:43:41 +00:00
Douglas Gregor 3b4abb6792 Improve handling of friend types in several ways:
- When instantiating a friend type template, perform semantic
  analysis on the resulting type.
  - Downgrade the errors concerning friend type declarations that do
  not refer to classes to ExtWarns in C++98/03. C++0x allows
  practically any type to be befriended, and ignores the friend
  declaration if the type is not a class.

llvm-svn: 100635
2010-04-07 17:57:12 +00:00
Douglas Gregor afb9bc10fa Split Sema::ActOnFriendTypeDecl into Sema::CheckFriendTypeDecl (for
semantic analysis) and Sema::ActOnFriendTypeDecl (the action
callback). This is a prerequisite for improving template instantiation
of friend type declarations.

llvm-svn: 100633
2010-04-07 16:53:43 +00:00
John McCall 8586bfd85d @llvm.sqrt isn't really close enough to C's sqrt to justify emitting calls
to the intrinsic, even when math-errno is off.

Fixes rdar://problem/7828230 by falling back on the library function.

llvm-svn: 100613
2010-04-07 08:20:20 +00:00
Chris Lattner fdb76ccfb4 a ridiculous amount of propagation through the backend later,
have the code generate slap a srcloc metadata on inline asm nodes.
This allows us to diagnose invalid inline asms with such nice 
diagnostics as:

<inline asm>:1:2: error: unrecognized instruction
        abc incl    %eax
        ^
asm.c:2:12: note: generated from here
  __asm__ ("abc incl    %0" : "+r" (X));
           ^
2 diagnostics generated.

llvm-svn: 100608
2010-04-07 05:46:54 +00:00
Zhongxing Xu 7614b5b475 Fix comment.
llvm-svn: 100604
2010-04-07 04:40:26 +00:00
Ted Kremenek 232d44ed48 Update checker build.
llvm-svn: 100603
2010-04-07 04:09:49 +00:00
Jeffrey Yasskin 3b54129419 Deprecate CXXScopeSpec::isSet() in favor of isNotEmpty() or isValid().
llvm-svn: 100600
2010-04-07 01:55:59 +00:00
John McCall 1bff99322a Teach -Wsign-compare to treat 1 << blah as "idiomatically non-negative".
Fixes a spurious warning in LLVM.

llvm-svn: 100595
2010-04-07 01:14:35 +00:00
Ted Kremenek 6e95bfc6a5 Fix crash in StoreManager::CastRegion() when the base region is a type with 0 size.
llvm-svn: 100594
2010-04-07 00:46:49 +00:00
John McCall 8e36d53e34 Check access for the implicit calls to destructors that occur when we
have a temporary object in C++.

Also fix a tag mismatch that Doug noticed.

llvm-svn: 100593
2010-04-07 00:41:46 +00:00
Ted Kremenek 6ca136a77f Fix CIndex crash on invalid code reported in <rdar://problem/7833619>.
llvm-svn: 100589
2010-04-07 00:27:13 +00:00
Fariborz Jahanian ea7a133775 Improve on diagnostics when an objc class is used as
a stand-alone type declaration.

llvm-svn: 100588
2010-04-07 00:22:00 +00:00
Douglas Gregor 636a61e0d2 Implement code completion for Objective-C method declarations and
definitions, e.g., after 

  -

or

  - (id)

we'll find all of the "likely" instance methods that one would want to
declare or define at this point. In the latter case, we only produce
results whose return types match "id".

llvm-svn: 100587
2010-04-07 00:21:17 +00:00
Fariborz Jahanian 8409416db7 Minor clean up.
llvm-svn: 100583
2010-04-06 23:43:59 +00:00
Fariborz Jahanian b2c1aac544 default access for synthesize ivar is @protect.
Fixes radar 7823675.

llvm-svn: 100582
2010-04-06 23:36:17 +00:00
Fariborz Jahanian 6a0a2e0ccc Patch to not build ivar ASTs when they are ilegally
declared in categories.

llvm-svn: 100577
2010-04-06 22:43:48 +00:00
John McCall 2351cb9139 Devote a special diagnostic to the typo
(void*) someFunction(5, 10, 15, 20);
where the cast is presumably meant to be to 'void'.

llvm-svn: 100574
2010-04-06 22:24:14 +00:00
Ted Kremenek f969841a1a Teach MemRegion::getBaseRegion() about ObjCIvarRegions. We want to treat
them the same way as fields.  This fixes a regression in RegionStore::RemoveDeadbindings()
that emerged from going to the cluster-based analysis.

llvm-svn: 100570
2010-04-06 22:06:03 +00:00
John McCall a8ae222d0e Implement the protected access restriction ([class.protected]), which requires
that protected members be used on objects of types which derive from the
naming class of the lookup.  My first N attempts at this were poorly-founded,
largely because the standard is very badly worded here.

llvm-svn: 100562
2010-04-06 21:38:20 +00:00
Douglas Gregor c01890e1cc When code completion produces an overload set as its results (e.g.,
while we're completing in the middle of a function call), also produce
"ordinary" name results that show what can be typed at that point.

llvm-svn: 100558
2010-04-06 20:19:47 +00:00
Douglas Gregor 2cb6c30673 Do not produce semicolons at the end of code-completion results
llvm-svn: 100557
2010-04-06 20:11:37 +00:00
Douglas Gregor 285560929f Only prove macros as code-completion results when we're in a case
statement or for ordinary names. This means that we won't show macros
when completing, e.g., member expressions such as "p->".

llvm-svn: 100555
2010-04-06 20:02:15 +00:00
Ted Kremenek 7deb7050d5 Fix ccc-analyzer's handling of quoted arguments in the build command. Fixes PR 6791.[B
llvm-svn: 100551
2010-04-06 19:41:24 +00:00
Douglas Gregor 9d2ddb2e5d When sending a message to "id", apply some heuristics to try to narrow
down the set of code-completion results based on Objective-C
conventions. 

llvm-svn: 100548
2010-04-06 19:22:33 +00:00
Chris Lattner e6485c5873 add a testcase that the integrated assembler rejects, this verifies
that the integrated assembler is working.

llvm-svn: 100545
2010-04-06 18:46:25 +00:00
Chris Lattner 5ec32e7fd8 teach clang to install the inline asm diagnostic handler,
allowing backend errors to be mapped through clang's 
diagnostics subsystem, including the backend location info.

We now get:

$ clang asm.c -c -o t.o -integrated-as
<inline asm>:1:2: error: unrecognized instruction
        abc incl    %eax
        ^
1 diagnostic generated.

With colors, and correct "# diagnostics generated".

llvm-svn: 100543
2010-04-06 18:38:50 +00:00
Chris Lattner 6d67213ebb reduce indentation, tidy.
llvm-svn: 100537
2010-04-06 17:52:14 +00:00
Blaine Garst 55050630a9 improved wording around ABI
llvm-svn: 100536
2010-04-06 17:46:43 +00:00
Douglas Gregor d720daf8bc Make code-completion for Objective-C message sends to "id" work in the
presence of precompiled headers by forcibly loading all of the
methods we know about from the PCH file before constructing our
code-completion list.

llvm-svn: 100535
2010-04-06 17:30:22 +00:00
Chris Lattner c0e8a59ac9 fit in 80 cols
llvm-svn: 100534
2010-04-06 17:29:22 +00:00
Fariborz Jahanian 440a6832c5 Put type restriction on convesion to nonconforming 'id' back in
block pointer type comparison.

llvm-svn: 100533
2010-04-06 17:23:39 +00:00
Daniel Dunbar 3d45e17d15 Driver: Add a Tool::hasGoodDiagnostics hook, and use it to simplify logic for
deciding when we need to emit an extra "command failed" diagnostic.
 - This also fixes the case where we were emitting that extra diagnostics, even
   when using clang w/ the integrated assembler, which has good diagnostics.

llvm-svn: 100529
2010-04-06 17:07:49 +00:00
Douglas Gregor 6285f754fa Implement support for code completion of an Objective-C message send to
"id" or an expression of type "id". In these cases, we produce a list
of all of the (class or instance) methods, respectively, that we know about.

Note that this implementation does not yet work well with precompiled
headers; that's coming soon.

llvm-svn: 100528
2010-04-06 16:40:00 +00:00
Douglas Gregor e7938a04c8 Add test for code completion of Objective-C message sends to classes.
llvm-svn: 100527
2010-04-06 15:27:03 +00:00
Douglas Gregor be9ea80abf Perform code-completion within ParseCastExpression, which handles,
e.g., the right-hand side of binary expressions.

llvm-svn: 100526
2010-04-06 15:09:27 +00:00
Douglas Gregor 6314641822 clang-wpa fixes for Diagnostic
llvm-svn: 100518
2010-04-06 04:03:12 +00:00
Zhongxing Xu 0f290ec0f0 Fix PR 6725. It looks like the copy constructor gets elided during inlining.
This bug only shows up with GCC 4.4.1 Release-Asserts build.

llvm-svn: 100516
2010-04-06 03:01:56 +00:00
Douglas Gregor ff8f4f6262 Unbreak build
llvm-svn: 100514
2010-04-06 01:25:58 +00:00
Daniel Dunbar 196ea449ed IRgen: Move BitFieldIsSigned bit into CGBitFieldInfo.
llvm-svn: 100513
2010-04-06 01:07:44 +00:00
Daniel Dunbar d45491077a Simplify.
llvm-svn: 100512
2010-04-06 01:07:41 +00:00
Daniel Dunbar 60d81e8611 Simplify.
llvm-svn: 100511
2010-04-06 01:07:39 +00:00