James Dennett [Thu, 14 Jun 2012 21:40:34 +0000 (21:40 +0000)]
Still more Doxygen documentation fixes:
* Escape #, < and @ symbols where Doxygen would try to interpret them;
* Fix several function param documentation where names had got out of sync;
* Delete param documentation referring to parameters that no longer exist.
James Dennett [Thu, 14 Jun 2012 03:11:41 +0000 (03:11 +0000)]
This makes SemaCodeComplete.cpp more Doxygen-friendly by changing the
OBJC_AT_KEYWORD_NAME take a string literal argument where previously
its second argument was an unquoted token; macro invocations such as
OBJC_AT_KEYWORD_NAME(NeedAt,{) confuse Doxygen's parser.
While I'm wary of changing code (rather than just comments) to work
around Doxygen's limitations, in this case the change makes the code
more readable for human beings as well, and the macro derived no
benefit from using the preprocessor's stringification operator, as
it never has need of the unquoted token.
I've also included a couple of trivial drive-by fixes to doc comments.
James Dennett [Wed, 13 Jun 2012 22:07:09 +0000 (22:07 +0000)]
More doxygen/documentation cleanups.
This reduces the number of warnings generated by Doxygen by about 100
(roughly 10%). Issues addressed:
(1) Primarily, backslash-escaped "@foo" and "#bah" in Doxygen comments
when they're not supposed to be Doxygen commands or links, and
similarly for "<baz>" when it's not intended as as HTML tag;
(2) Changed some \t commands (which don't exist) to \c ("to refer to a
word of code", as the Doxygen manual says);
(3) \precondition becomes \pre;
(4) When touching comments, deleted a couple of spurious spaces in them;
(5) Changed some \n and \r to \\n and \\r;
(6) Fixed one tiny typo: #pragms -> #pragma.
Richard Smith [Wed, 13 Jun 2012 20:27:03 +0000 (20:27 +0000)]
Add -isystem-prefix and -ino-system-prefix arguments, which can be used to
override whether headers are system headers by checking for prefixes of the
header name specified in the #include directive.
This allows warnings to be disabled for third-party code which is found in
specific subdirectories of include paths.
Richard Trieu [Wed, 13 Jun 2012 20:25:24 +0000 (20:25 +0000)]
Moved the StringLiteral printing code from StmtPrinter into the StringLiteral
class and have StmtPrinter and StmtDumper refer to it. This fixes an
assertion failure when dumping wchar string literals.
Daniel Jasper [Wed, 13 Jun 2012 07:12:33 +0000 (07:12 +0000)]
Rename shouldVisitImplicitDeclarations to shouldVisitImplicitCode.
Fix RecursiveASTVisitor to visit CXXForRangeStmts accordingly to visit
implicit or explicit code.
The key bug that inspired this was the Visitor not visiting the range
initializer of such a loop, which is explicit code.
Charles Davis [Wed, 13 Jun 2012 00:18:14 +0000 (00:18 +0000)]
Grab bag of Microsoft Mangler fixes:
- Support mangling virtual function tables (base tables need work on the
ManglerContext interface).
- Correct mangling of local scopes (i.e. functions and C++ methods).
- Replace every llvm_unreachable() for actually-reachable code with a
diagnostic.
Chad Rosier [Tue, 12 Jun 2012 19:03:42 +0000 (19:03 +0000)]
[ms-inline-asm] Cleanup MS style inline assembly parsing.
Specifically, improve the handling of whitespace, stop saving tokens that are
in comments and fix the case where we have a comment followed by a closing brace
on the next line.
Unfortunately, there's no easy way of testing this code.
Jordan Rose [Mon, 11 Jun 2012 23:20:52 +0000 (23:20 +0000)]
[analyzer] Treat LValueBitCasts like regular pointer bit casts.
These casts only appear in very well-defined circumstances, in which the
target of a reinterpret_cast or a function formal parameter is an lvalue
reference. According to the C++ standard, the following are equivalent:
Hal Finkel [Mon, 11 Jun 2012 22:35:19 +0000 (22:35 +0000)]
Add PPC support for translating gcc-style -mcpu options into LLVM -target-cpu options.
This functionality is based on what is done on ARM, and enables selecting PPC CPUs
in a way compatible with gcc's driver. Also, mirroring gcc (and what is done on x86),
-mcpu=native support was added. This uses the host cpu detection from LLVM
(which will also soon be updated by refactoring code currently in backend).
In order for this to work, the target needs a list of valid CPUs -- we now accept all CPUs accepted by LLVM.
A few preprocessor defines for common CPU types have been added.
Jordan Rose [Mon, 11 Jun 2012 16:40:41 +0000 (16:40 +0000)]
[analyzer] Add ObjCLoopChecker: objects from NSArray et al are non-nil.
While collections containing nil elements can still be iterated over in an
Objective-C for-in loop, the most common Cocoa collections -- NSArray,
NSDictionary, and NSSet -- cannot contain nil elements. This checker adds
that assumption to the analyzer state.
This was the cause of some minor false positives concerning CFRelease calls
on objects in an NSArray.
Jordan Rose [Mon, 11 Jun 2012 16:40:37 +0000 (16:40 +0000)]
[analyzer] When looking for a known class, only traverse the hierarchy once.
This has a small hit in the case where only one class is interesting
(NilArgChecker) but is a big improvement when looking for one of several
interesting classes (VariadicMethodTypeChecker), in which the most common
case is that there is no match.
James Dennett [Mon, 11 Jun 2012 06:19:40 +0000 (06:19 +0000)]
Documentation cleanup, fixing Doxygen markup. Mostly this avoids common terms
such as "protocol" and "expression" being implicitly turned into links to
mistakenly-generated Doxygen pages:
- Escaping @ symbols when Doxygen would otherwise incorrectly interpret them;
- Escaping # symbols when they're not intended as explicit Doxygen link
requests, such as when discussing preprocessor directives;
- In one odd case, unescaping @ in @__experimental_modules_import, because
Doxygen wrote '\@' to the output in that case, causing the example in the
description of ImportDecl to be wrong; and
- Fixing a typo: @breif -> @brief.
Richard Smith [Sun, 10 Jun 2012 07:07:24 +0000 (07:07 +0000)]
Remove CXXRecordDecl flags which are unused after r158289.
We need an efficient mechanism to determine whether a defaulted default
constructor is constexpr, in order to determine whether a class is a literal
type, so keep the incrementally-built form on CXXRecordDecl. Remove the
on-demand computation of same, so that we only have one method for determining
whether a default constructor is constexpr. This doesn't affect correctness,
since default constructor lookup is much simpler than selecting a constructor
for copying or moving.
We don't need a corresponding mechanism for defaulted copy or move constructors,
since they can't affect whether a type is a literal type. Conversely, checking
whether such functions are constexpr can require non-trivial effort, so we defer
such checks until the copy or move constructor is required.
Thus we now only compute whether a copy or move constructor is constexpr on
demand, and only compute whether a default constructor is constexpr in advance.
This is unfortunate, but seems like the best solution.
Richard Smith [Sun, 10 Jun 2012 05:43:50 +0000 (05:43 +0000)]
Fix PR13052 properly, by performing special member lookup to determine whether
an explicitly-defaulted default constructor would be constexpr. This is
necessary in weird (but well-formed) cases where a class has more than one copy
or move constructor.
Cleanup of now-unused parts of CXXRecordDecl to follow.
Richard Smith [Sun, 10 Jun 2012 03:12:00 +0000 (03:12 +0000)]
PR13064: Store whether an in-class initializer uses direct or copy
initialization, and use that information to produce the right kind of
initialization during template instantiation.
[C++11 Compat] Fix breaking change in C++11 pair copyctor.
While this code is valid C++98, it is not valid C++11. The problem can be
reduced to:
class MDNode;
class DIType {
operator MDNode*() const {return 0;}
};
class WeakVH {
WeakVH(MDNode*) {}
};
int main() {
DIType di;
std::pair<void*, WeakVH> p(std::make_pair((void*)0, di)));
}
This was not detected by any of the bots we have because they either compile
C++98 with libstdc++ (which allows it), or C++11 with libc++ (which incorrectly
allows it). I ran into the problem when compiling with VS 2012 RC.
Jordan Rose [Fri, 8 Jun 2012 21:14:25 +0000 (21:14 +0000)]
Disallow using ObjC literals in direct comparisons (== and friends).
Objective-C literals conceptually always create new objects, but may be
optimized by the compiler or runtime (constant folding, singletons, etc).
Comparing addresses of these objects is relying on this optimization
behavior, which is really an implementation detail.
In the case of == and !=, offer a fixit to a call to -isEqual:, if the
method is available. This fixit is directly on the error so that it is
automatically applied.
Most of the time, this is really a newbie mistake, hence the fixit.
Jordan Rose [Fri, 8 Jun 2012 21:14:19 +0000 (21:14 +0000)]
If fixits appear to overlap, move the second one over in the output.
This occurs when you have two insertions and the first one is so long that the
second fixit's column is before the first fixit ends. The edits themselves
don't actually overlap, but our command-line preview does.
Richard Smith [Fri, 8 Jun 2012 21:09:22 +0000 (21:09 +0000)]
PR13051: If a constructor is explicitly defaulted, it isn't marked as being
constexpr until we get to the end of the class definition. When that happens,
be sure to remember that the class actually does have a constexpr constructor.
This is a stopgap solution, which still doesn't cover the case of a class with
multiple copy constructors (only some of which are constexpr). We should be
performing constructor lookup when implicitly defining a constructor in order
to determine whether all constructors it invokes are constexpr.
Anna Zaks [Fri, 8 Jun 2012 18:44:43 +0000 (18:44 +0000)]
[analyzer] MallocSizeofChecker false positive: when sizeof is argument
to addition.
We should not to warn in case the malloc size argument is an
addition containing 'sizeof' operator - it is common to use the pattern
to pack values of different sizes into a buffer.
Jordan Rose [Fri, 8 Jun 2012 18:06:21 +0000 (18:06 +0000)]
Disable _Pragma during HTML macro rewriting to keep from crashing.
The preprocessor's handling of diagnostic push/pops is stateful, so
encountering pragmas during a re-parse causes problems. HTMLRewrite
already filters out normal # directives including #pragma, so it's
clear it's not expected to be interpreting pragmas in this mode.
This fix adds a flag to Preprocessor to explicitly disable pragmas.
The "right" fix might be to separate pragma lexing from pragma
parsing so that we can throw away pragmas like we do preprocessor
directives, but right now it's important to get the fix in.
Note that this has nothing to do with the "hack" of re-using the
input preprocessor in HTMLRewrite. Even if we someday copy the
preprocessor instead of re-using it, the copy would (and should) include
the diagnostic level tables and have the same problems.
[libclang/AST]
AST: For auto-synthesized ivars give them the location of the related
property (previously they had no source location). This allows them
to be indexed by libclang.
libclang: Make sure synthesized ivars are indexed before the methods that
may reference them.
Rename a test case to a more generic name. This is a completely useless
test, but David Sehr is looking at spiffing it up and adding some proper
tests for our alloca codegen.
Anna Zaks [Fri, 8 Jun 2012 00:04:43 +0000 (00:04 +0000)]
[analyzer] Add experimental "issue hash" to the plist diagnostic.
CmpRuns.py can be used to compare issues from different analyzer runs.
Since it uses the issue line number to unique 2 issues, adding a new
line to the beginning of a file makes all issues in the file reported as
new.
The hash will be an opaque value which could be used (along with the
function name) by CmpRuns to identify the same issues. This way, we only
fail to identify the same issue from two runs if the function it appears
in changes (not perfect, but much better than nothing).