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 MacroInfo;
|
||||||
class Module;
|
class Module;
|
||||||
class SourceLocation;
|
class SourceLocation;
|
||||||
|
class SourceRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace swift {
|
namespace swift {
|
||||||
@@ -114,6 +115,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
clang::SourceLocation getLocation() const;
|
clang::SourceLocation getLocation() const;
|
||||||
|
clang::SourceRange getSourceRange() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DeclKind : uint8_t {
|
enum class DeclKind : uint8_t {
|
||||||
|
|||||||
@@ -45,6 +45,15 @@ clang::SourceLocation ClangNode::getLocation() const {
|
|||||||
return clang::SourceLocation();
|
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.
|
// Only allow allocation of Decls using the allocator in ASTContext.
|
||||||
void *Decl::operator new(size_t Bytes, ASTContext &C,
|
void *Decl::operator new(size_t Bytes, ASTContext &C,
|
||||||
unsigned Alignment) {
|
unsigned Alignment) {
|
||||||
|
|||||||
@@ -362,7 +362,8 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
|||||||
const auto &Ctx = ClangLoader.getClangASTContext();
|
const auto &Ctx = ClangLoader.getClangASTContext();
|
||||||
const auto &SM = Ctx.getSourceManager();
|
const auto &SM = Ctx.getSourceManager();
|
||||||
|
|
||||||
clang::SourceLocation NodeLoc = SM.getFileLoc(Node.getLocation());
|
clang::SourceLocation NodeLoc =
|
||||||
|
SM.getFileLoc(Node.getSourceRange().getBegin());
|
||||||
if (NodeLoc.isInvalid())
|
if (NodeLoc.isInvalid())
|
||||||
return;
|
return;
|
||||||
unsigned NodeLineNo = SM.getSpellingLineNumber(NodeLoc);
|
unsigned NodeLineNo = SM.getSpellingLineNumber(NodeLoc);
|
||||||
@@ -424,7 +425,8 @@ void ClangCommentPrinter::printCommentsUntil(ClangNode Node) {
|
|||||||
}
|
}
|
||||||
*this << CommentText << "\n";
|
*this << CommentText << "\n";
|
||||||
printIndent();
|
printIndent();
|
||||||
LastPrintedCommentLineNo = LineNo;
|
LastPrintedCommentLineNo =
|
||||||
|
SM.getLineNumber(LocInfo.first, LocInfo.second + Tok.getLength());
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,17 @@ extern int fooIntVar;
|
|||||||
|
|
||||||
/// Aaa. fooFunc1. Bbb.
|
/// Aaa. fooFunc1. Bbb.
|
||||||
int fooFunc1(int a);
|
int fooFunc1(int a);
|
||||||
|
|
||||||
int fooFunc1AnonymousParam(int);
|
int fooFunc1AnonymousParam(int);
|
||||||
int fooFunc3(int a, float b, double c, int *d);
|
int fooFunc3(int a, float b, double c, int *d);
|
||||||
|
|
||||||
|
/*
|
||||||
|
Very good
|
||||||
|
fooFuncWithBlock function.
|
||||||
|
*/
|
||||||
|
extern
|
||||||
void fooFuncWithBlock(int (^blk)(float x));
|
void fooFuncWithBlock(int (^blk)(float x));
|
||||||
|
|
||||||
void fooFuncWithFunctionPointer(int (*fptr)(float x));
|
void fooFuncWithFunctionPointer(int (*fptr)(float x));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -76,6 +76,10 @@ var fooIntVar: CInt
|
|||||||
func fooFunc1(CInt) -> CInt
|
func fooFunc1(CInt) -> CInt
|
||||||
func fooFunc1AnonymousParam(CInt) -> CInt
|
func fooFunc1AnonymousParam(CInt) -> CInt
|
||||||
func fooFunc3(CInt, CFloat, CDouble, CMutablePointer<CInt>) -> CInt
|
func fooFunc3(CInt, CFloat, CDouble, CMutablePointer<CInt>) -> CInt
|
||||||
|
/*
|
||||||
|
Very good
|
||||||
|
fooFuncWithBlock function.
|
||||||
|
*/
|
||||||
func fooFuncWithBlock((CFloat) -> CInt)
|
func fooFuncWithBlock((CFloat) -> CInt)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user