Manuel Klimek [Mon, 7 Jan 2013 18:10:23 +0000 (18:10 +0000)]
Fix parsing of variable declarations directly after a class / struct.
Previous indent:
class A {
}
a;
void f() {
};
With this patch:
class A {
} a;
void f() {
}
;
The patch introduces a production for classes and structs, and parses
the rest of the line to the semicolon after the class scope.
This allowed us to remove a long-standing wart in the parser that would
just much the semicolon after any block.
Due to this suboptimal formating some tests were broken.
Some unrelated formatting tests broke; those hit a bug in the ast
printing, and need to be fixed separately.
Michael Han [Mon, 7 Jan 2013 16:57:11 +0000 (16:57 +0000)]
Add fixit hints for misplaced C++11 attributes around class specifiers.
Following r168626, in class declaration or definition, there are a combination of syntactic locations
where C++11 attributes could appear, and among those the only valid location permitted by standard is
between class-key and class-name. So for those attributes appear at wrong locations, fixit is used to
move them to expected location and we recover by applying them to the class specifier.
Douglas Gregor [Mon, 7 Jan 2013 16:56:53 +0000 (16:56 +0000)]
updateOutOfDateIdentifier() can cause the identifier table to be
rehashed, invaliding the iterator walking through the identifier
table. Separate out the identification of out-of-date identifiers from
updating them.
David Tweed [Mon, 7 Jan 2013 16:43:27 +0000 (16:43 +0000)]
Scalar shifts in the OpenCL specification (as of v. 1.2) are defined to be
with respect to the lower "left-hand-side bitwidth" bits, even when negative);
see OpenCL spec 6.3j. This patch both implements this behaviour in the code
generator and "constant folding" bits of Sema, and also prevents tests
to detect undefinedness in terms of the weaker C99 or C++ specifications
from being applied.
This required rudimentary changes to static initializer lists, but we
are not yet formatting them in a reasonable way. That will be done in a
subsequent patch.
To implement this I introduced a line type during parsing and moved the
definition of TokenType out of the struct for increased readability.
Should have done the latter in a separate patch, but it would be hard to
pull apart now.
Manuel Klimek [Mon, 7 Jan 2013 10:03:37 +0000 (10:03 +0000)]
Fix incorrect FIXME.
The case that we wanted to write a test for cannot happen, as the
UnwrappedLineParser already protects against it. Added an assert to
prevent regressions of that assumption.
Manuel Klimek [Mon, 7 Jan 2013 09:24:17 +0000 (09:24 +0000)]
Do not ever allow using the full line in preprocessor directives.
We would format:
#define A \
int f(a); int i;
as
#define A \
int f(a);\
int i
The fix will break up macro definitions that could fit a line, but hit
the last column; fixing that is more involved, though, as it requires
looking at the following line.
Manuel Klimek [Mon, 7 Jan 2013 07:56:50 +0000 (07:56 +0000)]
Fix layouting of tokens with a leading escaped newline.
If a token follows directly on an escaped newline, the escaped newline
is stored with the token. Since we re-layout escaped newlines, we need
to treat them just like normal whitespace - thus, we need to increase
the whitespace-length of the token, while decreasing the token length
(otherwise the token length contains the length of the escaped newline
and we double-count it while indenting).
David Blaikie [Mon, 7 Jan 2013 05:55:03 +0000 (05:55 +0000)]
PR14759: Improve/correct support for debug info for C++ member pointers.
Using added LLVM functionality in r171698. This works in GDB for member
variable pointers but not member function pointers. See the LLVM commit and
GDB bug 14998 for details.
Un-xfailing cases in the GDB 7.5 test suite will follow.
Manuel Klimek [Sat, 5 Jan 2013 22:56:06 +0000 (22:56 +0000)]
Fixes parsing of hash tokens in the middle of a line.
To parse # correctly, we need to know whether it is the first token in a
line - we can deduct this either from the whitespace or seeing that the
token is the first in the file - we already calculate this information.
This patch moves the identification of the first token into the
getNextToken method and stores it inside the FormatToken, so the
UnwrappedLineParser can stay independent of the SourceManager.
Fixes a breakage in dejagnu++ test suite where it included
<objc/Protocol.h>. Caused by my recent changes for
various builtin declarations of objc_msgSendSuper
variety. // rdar://12489098
David Blaikie [Sat, 5 Jan 2013 20:03:07 +0000 (20:03 +0000)]
PR14573: Unnamed parameters in debug info, Part 2
Catch some cases I'd missed in r171605 related to unnamed parameters of record
type. This resolves all remaining cases of PR14573 suppression in the GDB 7.5
test suite. Fix to the test suite to follow.
David Blaikie [Sat, 5 Jan 2013 05:48:08 +0000 (05:48 +0000)]
Change test/CodeGenCXX/debug-info-method.cpp an IR (rather than asm) test.
Referring back to the original commit (r115090) which was a frontend only test
I adjusted this test to verify the frontend change that was made, to emit the
protected access value in the flags metadata field.
Manuel Klimek [Fri, 4 Jan 2013 23:34:14 +0000 (23:34 +0000)]
Various fixes to clang-format's macro handling.
Some of this is still pretty rough (note the load of FIXMEs), but it is
strictly an improvement and fixes various bugs that were related to
macro processing but are also imporant in non-macro use cases.
Specific fixes:
- correctly puts espaced newlines at the end of the line
- fixes counting of white space before a token when escaped newlines are
present
- fixes parsing of "trailing" tokens when eof() is hit
- puts macro parsing orthogonal to parsing other structure
- general support for parsing of macro definitions
Due to the fix to format trailing tokens, this change also includes a
bunch of fixes to the c-index tests.
objective-C arc: in copy helper function for
__strong __block variables, perform objc_storeStrong on
source and destination instead of direct move. This
is done with -O0 and to improve some analysis.
// rdar://12530881
Ted Kremenek [Fri, 4 Jan 2013 19:04:40 +0000 (19:04 +0000)]
NSErrorChecker: remove quoting the parameter name in the diagnostic until we actually include it's name.
This is a possible regression of moving to using ImplicitNullDerefEvent.
Fixing this for real (including the parameter name) requires more
plumbing in ImplicitNullDerefEvent. This is just a stop gap fix.
Manman Ren [Fri, 4 Jan 2013 18:51:35 +0000 (18:51 +0000)]
Debug Info: fix the line location for cleanup code of a block function
The line information was changed when emitting debug information for all the
DeclRefExprs and we should change it back to get ready for PopClenupBlocks
called from FinishFunction.
Uses of clang_getSpellingLocation should eventually move to calling
clang_getFileLocation, and clang_getSpellingLocation should do what
its name represents and actually point at the 'spelling' location, e.g.
inside a macro definition if the spelling of a token came from that.
[arcmt] Adds brackets in case statements that "contain" initialization of retaining
variable, thus emitting the "switch case is in protected scope" error.
To do so we have to wait until we know that the type of a variable has been
deduced. Sema::FinalizeDeclaration is the first callback that is used for
decl with or without initializers.
Sean Silva [Wed, 2 Jan 2013 23:07:22 +0000 (23:07 +0000)]
analyzer: add initial Sphinx configuration
This is just the output of sphinx-quickstart. Now all that is needed
to begin converting the analyzer docs to reST is the server-side setup.
The analyzer folks have asked me to keep this segregated from the other
clang docs since the analyzer is a logically separate project (and has
its own separate web page) even though it resides in the clang tree.
Sean Silva [Wed, 2 Jan 2013 22:05:33 +0000 (22:05 +0000)]
docs: Mark ReleaseNotes as "In-Progress"
Even though we do have a `.. warning::` directive on the page, hopefully
having "In-Progress" in the title will help to condition people's
expectations a bit for when they run into the extremely bare-bones
release notes.
Also, when release season comes around again, maybe this will get
people's attention and avoid confusion about what is going into the
upcoming release, and what is for changes to trunk for the next version.
Sean Silva [Wed, 2 Jan 2013 21:50:48 +0000 (21:50 +0000)]
docs: Take advantage of extra level of headings.
The way Sphinx treats the "top-level" adornments is weird. It usually
uses the first top-level adornment as the page title, even if the
top-level adornment is just one "section" out of many (i.e. if the first
section is "Introduction", then it will make the page title be
"Introduction"). This behavior can be overriden by using an explicit
`.. title::` directive to set the title.
Since the Sphinx stylesheet that Clang is currently using ('haiku')
nicely puts the document title at the top of the page in the header,
this weird default behavior was resulting in a redundant "title" in the
body content. Getting rid of this redundant level of headings
effectively "exposes" one more level of heading from the stylesheet to
which now makes the real "sections" more distinct.
Sean Silva [Wed, 2 Jan 2013 21:03:11 +0000 (21:03 +0000)]
docs: Reorganize landing page.
Language extensions are highly relevant to using clang as a compiler, so
move LanguageExtensions up into `Using Clang as a Compiler` on the
landing page.
The other documents from the now-gone `Language Extensions and Specs`
section on the landing page nicely fit hierarchically under
LanguageExtensions.rst, so put them under LanguageExtensions.rst's
toctree instead of on the landing page.