mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[IDE/ModuleInterface] Fix erroneously printed newline between a regular comment and the declaration it is 'attached' to.
Swift SVN r16293
This commit is contained in:
@@ -43,6 +43,7 @@ namespace clang {
|
||||
class MacroInfo;
|
||||
class Module;
|
||||
class SourceLocation;
|
||||
class SourceRange;
|
||||
}
|
||||
|
||||
namespace swift {
|
||||
@@ -114,6 +115,7 @@ public:
|
||||
}
|
||||
|
||||
clang::SourceLocation getLocation() const;
|
||||
clang::SourceRange getSourceRange() const;
|
||||
};
|
||||
|
||||
enum class DeclKind : uint8_t {
|
||||
|
||||
@@ -45,6 +45,15 @@ clang::SourceLocation ClangNode::getLocation() const {
|
||||
return clang::SourceLocation();
|
||||
}
|
||||
|
||||
clang::SourceRange ClangNode::getSourceRange() const {
|
||||
if (auto D = getAsDecl())
|
||||
return D->getSourceRange();
|
||||
if (auto M = getAsMacro())
|
||||
return clang::SourceRange(M->getDefinitionLoc(), M->getDefinitionEndLoc());
|
||||
|
||||
return clang::SourceLocation();
|
||||
}
|
||||
|
||||
// Only allow allocation of Decls using the allocator in ASTContext.
|
||||
void *Decl::operator new(size_t Bytes, ASTContext &C,
|
||||
unsigned Alignment) {
|
||||
|
||||
@@ -362,7 +362,8 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
||||
const auto &Ctx = ClangLoader.getClangASTContext();
|
||||
const auto &SM = Ctx.getSourceManager();
|
||||
|
||||
clang::SourceLocation NodeLoc = SM.getFileLoc(Node.getLocation());
|
||||
clang::SourceLocation NodeLoc =
|
||||
SM.getFileLoc(Node.getSourceRange().getBegin());
|
||||
if (NodeLoc.isInvalid())
|
||||
return;
|
||||
unsigned NodeLineNo = SM.getSpellingLineNumber(NodeLoc);
|
||||
@@ -424,7 +425,8 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
||||
}
|
||||
*this << CommentText << "\n";
|
||||
printIndent();
|
||||
LastPrintedCommentLineNo = LineNo;
|
||||
LastPrintedCommentLineNo =
|
||||
SM.getLineNumber(LocInfo.first, LocInfo.second + Tok.getLength());
|
||||
|
||||
} while (true);
|
||||
|
||||
|
||||
@@ -63,9 +63,17 @@ extern int fooIntVar;
|
||||
|
||||
/// Aaa. fooFunc1. Bbb.
|
||||
int fooFunc1(int a);
|
||||
|
||||
int fooFunc1AnonymousParam(int);
|
||||
int fooFunc3(int a, float b, double c, int *d);
|
||||
|
||||
/*
|
||||
Very good
|
||||
fooFuncWithBlock function.
|
||||
*/
|
||||
extern
|
||||
void fooFuncWithBlock(int (^blk)(float x));
|
||||
|
||||
void fooFuncWithFunctionPointer(int (*fptr)(float x));
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,10 @@ var fooIntVar: CInt
|
||||
func fooFunc1(CInt) -> CInt
|
||||
func fooFunc1AnonymousParam(CInt) -> CInt
|
||||
func fooFunc3(CInt, CFloat, CDouble, CMutablePointer<CInt>) -> CInt
|
||||
/*
|
||||
Very good
|
||||
fooFuncWithBlock function.
|
||||
*/
|
||||
func fooFuncWithBlock((CFloat) -> CInt)
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user