Commit Graph

29425 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 8a27b2b350 In Sema::InstantiateStaticDataMemberDefinition, pass the var decl to the consumer
just using ASTConsumer::HandleCXXStaticMemberVarInstantiation(), don't pass it with
ASTConsumer::HandleTopLevelDecl.

ASTConsumer::HandleTopLevelDecl is intended for user-written top-level decls;
a consumer can treat an instantiated static data member however it wants of course.

llvm-svn: 175976
2013-02-24 00:05:01 +00:00
Daniel Jasper cd8599e8c9 Better formatting of conditional expressions.
In conditional expressions, if the condition is split over multiple
lines, also break before both operands.

This prevents formattings like:

  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c;

Which are bad, because they suggestion incorrect operator precedence:

  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ==
      (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? b : c);

This lead to the discovery that the expression parser incorrectly
handled conditional operators and that it could also handle semicolons
(which in turn reduced the amount of special casing for for-loops). As a
side-effect, we can now apply the bin-packing configuration to the
sections of for-loops.

llvm-svn: 175973
2013-02-23 21:01:55 +00:00
David Blaikie 1d969f42a0 Prefer 'and' over '&' in comments.
Post commit code review feedback from Matt Beaumont-Gay on r174248.

llvm-svn: 175969
2013-02-23 19:20:56 +00:00
Benjamin Kramer 24ebf7c92c Add streamed versions of getQualifiedNameAsString.
Move the cold virtual method getNameForDiagnostic out of line.

llvm-svn: 175966
2013-02-23 13:53:57 +00:00
Daniel Jasper ba0bda9739 Don't recognize unnamed pointer parameters as casts.
This fixes llvm.org/PR15061.

Before: virtual void f(int *)const;
After:  virtual void f(int *) const;
llvm-svn: 175960
2013-02-23 08:07:18 +00:00
Daniel Jasper af5ba0ed8c Allow splitting between string literals and identifiers.
Also don't break in long include directives as that is not desired.

We can now format:

  #include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
  #define LL_FORMAT "ll"
  printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT
         "d, ddddddddd: %" LL_FORMAT "d\n");

Before, this led to weird results.

llvm-svn: 175959
2013-02-23 07:46:38 +00:00
Logan Chien 5a5a96bfdc Implement __builtin_eh_return_data_regno() for ARM and MIPS.
llvm-svn: 175954
2013-02-23 04:24:36 +00:00
Richard Smith 539e4a77bb ubsan: Emit bounds checks for array indexing, vector indexing, and (in really simple cases) pointer arithmetic. This augments the existing bounds checking with language-level array bounds information.
llvm-svn: 175949
2013-02-23 02:53:19 +00:00
David Blaikie 00be69ab5c Remove the CFGElement "Invalid" state.
Use Optional<CFG*> where invalid states were needed previously. In the one case
where that's not possible (beginAutomaticObjDtorsInsert) just use a dummy
CFGAutomaticObjDtor.

Thanks for the help from Jordan Rose & discussion/feedback from Ted Kremenek
and Doug Gregor.

Post commit code review feedback on r175796 by Ted Kremenek.

llvm-svn: 175938
2013-02-23 00:29:34 +00:00
Rafael Espindola 16c8cf0e11 Remove the hack that avoided mangling static functions in extern C contexts.
Weather we should give C language linkage to functions and variables with
internal linkage probably depends on how much code assumes it. The standard
says they should have no language linkage, but gcc and msvc assign them
C language linkage.

This commit removes the hack that was preventing the mangling on static
functions declare in extern C contexts. It is an experiment to see if we
can implement the rules in the standard.

If it turns out that many users depend on these functions and variables
having C language linkage, we should change isExternC instead and try
to convince the CWG to change the standard.

llvm-svn: 175937
2013-02-23 00:26:28 +00:00
Peter Collingbourne 47f9f2d1e6 Revert r175912, "Add support for coldcc to clang" at John's request.
llvm-svn: 175936
2013-02-23 00:06:18 +00:00
Eric Christopher f1545838d7 Propagate the split dwarf file information through into the backend
and through to the debug info in the module. In order to make the
testcase a bit more efficient allow the filename to go through
compilation for compile and not assemble jobs and turn off the
extract for cases where we don't create an object.

llvm-svn: 175935
2013-02-22 23:50:16 +00:00
Argyrios Kyrtzidis fb70380f2f [libclang] Fix assertion hit when code-completing inside a function macro with more
arguments than it should accept.

llvm-svn: 175925
2013-02-22 22:28:58 +00:00
Fariborz Jahanian f073871f7f objective-C arg: provide fixit support when
c++'s named cast need be replaced for bridge casting.
// rdar://12788838

llvm-svn: 175923
2013-02-22 22:02:53 +00:00
Benjamin Kramer b164d67d07 Driver: Pass down the -march setting down to -cc1as on x86 too.
The assembler historically didn't make use of any target features, but this has
changed when support for old CPUs that don't support long nops was added.

llvm-svn: 175919
2013-02-22 20:55:17 +00:00
Bill Wendling 2f81db66af Make sure we apply attributes to correct places.
Some attributes make sense only on the function or on the call site, but not
both. Make this distinction here.

llvm-svn: 175918
2013-02-22 20:53:29 +00:00
Eric Christopher d380400b17 Split out the command handling for split debug info, we're going
to want to propagate some information through the module into
the back end and so need to pass it through to codegen.

Also make the methods file static so we can use them in other places.

llvm-svn: 175916
2013-02-22 20:12:52 +00:00
Jordan Rose 893d73b7e9 [analyzer] Don't canonicalize the RecordDecl used in CXXBaseObjectRegion.
This Decl shouldn't be the canonical Decl; it should be the Decl used by
the CXXBaseSpecifier in the subclass. Unfortunately, that means continuing
to throw getCanonicalDecl() on all comparisons.

This fixes MemRegion::getAsOffset's use of ASTRecordLayout when redeclarations
are involved.

llvm-svn: 175913
2013-02-22 19:33:13 +00:00
Peter Collingbourne f32b3f2c55 Add support for coldcc to clang
llvm-svn: 175912
2013-02-22 19:24:35 +00:00
Argyrios Kyrtzidis 832de9fcf1 [preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.

This is because the order of the entities in the vector can change in some (uncommon) cases.

llvm-svn: 175907
2013-02-22 18:35:59 +00:00
Benjamin Kramer 2999b77f1d Replace some typically large vectors with SmallVector.
This may seem counter-intuitive but the POD-like optimization helps when the
vectors grow into multimegabyte buffers. SmallVector calls realloc which knows
how to twiddle virtual memory bits and avoids large copies.

llvm-svn: 175906
2013-02-22 18:29:39 +00:00
Rafael Espindola db1a47706b Make sure pragmas don't attach visibility attributes to auto variables with
internal linkage.

llvm-svn: 175903
2013-02-22 17:59:16 +00:00
Michael Han 84324357b8 [Sema] Semantic analysis for empty-declaration and attribute-declaration.
Introduce a new AST Decl node "EmptyDecl" to model empty-declaration. Have attributes from attribute-declaration appertain
to the EmptyDecl node by creating the AST representations of these attributes and attach them to the EmptyDecl node so these
attributes can be sema checked just as attributes attached to "normal" declarations.

llvm-svn: 175900
2013-02-22 17:15:32 +00:00
Benjamin Kramer 6582c36298 Use raw_ostream::indent, update comment.
llvm-svn: 175897
2013-02-22 16:13:34 +00:00
Benjamin Kramer 8de9046c6d Push the raw_ostream through the template diffing code.
llvm-svn: 175896
2013-02-22 16:08:12 +00:00
Benjamin Kramer 7192c9e12d Streamify FormatASTNodeDiagnosticArgument.
llvm-svn: 175895
2013-02-22 15:46:08 +00:00
Benjamin Kramer 9170e914fc Streamify getNameForDiagnostic and remove the string versions of PrintTemplateArgumentList.
llvm-svn: 175894
2013-02-22 15:46:01 +00:00
Dmitri Gribenko acf2e786d2 Comment parsing: add CommentOptions to allow specifying custom comment block commands
Add an ability to specify custom documentation block comment commands via a new
class CommentOptions.  The intention is that this class will hold future
customizations for comment parsing, including defining documentation comments
with specific numbers of parameters, etc.

CommentOptions instance is a member of LangOptions.

CommentOptions is controlled by a new command-line parameter
-fcomment-block-commands=Foo,Bar,Baz.

llvm-svn: 175892
2013-02-22 14:21:27 +00:00
Benjamin Kramer c5720e91a2 StmtPrinter: Directly print types to the stream instead of taking a detour through getAsString.
llvm-svn: 175891
2013-02-22 14:19:01 +00:00
Timur Iskhodzhanov f2afe63fa5 Fix MergeFunctionDecl implicit CC for static methods.
Patch by Alexander Zinenko!

llvm-svn: 175890
2013-02-22 12:42:50 +00:00
Richard Smith 3653b7e8e4 Don't crash if we try to apply 'alignas' to a variable declared with an
incomplete type.

llvm-svn: 175880
2013-02-22 09:21:42 +00:00
Richard Smith 4cabd04e75 Don't accidentally and silently accept C++11 attributes in decl-specifier-seqs
in C++98.

llvm-svn: 175879
2013-02-22 09:15:49 +00:00
Richard Smith 2386c8b221 Per the grammar in [dcl.dcl]p1, a simple-declaration can only have attributes
if it has declarators. We were missing the check for this in a couple of places.

llvm-svn: 175876
2013-02-22 09:06:26 +00:00
Richard Smith 44c247f0f0 Handle alignas(foo...) pack expansions.
llvm-svn: 175875
2013-02-22 08:32:16 +00:00
Argyrios Kyrtzidis 1fcd7fd633 In LookupResult::resolveKind(), when handling multiple found declarations, ignore invalid declarations.
This reduces the "ambiguous reference" errors (which are rather strange in C/ObjC) and fixes an assertion hit
with an invalid code test case.

llvm-svn: 175869
2013-02-22 06:58:37 +00:00
Argyrios Kyrtzidis 425daaa5d2 When a parameter list in a C function has an error, recover by forming a K&R function,
instead of a non-function type.

llvm-svn: 175868
2013-02-22 06:58:32 +00:00
Argyrios Kyrtzidis e936505807 Don't crash when applying an alloc_size attribute on a K&R function.
llvm-svn: 175867
2013-02-22 06:58:28 +00:00
Richard Smith 434516c50c Don't skip '_Alignas' when disambiguating 'final'. '_Alignas' can't appear here,
and we used to assert if it did.

llvm-svn: 175866
2013-02-22 06:46:23 +00:00
Richard Smith e6560761ce Teach -ast-print how to print trailing-return-types.
llvm-svn: 175864
2013-02-22 05:54:51 +00:00
Ted Kremenek efb41d23a6 [analyzer] Implement "Loop executed 0 times" diagnostic correctly.
Fixes <rdar://problem/13236549>

llvm-svn: 175863
2013-02-22 05:45:33 +00:00
Richard Smith bc8caaf05f Implement C++11 [dcl.align]p6-p8, and C11 6.7.5/7. This had to be split out of
the normal attribute-merging path, because we can't merge alignment attributes
without knowing the complete set of alignment attributes which apply to a
particular declaration.

llvm-svn: 175861
2013-02-22 04:55:39 +00:00
Argyrios Kyrtzidis 4431918f40 [libclang] Fix a crash with invalid code, while skip function bodies is enabled.
llvm-svn: 175860
2013-02-22 04:11:06 +00:00
NAKAMURA Takumi 62eae089ca Decl.cpp/mergeTemplateLV(): Tweak a description. [-Wdocumentation]
llvm-svn: 175859
2013-02-22 04:06:28 +00:00
John McCall 5149fbfd56 Only suppress instance context if a member is actually
accessible in its declaring class;  otherwise we might
fail to apply [class.protected] when considering
accessibility in derived classes.

Noticed by inspection; <rdar://13270329>.

I had an existing test wrong.  Here's why it's wrong:

Follow the rules (and notation) of [class.access]p5.
The naming class (N) is B and the context (R) is D::getX.
- 'x' as a member of B is protected, but R does not occur
  in a member or friend of a class derived from B.
- There does exist a base class of B, A, which is accessible
  from R, and 'x' is accessible at R when named in A because
  'x' as a member of A is protected and R occurs in a member
  of a class, D, that is derived from A;  however, by
  [class.protected], the class of the object expression must
  be equal to or derived from that class, and A does not
  derive from D.

llvm-svn: 175858
2013-02-22 03:52:55 +00:00
Anna Zaks 04e7ff43a1 [analyzer] Place all inlining policy checks into one palce
Previously, we had the decisions about inlining spread out
over multiple functions.

In addition to the refactor, this commit ensures
that we will always inline BodyFarm functions as long as the Decl
is available. This fixes false positives due to those functions
not being inlined when no or minimal inlining is enabled such (as
shallow mode).

llvm-svn: 175857
2013-02-22 02:59:24 +00:00
Richard Smith b3a145293d Add -fbracket-depth=N, analogous to -ftemplate-depth= and -fconstexpr-depth=,
to control the check for the C 5.2.4.1 / C++ [implimits] restriction on nesting
levels for parentheses, brackets and braces.

Some code with heavy macro use exceeds the default limit of 256, but we don't
want to increase it generally to avoid stack overflow on stack-constrained
systems.

llvm-svn: 175855
2013-02-22 01:59:51 +00:00
Jordan Rose 5772f82d1e [analyzer] Make sure a materialized temporary matches its bindings.
This is a follow-up to r175830, which made sure a temporary object region
created for, say, a struct rvalue matched up with the initial bindings
being stored into it. This does the same for the case in which the AST
actually tells us that we need to create a temporary via a
MaterializeObjectExpr. I've unified the two code paths and moved a static
helper function onto ExprEngine.

This also caused a bit of test churn, causing us to go back to describing
temporary regions without a 'const' qualifier. This seems acceptable; it's
our behavior from a few months ago.

<rdar://problem/13265460> (part 2)

llvm-svn: 175854
2013-02-22 01:51:15 +00:00
Ted Kremenek a3bb2b6044 Fix regression in modeling assignments of an address of a variable to itself. Fixes <rdar://problem/13226577>.
llvm-svn: 175852
2013-02-22 01:39:26 +00:00
Eric Christopher 77569ffd06 Make sure we only use the output file as a base for debug splitting
if we're compiling.

llvm-svn: 175851
2013-02-22 01:33:46 +00:00
Fariborz Jahanian ac2d082f58 objective-C arc: Diagnostic can not say to use bridge
casts with c++ named casts. Change notes to say use
bridge with c-style cast instead. // rdar://12788838

llvm-svn: 175850
2013-02-22 01:22:48 +00:00