Commit Graph

26814 Commits

Author SHA1 Message Date
Anna Zaks 4818bbe348 [analyzer] Do not propagate the [super init] could be nil assumption
from callee to caller.

radar://12109638

llvm-svn: 162935
2012-08-30 19:40:52 +00:00
Ted Kremenek 401ce8edba Teach RetainCountChecker about 'pragma clang arc_cf_code_audited'.
llvm-svn: 162934
2012-08-30 19:27:02 +00:00
Ted Kremenek efca7a7e1b Rename 'MaxLoop' to 'maxBlockVisitOnPath' to reflect reality. We
should consider renaming the command line option as well.

llvm-svn: 162932
2012-08-30 19:26:56 +00:00
Ted Kremenek b8f8b357e9 Rename 'VisualizeEGUbi' and 'VisualizeEGDot' to 'visualizeExplodedGraphWithUbigGraph'
and 'visualizeExplodedGraphWithGraphViz' respectively.

llvm-svn: 162931
2012-08-30 19:26:53 +00:00
Ted Kremenek 6f5131f149 Rename AnalyzerOptions 'EagerlyAssume' to 'eagerlyAssumeBinOpBifurcation'.
llvm-svn: 162930
2012-08-30 19:26:48 +00:00
Ted Kremenek 8756c4a1a9 Store const& to AnalyzerOptions in AnalysisManager instead of copying
individual flags.

llvm-svn: 162929
2012-08-30 19:26:43 +00:00
Ted Kremenek 45c5c0aa06 Move AnalyzerOptions.h to include/clang/StaticAnalyzer.
llvm-svn: 162928
2012-08-30 19:26:38 +00:00
Ted Kremenek 3cc42279c4 Move Analyses.def to include/clang/StaticAnalyzer.
llvm-svn: 162927
2012-08-30 19:26:33 +00:00
Fariborz Jahanian f257857443 objective-C: clang must implicitly convert
__objc_yes/__objc_no to (BOOL)1/(BOOL)0 when
BOOL is declared; otherwise it resorts to
default of 'signed char'. This is important to
selecting the correct Numeric API numberWithBool:
Can't have a clang test for this. Will checkin and
executable llvm test. // rdar://12156616

llvm-svn: 162922
2012-08-30 18:49:41 +00:00
Richard Smith 5edd5830e1 Make preprocessor act in a GCC-compatible fashion when a macro is redefined
within its own argument list. The original definition is used for the immediate
expansion, but the new definition is used for any subsequent occurences within
the argument list or after the expansion.

llvm-svn: 162906
2012-08-30 13:38:46 +00:00
Richard Smith b3afa6c483 PR13652: Don't assume the parameter array on a FunctionTypeLoc for a lambda will
be filled in; they won't if the lambda's declarator has an invalid type. Instead
take the parameters from the declarator directly.

llvm-svn: 162904
2012-08-30 13:13:20 +00:00
Ted Kremenek 53f3e7dba3 Change -analyzer-config to use '=' as the key-value separator, and only
support the '-analyzer-config key=val' variant.

llvm-svn: 162891
2012-08-30 05:49:16 +00:00
Nico Weber 723b4f02a7 Reland r160052: Default to -std=c++11 on Windows.
Also update the tests that rely on c++98 to explicitly mention that.

llvm-svn: 162890
2012-08-30 02:08:31 +00:00
Nico Weber 077a53e5ab Tooling: Add a runToolOnCodeWithArgs() function that allows
passing additional parameters to a tool.

Use this to fix a FIXME in testing code.

llvm-svn: 162889
2012-08-30 02:02:19 +00:00
Eli Friedman 448ce40426 Fix a crash in type merging with enum types.
llvm-svn: 162886
2012-08-30 00:44:15 +00:00
Bill Wendling 8c0b4bc339 Emit .gcda files as absolute paths instead of relative paths.
This improves compatibility with gcc in this regard, and this file generation
can be ameliorated with GCOV_PREFIX and GCOV_PREFIX_STRIP. It's also useful if
your build directory doesn't specify -o <abspath> and it uses a recursive make
structure, so it's not relative to the toplevel.

Patch by Joshua Cranmer!
<rdar://problem/12179524>

llvm-svn: 162884
2012-08-30 00:43:41 +00:00
Anna Zaks 256127388a [analyzer] Stop tracking symbols based on a retain count summary of
inlined function.

This resolves retain count checker false positives that are caused by
inlining ObjC and other methods. Essentially, if we are passing an
object to a method with "delegate" in the selector or a function pointer
as another argument, we should stop tracking the other parameters/return
value as far as the retain count checker is concerned.

llvm-svn: 162876
2012-08-29 23:23:43 +00:00
Anna Zaks 07a821fb17 [analyzer] Fixup 162863.
Thanks Jordan.

llvm-svn: 162875
2012-08-29 23:23:39 +00:00
Ted Kremenek 7712eef0d7 Fix serious regression introduced in r157780 where __attribute__((NSObject))
could not be attached to a CFTypeRef.

Fixes <rdar://problem/12197822>

llvm-svn: 162872
2012-08-29 22:54:47 +00:00
Anna Zaks 5d4ec36323 [analyzer] Improved diagnostic pruning for calls initializing values.
This heuristic addresses the case when a pointer (or ref) is passed
to a function, which initializes the variable (or sets it to something
other than '0'). On the branch where the inlined function does not
set the value, we report use of undefined value (or NULL pointer
dereference). The access happens in the caller and the path
through the callee would get pruned away with regular path pruning. To
solve this issue, we previously disabled diagnostic pruning completely
on undefined and null pointer dereference checks, which entailed very
verbose diagnostics in most cases. Furthermore, not all of the
undef value checks had the diagnostic pruning disabled.

This patch implements the following heuristic: if we pass a pointer (or
ref) to the region (on which the error is reported) into a function and
it's value is either undef or 'NULL' (and is a pointer), do not prune
the function.

llvm-svn: 162863
2012-08-29 21:22:37 +00:00
Eli Friedman 504f9a2872 Make alignment computation for pointer values for builtins handle
non-pointer types with a pointer representation correctly. PR13660.

llvm-svn: 162862
2012-08-29 21:21:11 +00:00
Simon Atanasyan c6a0be00ab Define __mips64 / __mips64__ macros for MIPS 64-bit targets.
The patch suggested by Brad Smith.

llvm-svn: 162858
2012-08-29 20:50:11 +00:00
Simon Atanasyan 16ee0057ab Use getTargetDefines() virtual function in MipsTargetInfoBase successors
to define all macros for MIPS targets. Remove redundant virtual function
getArchDefines(). Two virtual functions for this task are really too much.

llvm-svn: 162853
2012-08-29 19:59:32 +00:00
Simon Atanasyan 683535bbdd Factor out MIPS macro definitions common for all MIPS targets.
llvm-svn: 162852
2012-08-29 19:14:58 +00:00
Hans Wennborg cb9ad9908b Move TLS check from LValueExprEvaluator::VisitVarDecl to
CheckLValueConstantExpression.

Richard pointed out that using the address of a TLS variable is ok in a
core C++11 constant expression, as long as it isn't part of the eventual
result of constant expression evaluation. Having the check in
CheckLValueConstantExpression accomplishes this.

llvm-svn: 162850
2012-08-29 18:27:29 +00:00
Fariborz Jahanian f07bcc527a objective-C: make -Widiomatic-parentheses work
when assignment expression in conditional invloves
property reference. // rdar://11066598

llvm-svn: 162846
2012-08-29 17:17:11 +00:00
Alexander Kornienko c0b4928df8 Fixed a problem with #pragma push_macro/pop_macro implementation.
Summary:
The problem was with the following sequence:
  #pragma push_macro("long")
  #undef long
  #pragma pop_macro("long")
in case when "long" didn't represent a macro.
Fixed crash and removed code duplication for #undef/pop_macro case. Added regression tests.

Reviewers: doug.gregor, klimek

Reviewed By: doug.gregor

CC: cfe-commits, chapuni

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

llvm-svn: 162845
2012-08-29 16:56:24 +00:00
Simon Atanasyan 5a0642fdc1 Define _MIPS_ARCH and _MIPS_ARCH_<cpu name> macros for MIPS targets.
The patch suggested by Logan Chien.

llvm-svn: 162840
2012-08-29 15:17:29 +00:00
Aaron Ballman d5a176dbad Reversing the logic since C99 mode is actually not an extension. Also, changing the group to the singular to match the diagnostic better.
llvm-svn: 162838
2012-08-29 12:35:14 +00:00
Hans Wennborg 2efa2c33ec Fix r162835 as per Richard's comments.
VisitVarDecl should return Error(E), and we should test that the address
of a TLS var can't be used as a constexpr.

llvm-svn: 162837
2012-08-29 09:17:34 +00:00
Hans Wennborg 299f50b4e8 The address of a TLS var is not compile-time constant (PR13720)
This makes Clang produce an error for code such as:

  __thread int x;
  int *p = &x;

The lvalue of a thread-local variable cannot be evaluated at compile
time.

llvm-svn: 162835
2012-08-29 08:44:49 +00:00
Ted Kremenek fb5351eed3 Add new -cc1 driver option -analyzer-config, which allows one to specify
a comma separated collection of key:value pairs (which are strings).  This
allows a general way to provide analyzer configuration data from the command line.

No clients yet.

llvm-svn: 162827
2012-08-29 05:55:00 +00:00
Jordan Rose 2c625dd6f9 [analyzer] C++ objects returned on the stack may be wrapped in ExprWithCleanups.
In C++, objects being returned on the stack are actually copy-constructed into
the return value. That means that when a temporary is returned, it still has
to be destroyed, i.e. the returned expression will be wrapped in an
ExprWithCleanups node. Our "returning stack memory" checker needs to look
through this node to see if we really are returning an object by value.

PR13722

llvm-svn: 162817
2012-08-29 01:11:59 +00:00
Alexander Kornienko 8b3f623582 Keep history of macro definitions and #undefs
Summary:
Summary: Keep history of macro definitions and #undefs with corresponding source locations, so that we can later find out all macros active in a specified source location. We don't save the history in PCH (no need currently). Memory overhead is about sizeof(void*)*3*<number of macro definitions and #undefs>+<in-memory size of all #undef'd macros>

I've run a test on a file composed of 109 .h files from boost 1.49 on x86-64 linux.
Stats before this patch:
*** Preprocessor Stats:
73222 directives found:
  19171 #define.
  4345 #undef.
  #include/#include_next/#import:
    5233 source files entered.
    27 max include stack depth
  19210 #if/#ifndef/#ifdef.
  2384 #else/#elif.
  6891 #endif.
  408 #pragma.
14466 #if/#ifndef#ifdef regions skipped
80023/451669/1270 obj/fn/builtin macros expanded, 85724 on the fast path.
127145 token paste (##) operations performed, 11008 on the fast path.

Preprocessor Memory: 5874615B total
  BumpPtr: 4399104
  Macro Expanded Tokens: 417768
  Predefines Buffer: 8135
  Macros: 1048576
  #pragma push_macro Info: 0
  Poison Reasons: 1024
  Comment Handlers: 8

Stats with this patch:
...
Preprocessor Memory: 7541687B total
  BumpPtr: 6066176
  Macro Expanded Tokens: 417768
  Predefines Buffer: 8135
  Macros: 1048576
  #pragma push_macro Info: 0
  Poison Reasons: 1024
  Comment Handlers: 8

In my test increase in memory usage is about 1.7Mb, which is ~28% of initial preprocessor's memory usage and about 0.8% of clang's total VMM allocation.

As for CPU overhead, it should only be noticeable when iterating over all macros, and should mostly consist of couple extra dereferences and one comparison per macro + skipping of #undef'd macros. It's less trivial to measure, though, as the preprocessor consumes a very small fraction of compilation time.


Reviewers: doug.gregor, klimek, rsmith, djasper

Reviewed By: doug.gregor

CC: cfe-commits, chandlerc

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

llvm-svn: 162810
2012-08-29 00:20:03 +00:00
Manuel Klimek 021d56f948 Modifes BoundNodes to store void* and allow casting them
into the correct types when pulling them out in the result
callback in a type safe way.

This is also the base change for multiple things that will
allow handling things more generally and thus supporting more
of the AST, especially handling Type nodes.

Patch contributed by Michael Diamond.

llvm-svn: 162804
2012-08-28 23:26:39 +00:00
Fariborz Jahanian 272b7dc8ae objective-C arc: ns_returns_retained is a type attribute in ARC,
and when used in property type declaration, is handled as type
attribute. Do not issue the warning when declaraing the property. 
// rdar://12173491

llvm-svn: 162801
2012-08-28 22:26:21 +00:00
Alexander Kornienko 9ed8c4e941 Only add common tool options when CommonOptionsParser is used.
Summary: Subj.

Reviewers: chandlerc, klimek, djasper

Reviewed By: klimek

CC: cfe-commits

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

llvm-svn: 162798
2012-08-28 22:15:41 +00:00
Chad Rosier 6f0a9a2e2f Revert r162424 now that the scoping issue has been fixed in r162444.
llvm-svn: 162797
2012-08-28 22:08:58 +00:00
Chad Rosier 649dfc317d [ms-inline asm] Have MSAsmStmts use the generic EmitAsmStmt codegen function.
llvm-svn: 162796
2012-08-28 21:11:24 +00:00
Aaron Ballman 3731b33009 Splitting the duplicated decl spec extension warning into two: one is an ExtWarn and the other a vanilla warning. This addresses PR13705, where const char const * wouldn't warn unless -pedantic was specified under the right conditions.
llvm-svn: 162793
2012-08-28 20:55:40 +00:00
Jordan Rose 8d48938bf3 [analyzer] Teach CallEventManager that CXXTemporaryObjectExpr is also a ctor.
Specifically, CallEventManager::getCaller was looking at the call site for
an inlined call and trying to see what kind of call it was, but it only
checked for CXXConstructExprClass. (It's not using an isa<> here to avoid
doing three more checks on the the statement class.)

This caused an unreachable when we actually did inline the constructor of a
temporary object.

PR13717

llvm-svn: 162792
2012-08-28 20:52:21 +00:00
Jordan Rose 2be6e30d96 [analyzer] When we look for the last stmt in a function, skip implicit dtors.
When exiting a function, the analyzer looks for the last statement in the
function to see if it's a return statement (and thus bind the return value).
However, the search for "the last statement" was accepting statements that
were in implicitly-generated inlined functions (i.e. destructors). So we'd
go and get the statement from the destructor, and then say "oh look, this
function had no explicit return...guess there's no return value". And /that/
led to the value being returned being declared dead, and all our leak
checkers complaining.

llvm-svn: 162791
2012-08-28 20:52:13 +00:00
Peter Collingbourne c6b0857e95 CUDA: give static storage class to __shared__ and __constant__
variables without a storage class within a function, to implement
CUDA B.2.5: "__shared__ and __constant__ variables have implied static
storage [duration]."

llvm-svn: 162788
2012-08-28 20:37:50 +00:00
Peter Collingbourne ee0502d551 CUDA: give correct address space to globals declared in functions
llvm-svn: 162787
2012-08-28 20:37:10 +00:00
Chad Rosier 7ae6360758 Tidy up.
llvm-svn: 162786
2012-08-28 20:35:06 +00:00
Chad Rosier 0bca469d11 [ms-inline asm] Have generateAsmString() return the AsmString computed by Sema.
We still need to translate the string, but this at least gets us one step
closer to using the more general EmitAsmStmt() codegen function. No functional
change intended.

llvm-svn: 162785
2012-08-28 20:33:49 +00:00
Chad Rosier 3dd7bf2c86 [ms-inline asm] Add constraints to MSAsmStmt. We don't currently compute
the constraints, so in the interim we speculatively assume a 'r' constraint.
This is expected to work for most cases on x86.

llvm-svn: 162784
2012-08-28 20:28:20 +00:00
Chad Rosier 6051bb94c0 [ms-inline asm] Rename EmitGCCAsmStmt to EmitAsmStmt and have it accept
AsmStmts.  This function is only used by GCCAsmStmts, however. Constraints need
to be properly computed before MSAsmStmts can use EmitAsmStmt.  No functional
change intended.

llvm-svn: 162776
2012-08-28 18:54:39 +00:00
Chad Rosier f70b7e284c [ms-inline asm] Use dyn_cast<> here to simplify logic.
llvm-svn: 162773
2012-08-28 18:21:14 +00:00
Jordan Rose 595c131460 [analyzer] Don't purge dead symbols at the end of calls if -analyzer-purge=none.
No test case since this is a debug option that we will never turn on by
default since it makes the leak checkers much less useful. (We'll only report
leaks at the end of analysis if -analyzer-purge=none.)

llvm-svn: 162772
2012-08-28 18:16:45 +00:00
Chad Rosier bbbe9ab876 [ms-inline asm] Make the AsmStmt class non-virtual.
llvm-svn: 162768
2012-08-28 17:43:23 +00:00
Michael Liao 48f498fccf Fix PR13704
- The increment needs to be signed value to preserve the original value when
  its data type is larger than 64-bit integer.

llvm-svn: 162766
2012-08-28 16:55:13 +00:00
Hans Wennborg f4ad232921 Warn about suspicious implicit conversions from floating point to bool
This warns in two specific situations:

1) For potentially swapped function arguments, e.g.

     void foo(bool, float);
     foo(1.7, false);

2) Misplaced brackets around function call arguments, e.g.

     bool InRange = fabs(a - b < delta);

   Where the last argument in a function call is implicitly converted
   from bool to float, and the function returns a float which gets
   implicitly converted to bool.

Patch by Andreas Eckleder!

llvm-svn: 162763
2012-08-28 15:44:30 +00:00
Roman Divacky afe2f23a3c Cleanup FreeBSD linking and add support for -pie.
Path by Brooks Davis, tests and fixes from me.

llvm-svn: 162761
2012-08-28 15:09:03 +00:00
Rafael Espindola 3dd531dbd4 Fix for assertion when solving unresolved templates.
Patch by Magee, Josh.

llvm-svn: 162737
2012-08-28 04:13:54 +00:00
Dmitri Gribenko 4364fcf026 Fix a -Wdocumentation warning.
llvm-svn: 162730
2012-08-28 02:49:14 +00:00
Dmitri Gribenko 557a8d568b Merging consecutive comments: be more conservative.
Should fix part 2 of PR13374.

llvm-svn: 162723
2012-08-28 01:20:53 +00:00
Jordan Rose a0f7d35afe [analyzer] Rename addTrackNullOrUndefValueVisitor to trackNullOrUndefValue.
This helper function (in the clang::ento::bugreporter namespace) may add more
than one visitor, but conceptually it's tracking a single use of a null or
undefined value and should do so as best it can.

Also, the BugReport parameter has been made a reference to underscore that
it is non-optional.

llvm-svn: 162720
2012-08-28 00:50:51 +00:00
Jordan Rose 72c5515bab [analyzer] Refactor FindLastStoreBRVisitor to not find the store ahead of time.
As Anna pointed out to me offline, it's a little silly to walk backwards through
the graph to find the store site when BugReporter will do the exact same walk
as part of path diagnostic generation.

llvm-svn: 162719
2012-08-28 00:50:45 +00:00
Jordan Rose 5090904d6c [analyzer] If the last store into a region came from a function, step into it.
Previously, if we were tracking stores to a variable 'x', and came across this:

x = foo();

...we would simply emit a note here and stop. Now, we'll step into 'foo' and
continue tracking the returned value from there.

<rdar://problem/12114689>

llvm-svn: 162718
2012-08-28 00:50:42 +00:00
Jordan Rose e537cc05f5 [analyzer] Rename CallEvent::mayBeInlined to CallEvent::isCallStmt.
The two callers are using this in order to be conservative, so let's just
clarify the information that's actually being provided here. This is not
related to inlining decisions in any way.

No functionality change.

llvm-svn: 162717
2012-08-28 00:50:38 +00:00
Chad Rosier a1b5c8c6a1 [ms-inline asm] Hoist more common code into the AsmStmt base class. Add stubs
with FIXMEs for unimplemented features.  No functional change intended.

llvm-svn: 162716
2012-08-28 00:24:05 +00:00
Chad Rosier 6100ae120c [ms-inline asm] Add virtual function, getClobber, that returns a StringRef.
More work towards unifying asm stmt codegen.

llvm-svn: 162712
2012-08-27 23:47:56 +00:00
Chad Rosier d9fb09a91b [ms-inline asm] Rename getClobber to getClobberStringLiteral. No functional
change intended.

llvm-svn: 162710
2012-08-27 23:28:41 +00:00
Benjamin Kramer 29f9a00732 CodeGen: Hoist check from recursive function to its only callsite.
Suggested by Roman Divacky.

llvm-svn: 162702
2012-08-27 22:07:02 +00:00
Benjamin Kramer 46cbe77b49 CodeGen: When emitting stores for an initializer, only emit a GEP if we really need the store.
This avoids emitting many dead GEPs for large zero-initialized arrays.

llvm-svn: 162701
2012-08-27 21:35:58 +00:00
Simon Atanasyan ec4b1c194b MIPS: Use -G option to specify MIPS section threshold. Translate it
to the -mllvm -mips-ssection-threshold=<value> pair and pass to the frontend.
The patch suggested by Carl Norum.

llvm-svn: 162697
2012-08-27 20:55:56 +00:00
Chad Rosier 3b0c2607ef [ms-inline asm] Rename GenerateAsmString to generateAsmString to conform with
coding standards.  Also, add stub for MSAsmStmt class as part of unifying 
codegen logic for AsmStmts.

llvm-svn: 162696
2012-08-27 20:23:31 +00:00
Jordan Rose 1a61674f5a [analyzer] Look through casts when trying to track a null pointer dereference.
Also, add comments to addTrackNullOrUndefValueVisitor.

Thanks for the review, Anna!

llvm-svn: 162695
2012-08-27 20:18:30 +00:00
Chad Rosier fe3352e0bc [ms-inline asm] Hoist common logic into the AsmStmt base class.
llvm-svn: 162692
2012-08-27 19:38:01 +00:00
Chad Rosier aeff2299c3 [ms-inline asm] Add a new base class, AsmStmt, for the GCCAsmStmt and MSAsmStmt
classes.

llvm-svn: 162691
2012-08-27 18:56:36 +00:00
Jordan Rose 561919e5bd [analyzer] Don't inline constructors for objects allocated with operator new.
Because the CXXNewExpr appears after the CXXConstructExpr in the CFG, we don't
actually have the correct region to construct into at the time we decide
whether or not to inline. The long-term fix (discussed in PR12014) might be to
introduce a new CFG node (CFGAllocator) that appears before the constructor.

Tracking the short-term fix in <rdar://problem/12180598>.

llvm-svn: 162689
2012-08-27 18:39:22 +00:00
Anna Zaks 7d2babc046 [analyzer] More internal stats collection.
llvm-svn: 162687
2012-08-27 18:38:32 +00:00
John McCall 64044c3a81 Use cast<> instead of static_cast. Patch by Timur Iskhodzhanov!
llvm-svn: 162683
2012-08-27 18:12:29 +00:00
Jordan Rose c93183042f [analyzer] Inline constructors for any object with a trivial destructor.
This allows us to better reason about status objects, like Clang's own
llvm::Optional (when its contents are trivially destructible), which are
often intended to be passed around by value.

We still don't inline constructors for temporaries in the general case.

<rdar://problem/11986434>

llvm-svn: 162681
2012-08-27 17:50:07 +00:00
Simon Atanasyan 8f06f2fbbf Support MIPS DSP Rev2 intrinsics.
The patch reviewed by Akira Hatanaka.

llvm-svn: 162669
2012-08-27 12:29:20 +00:00
John McCall 9320707aac Tweak the ARC-requires-10.6 diagnostic according to Jordan's review.
llvm-svn: 162651
2012-08-27 01:56:21 +00:00
Eli Friedman 48ddcf2cb5 Fix a CodeGen bug where we would skip zero-initialization for
array new with a non-trivial constructor. Pointed out in PR13380.

llvm-svn: 162643
2012-08-25 07:11:29 +00:00
Richard Smith a374bf0ae1 Remove spurious string literal for bool argument.
llvm-svn: 162642
2012-08-25 05:43:00 +00:00
Francois Pichet fb5d242d25 _HAS_CHAR16_T_LANGUAGE_SUPPORT is not predefined MSVC macro.
llvm-svn: 162641
2012-08-25 05:27:04 +00:00
John McCall a5f46fbcf9 Fix the CC-matching logic for instance methods in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162639
2012-08-25 02:00:03 +00:00
John McCall 3351dc397b Fix the mangling of function pointers in the MS ABI.
Patch by Timur Iskhodzhanov!

llvm-svn: 162638
2012-08-25 01:12:56 +00:00
Jordan Rose 0a0aa84da3 [analyzer] Use the common evalBind infrastructure for initializers.
This allows checkers (like the MallocChecker) to process the effects of the
bind. Previously, using a memory-allocating function (like strdup()) in an
initializer would result in a leak warning.

This does bend the expectations of checkBind a bit; since there is no
assignment expression, the statement being used is the initializer value.
In most cases this shouldn't matter because we'll use a PostInitializer
program point (rather than PostStmt) for any checker-generated nodes, though
we /will/ generate a PostStore node referencing the internal statement.
(In theory this could have funny effects if someone actually does an
assignment within an initializer; in practice, that seems like it would be
very rare.)

<rdar://problem/12171711>

llvm-svn: 162637
2012-08-25 01:06:23 +00:00
Richard Smith 3e056dea1b -fcatch-undefined-behavior: add the -ftrapv checks to the set of things caught
by this mode, and also check for signed left shift overflow. The rules for the
latter are a little subtle:

 * neither C89 nor C++98 specify the behavior of a signed left shift at all
 * in C99 and C11, shifting a 1 bit into the sign bit has undefined behavior
 * in C++11, with core issue 1457, shifting a 1 bit *out* of the sign bit has
   undefined behavior

As of this change, we use the C99 rules for all C language variants, and the
C++11 rules for all C++ language variants. Once we have individual
-fcatch-undefined-behavior= flags, this should be revisited.

llvm-svn: 162634
2012-08-25 00:32:28 +00:00
Chad Rosier de70e0ef45 [ms-inline asm] As part of a larger refactoring, rename AsmStmt to GCCAsmStmt.
No functional change intended.

llvm-svn: 162632
2012-08-25 00:11:56 +00:00
Richard Smith a6a03369da Remove RequireCompleteType call which was made redundant by r162586.
llvm-svn: 162630
2012-08-24 23:51:39 +00:00
Chad Rosier e30d4994f2 [ms-inline asm] Update the AST Reader/Writer for MS-style inline asms.
llvm-svn: 162629
2012-08-24 23:51:02 +00:00
Fariborz Jahanian 1cfbe7a240 objective-C: Do not warn if align attribute on method
declaration is not provided. It is only necessary on
the method implementation. // rdar://11593375

llvm-svn: 162628
2012-08-24 23:50:13 +00:00
Richard Smith 24adaee6bc Fix integer unsigned behavior in clang due to signed left shift overflow.
llvm-svn: 162626
2012-08-24 23:43:39 +00:00
John McCall e91aec7a57 When computing the effective context for access control,
make sure we walk up the DC chain for the current context,
rather than allowing ourselves to get switched over to the
canonical DC chain.  Fixes PR13642.

llvm-svn: 162616
2012-08-24 22:54:02 +00:00
Chad Rosier 175ea24e38 [ms-inline asm] Change the -fenable-experimental-ms-inline-asm option from a
CodeGen option to a LangOpt option.  In turn, hoist the guard into the parser 
so that we avoid the new (and fairly unstable) Sema/AST/CodeGen logic.  This
should restore the behavior of clang to that prior to r158325.
<rdar://problem/12163681>

llvm-svn: 162602
2012-08-24 21:42:51 +00:00
Benjamin Kramer c5d00f61b6 Remove unnecessary calls to c_str.
llvm-svn: 162590
2012-08-24 20:43:21 +00:00
John McCall 7d8b041999 Instantiate class template specializations during ADL.
llvm-svn: 162586
2012-08-24 20:38:34 +00:00
Fariborz Jahanian fd5cf6cf26 objective-C: When checking for valid overriden property
in class extension, assume default is rewdwrite and don't
issue any diagnostics, privided other ownership models
are ok.

llvm-svn: 162583
2012-08-24 20:10:53 +00:00
Ted Kremenek 7c65b8f22a Rename the "experimental" checker package to "alpha". We will then refine
this group into "alpha" and "beta" to distinguish between checkers in
different levels of premature state.

llvm-svn: 162582
2012-08-24 19:46:03 +00:00
Ted Kremenek 5bc38bad73 Rework how PathDiagnosticConsumers pass knowledge of what files they
generated for a given diagnostic to another.  Because PathDiagnostics
are specific to a give PathDiagnosticConsumer, store in
a FoldingSet a unique hash for a PathDiagnostic (that will be the same
for the same bug for different PathDiagnosticConsumers) that
stores a list of files generated.  This can then be read by the
other PathDiagnosticConsumers.

This fixes breakage in the PLIST-HTML output.

llvm-svn: 162580
2012-08-24 19:35:19 +00:00
Chad Rosier 0f8487c632 Fix 80-column violation.
llvm-svn: 162575
2012-08-24 18:31:16 +00:00
Dmitri Gribenko 219bd1554f Comment diagnostics: for unresolved parameters, do not suggest parameter fixit
with parameter that is documented.

Fixes PR13670, <rdar://problem/12155840>.

llvm-svn: 162570
2012-08-24 17:45:39 +00:00
Chad Rosier 14836bab36 [ms-inline asm] Refactor code. No functional change intended.
llvm-svn: 162568
2012-08-24 17:05:45 +00:00
Chad Rosier 1e17cf9c22 [ms-inline asm] Generate the Input/Output expressions using
Sema::ActOnIdExpression().

llvm-svn: 162564
2012-08-24 16:38:58 +00:00