Don't warn for parentheses for the '&&' inside '||' for cases like:
assert(a || b && "bad");
since this is safe. This way we avoid a big source of such warnings which in this case are practically useless.
Note that we don't handle *all* cases where precedence wouldn't matter because of constants since
this is a bit costly to check, and IMO clarifying precedence with parentheses is good for
readability in general.
Douglas Gregor [Wed, 17 Nov 2010 17:15:08 +0000 (17:15 +0000)]
When libclang is walking a member access expression, don't walk into
an implicit "this"; it causes clang_getCursor() to find the implicit
"this" expression (which isn't written in the source!) rather than the
actual member.
Douglas Gregor [Wed, 17 Nov 2010 17:14:07 +0000 (17:14 +0000)]
When comparing the source range of a declaration against the region of
interest (e.g., as used by clang_getCursor()), count the
decl-specifier-seq as part of the source range, as we do for
clang_annotateTokens(). Makes clang_getCursor() work properly for the
result types of functions, for example.
Chris Lattner [Wed, 17 Nov 2010 08:25:26 +0000 (08:25 +0000)]
When forming the !srcloc mdnode for an inline asm, add the SourceLocations
of all the lines of the inline asm. With the refactoring and enhancement
of the backend, we can now reports errors on the correct source line when
an asm contains multiple lines of text. For something like this:
void foo() {
asm("push %rax\n"
".code32\n");
}
we used to get this: (note that the line 4 in t.c isn't helpful)
t.c:4:7: error: warning: ignoring directive for now
asm("push %rax\n"
^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^
now we get:
t.c:5:8: error: warning: ignoring directive for now
".code32\n"
^
<inline asm>:2:1: note: instantiated into assembly here
.code32
^
Note that we're pointing to line 5 properly now. This implements
rdar://7839391 - inline asm errors should point to the right line in the asm
and makes the error message in PR8595 much less confusing.
Chris Lattner [Wed, 17 Nov 2010 07:37:15 +0000 (07:37 +0000)]
a metric ton of refactoring later, Sema::getLocationOfStringLiteralByte
no longer depends on Preprocessor, so we can move it out of Sema into
a nice new StringLiteral::getLocationOfByte method that can be used by
any AST client.
Bob Wilson [Wed, 17 Nov 2010 00:44:53 +0000 (00:44 +0000)]
Re-enable test with modifications for Neon vector changes in clang.
I mistakenly thought that this was checking for vector name mangling, but
it is not. Since we're no longer wrapping Neon vectors in structs, this
test can just return a vector directly. There are already other tests for
that, so just to make this interesting, change the test to return a struct
of two vectors.
Douglas Gregor [Wed, 17 Nov 2010 00:13:31 +0000 (00:13 +0000)]
Fix source-range information for Objective-C properties. Previously,
we were just getting a range covering only the property name, which is
certainly not correct (and broke token annotation, among other
things).
Also, teach libclang about the relationship between
@synthesize/@dynamic and @property, so we get property name and
cursor-reference information for @synthesize and @dynamic.
John McCall [Tue, 16 Nov 2010 23:07:28 +0000 (23:07 +0000)]
Support compound complex operations as l-values in C++. Add a test
case based on CodeGen/volatile-1.c which tests the current C++
semantics, and note the many, many places we fall short of them.
Douglas Gregor [Tue, 16 Nov 2010 20:45:51 +0000 (20:45 +0000)]
Use an OwningPtr for the preamble buffer in ASTUnit. This plugs a leak
where we failed to free this buffer along one of the paths, and
detangles the code a little.
Anton Yartsev [Tue, 16 Nov 2010 20:09:36 +0000 (20:09 +0000)]
turned pointers into pointers to const in function parameters in all functions/builtins accepting pointers to a const-qualified type according to PIM and "Language Extensions for CBEA"
Chandler Carruth [Tue, 16 Nov 2010 10:26:08 +0000 (10:26 +0000)]
This really seems like a boring set of fixes to our tests to make them more
independent of the underlying system. Let me know if any of these are too
aggressive.
John McCall [Tue, 16 Nov 2010 10:08:07 +0000 (10:08 +0000)]
Simplify some complex emission and implement correct semantics for
assignment to volatiles in C. This in effect reverts some of mjs's
work in and around r72572. Basically, the C++ standard is quite
clear, except that it lies about volatile behavior approximating
C's, whereas the C standard is almost actively misleading.
Chandler Carruth [Tue, 16 Nov 2010 10:07:43 +0000 (10:07 +0000)]
Futher reduce the includes of our builtin headers, and teach limits.h to avoid
include_next when not hosted or unavailable. This follows the pattern in
stdint.h and allows these headers to work even in a freestanding configuration
without a standard library.
Chandler Carruth [Tue, 16 Nov 2010 08:49:43 +0000 (08:49 +0000)]
Fix PR8625 and correctly interpret member-calls to static members when
producing warnings.
This feels really fragile, and I've not audited all other argument index-based
warnings. I suspect we'll grow this bug on another warning eventually. It might
be nice to adjust the argument indices when building up the attribute AST node,
as we already have to remember about the 'this' argument within that code to
produce correct errors.
Chandler Carruth [Tue, 16 Nov 2010 08:35:43 +0000 (08:35 +0000)]
Re-work the handling of implicit 'this' arguments and silly GCC-style attribute
argument indexes. This handles the offsets in a consistent manner for all of
the attributes which I saw working with these concepts. I've also added tests
for the attribute that motivated this: nonnull.
I consolidated the tests for format attributes into one file, and fleshed them
out a bit to trigger more of the warning cases. Also improved the quality of
some of the diagnostics that occur with invalid argument indices.
The only really questionable change here is supporting the implicit this
argument for the ownership attribute. I'm not sure it's really a sensible
concept there, but implemented the logic for consistency.
Ted Kremenek [Tue, 16 Nov 2010 08:15:38 +0000 (08:15 +0000)]
Rework USR generation from CXCursors to use CXStringBufs
for the backing of generated USRs. This optmizes
for the case when a client generates a sequence
of USRs in sequence, disposing of them soon
after generating them. By using a string buffer,
we recycle malloc'ed memory instead of constantly
malloc'ing and copying strings.
Ted Kremenek [Tue, 16 Nov 2010 08:15:36 +0000 (08:15 +0000)]
Change CXTranslationUnit to not directly cast to an ASTUnit*,
but to wrap both an ASTUnit and a "string pool"
that will be used for fast USR generation.
This requires a bunch of mechanical changes, as
there was a ton of code that assumed that CXTranslationUnit
and ASTUnit* were the same.
Along with this change, introduce CXStringBuf,
which provides an llvm::SmallVector<char> backing
for repeatedly generating CXStrings without a huge
amount of malloc() traffic. This requires making
some changes to the representation of CXString
by renaming a few fields (but keeping the size
of the object the same).
Zhongxing Xu [Tue, 16 Nov 2010 07:52:17 +0000 (07:52 +0000)]
Handle member initializer in C++ ctor.
- Add a new Kind of ProgramPoint: PostInitializer.
- Still use GRStmtNodeBuilder. But special handling PostInitializer in
GRStmtNodeBuilder::GenerateAutoTransition().
- Someday we should clean up the interface of GRStmtNodeBuilder.
Marcin Swiderski [Tue, 16 Nov 2010 07:15:33 +0000 (07:15 +0000)]
Basic support for C++ in BasicStore:
- CXXThisRegion treated like VarRegion and ObjCIVarRegion in various places,
- Reference treated like pointer in BindDeclInternal.
Bob Wilson [Tue, 16 Nov 2010 00:32:24 +0000 (00:32 +0000)]
Add support for "neon_vector_type" and "neon_polyvector_type" attributes
to create the special Neon vector types. These are intended to be used in
Clang's version of <arm_neon.h> to define special Neon vector types that will
be mangled according to ARM's ABI.
Bob Wilson [Tue, 16 Nov 2010 00:32:20 +0000 (00:32 +0000)]
ASTContext::getVectorType should preserve the vector kind for canonical types.
This is needed for Neon types when it is most natural to define them in terms
of a typedef. For example, Neon poly8_t is a typedef for "signed char", and
we want to define polynomial vectors as vectors of that typedef. Without this
change, the result will be a generic GCC-style vector. I think this is safe
for other vector types as well, but I would appreciate a review of this.
Bob Wilson [Tue, 16 Nov 2010 00:32:18 +0000 (00:32 +0000)]
Change CXXNameMangler::mangleNeonVectorType to require the vector type to be
one of the special Neon types. We'll check for invalid Neon vectors when
they are created, so there's no point in handling them when mangling.
John McCall [Mon, 15 Nov 2010 23:31:06 +0000 (23:31 +0000)]
Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations. Uses to follow.
Douglas Gregor [Mon, 15 Nov 2010 23:00:34 +0000 (23:00 +0000)]
Tweak libclang's heuristics for building precompiled preambles and
caching global code-completion results. In particular, don't perform
either operation the first time we parse, but do both after the first
reparse.
Ted Kremenek [Mon, 15 Nov 2010 22:59:22 +0000 (22:59 +0000)]
Remove invalid assertion from CFG builder. When building the CFG pieces for a ternary '?' expression,
it is possible for the confluence block to only have a single predecessor due to calls to 'noreturn'
functions. Fixes assertion failure reported in PR 8619.
Ted Kremenek [Mon, 15 Nov 2010 22:23:24 +0000 (22:23 +0000)]
Annotate CursorVisitor::VisitDataRecursive() with attribute 'noinline'.
Clang currently uses a ridiculous amount of stack space when inlining
this function, which can lead to premature stack overflows.
Ted Kremenek [Mon, 15 Nov 2010 20:09:42 +0000 (20:09 +0000)]
Relax assertion in SValuator so that we don't crash when analyzing a call via a function pointer that
casts the return value to something completely different. While we need better reasoning here,
we should definately not crash.
Rafael Espindola [Mon, 15 Nov 2010 18:28:16 +0000 (18:28 +0000)]
Fixes PR8611.
Silence warning about -g not being used during linking. I couldn't find any
change in behavior in gcc liking when given -g. Please open another bug if
I missed something.
Douglas Gregor [Mon, 15 Nov 2010 15:41:16 +0000 (15:41 +0000)]
Implement C++0x [temp.func.order]p3 (aka DR532) properly. In
particular, we only add the implement object parameter type if only
one of the function templates is a non-static member function
template.
Moreover, since this DR differs from existing practice in C++98/03,
this commit implements the existing practice (which ignores the
first parameter of the function template that is not the non-static
member function template) in C++98/03 mode.