r174173 - libclang: introduce cxstring::createNull()
Dmitri Gribenko
gribozavr at gmail.com
Fri Feb 1 06:13:33 PST 2013
Author: gribozavr
Date: Fri Feb 1 08:13:32 2013
New Revision: 174173
URL: http://llvm.org/viewvc/llvm-project?rev=174173&view=rev
Log:
libclang: introduce cxstring::createNull()
Modified:
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
cfe/trunk/tools/libclang/CXComment.cpp
cfe/trunk/tools/libclang/CXCompilationDatabase.cpp
cfe/trunk/tools/libclang/CXString.cpp
cfe/trunk/tools/libclang/CXString.h
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Fri Feb 1 08:13:32 2013
@@ -2935,7 +2935,7 @@ CXCursor clang_getTranslationUnitCursor(
extern "C" {
CXString clang_getFileName(CXFile SFile) {
if (!SFile)
- return createCXString((const char*)NULL);
+ return cxstring::createNull();
FileEntry *FEnt = static_cast<FileEntry *>(SFile);
return createCXString(FEnt->getName());
@@ -5875,7 +5875,7 @@ CXSourceRange clang_Cursor_getCommentRan
CXString clang_Cursor_getRawCommentText(CXCursor C) {
if (!clang_isDeclaration(C.kind))
- return createCXString((const char *) NULL);
+ return cxstring::createNull();
const Decl *D = getCursorDecl(C);
ASTContext &Context = getCursorContext(C);
@@ -5890,7 +5890,7 @@ CXString clang_Cursor_getRawCommentText(
CXString clang_Cursor_getBriefCommentText(CXCursor C) {
if (!clang_isDeclaration(C.kind))
- return createCXString((const char *) NULL);
+ return cxstring::createNull();
const Decl *D = getCursorDecl(C);
const ASTContext &Context = getCursorContext(C);
@@ -5904,7 +5904,7 @@ CXString clang_Cursor_getBriefCommentTex
return createCXString(BriefText, false);
}
- return createCXString((const char *) NULL);
+ return cxstring::createNull();
}
CXComment clang_Cursor_getParsedComment(CXCursor C) {
Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Fri Feb 1 08:13:32 2013
@@ -112,7 +112,7 @@ CXString clang_getCompletionChunkText(CX
unsigned chunk_number) {
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
if (!CCStr || chunk_number >= CCStr->size())
- return createCXString((const char*)0);
+ return cxstring::createNull();
switch ((*CCStr)[chunk_number].Kind) {
case CodeCompletionString::CK_TypedText:
@@ -211,7 +211,7 @@ CXString clang_getCompletionAnnotation(C
unsigned annotation_number) {
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
return CCStr ? createCXString(CCStr->getAnnotation(annotation_number))
- : createCXString((const char *) 0);
+ : cxstring::createNull();
}
CXString
@@ -222,7 +222,7 @@ clang_getCompletionParent(CXCompletionSt
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
if (!CCStr)
- return createCXString((const char *)0);
+ return cxstring::createNull();
return createCXString(CCStr->getParentContextName(), /*DupString=*/false);
}
@@ -232,7 +232,7 @@ clang_getCompletionBriefComment(CXComple
CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
if (!CCStr)
- return createCXString((const char *) NULL);
+ return cxstring::createNull();
return createCXString(CCStr->getBriefComment(), /*DupString=*/false);
}
Modified: cfe/trunk/tools/libclang/CXComment.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXComment.cpp (original)
+++ cfe/trunk/tools/libclang/CXComment.cpp Fri Feb 1 08:13:32 2013
@@ -124,7 +124,7 @@ unsigned clang_InlineContentComment_hasT
CXString clang_TextComment_getText(CXComment CXC) {
const TextComment *TC = getASTNodeAs<TextComment>(CXC);
if (!TC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(TC->getText(), /*DupString=*/ false);
}
@@ -132,7 +132,7 @@ CXString clang_TextComment_getText(CXCom
CXString clang_InlineCommandComment_getCommandName(CXComment CXC) {
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
if (!ICC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
const CommandTraits &Traits = getCommandTraits(CXC);
return createCXString(ICC->getCommandName(Traits), /*DupString=*/ false);
@@ -172,7 +172,7 @@ CXString clang_InlineCommandComment_getA
unsigned ArgIdx) {
const InlineCommandComment *ICC = getASTNodeAs<InlineCommandComment>(CXC);
if (!ICC || ArgIdx >= ICC->getNumArgs())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(ICC->getArgText(ArgIdx), /*DupString=*/ false);
}
@@ -180,7 +180,7 @@ CXString clang_InlineCommandComment_getA
CXString clang_HTMLTagComment_getTagName(CXComment CXC) {
const HTMLTagComment *HTC = getASTNodeAs<HTMLTagComment>(CXC);
if (!HTC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(HTC->getTagName(), /*DupString=*/ false);
}
@@ -204,7 +204,7 @@ unsigned clang_HTMLStartTag_getNumAttrs(
CXString clang_HTMLStartTag_getAttrName(CXComment CXC, unsigned AttrIdx) {
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
if (!HST || AttrIdx >= HST->getNumAttrs())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(HST->getAttr(AttrIdx).Name, /*DupString=*/ false);
}
@@ -212,7 +212,7 @@ CXString clang_HTMLStartTag_getAttrName(
CXString clang_HTMLStartTag_getAttrValue(CXComment CXC, unsigned AttrIdx) {
const HTMLStartTagComment *HST = getASTNodeAs<HTMLStartTagComment>(CXC);
if (!HST || AttrIdx >= HST->getNumAttrs())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(HST->getAttr(AttrIdx).Value, /*DupString=*/ false);
}
@@ -220,7 +220,7 @@ CXString clang_HTMLStartTag_getAttrValue
CXString clang_BlockCommandComment_getCommandName(CXComment CXC) {
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
if (!BCC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
const CommandTraits &Traits = getCommandTraits(CXC);
return createCXString(BCC->getCommandName(Traits), /*DupString=*/ false);
@@ -238,7 +238,7 @@ CXString clang_BlockCommandComment_getAr
unsigned ArgIdx) {
const BlockCommandComment *BCC = getASTNodeAs<BlockCommandComment>(CXC);
if (!BCC || ArgIdx >= BCC->getNumArgs())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(BCC->getArgText(ArgIdx), /*DupString=*/ false);
}
@@ -254,7 +254,7 @@ CXComment clang_BlockCommandComment_getP
CXString clang_ParamCommandComment_getParamName(CXComment CXC) {
const ParamCommandComment *PCC = getASTNodeAs<ParamCommandComment>(CXC);
if (!PCC || !PCC->hasParamName())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(PCC->getParamNameAsWritten(), /*DupString=*/ false);
}
@@ -305,7 +305,7 @@ enum CXCommentParamPassDirection clang_P
CXString clang_TParamCommandComment_getParamName(CXComment CXC) {
const TParamCommandComment *TPCC = getASTNodeAs<TParamCommandComment>(CXC);
if (!TPCC || !TPCC->hasParamName())
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(TPCC->getParamNameAsWritten(), /*DupString=*/ false);
}
@@ -338,7 +338,7 @@ CXString clang_VerbatimBlockLineComment_
const VerbatimBlockLineComment *VBL =
getASTNodeAs<VerbatimBlockLineComment>(CXC);
if (!VBL)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(VBL->getText(), /*DupString=*/ false);
}
@@ -346,7 +346,7 @@ CXString clang_VerbatimBlockLineComment_
CXString clang_VerbatimLineComment_getText(CXComment CXC) {
const VerbatimLineComment *VLC = getASTNodeAs<VerbatimLineComment>(CXC);
if (!VLC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
return createCXString(VLC->getText(), /*DupString=*/ false);
}
@@ -838,7 +838,7 @@ extern "C" {
CXString clang_HTMLTagComment_getAsString(CXComment CXC) {
const HTMLTagComment *HTC = getASTNodeAs<HTMLTagComment>(CXC);
if (!HTC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
SmallString<128> HTML;
CommentASTToHTMLConverter Converter(0, HTML, getCommandTraits(CXC));
@@ -849,7 +849,7 @@ CXString clang_HTMLTagComment_getAsStrin
CXString clang_FullComment_getAsHTML(CXComment CXC) {
const FullComment *FC = getASTNodeAs<FullComment>(CXC);
if (!FC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
SmallString<1024> HTML;
CommentASTToHTMLConverter Converter(FC, HTML, getCommandTraits(CXC));
@@ -1377,7 +1377,7 @@ extern "C" {
CXString clang_FullComment_getAsXML(CXComment CXC) {
const FullComment *FC = getASTNodeAs<FullComment>(CXC);
if (!FC)
- return createCXString((const char *) 0);
+ return cxstring::createNull();
ASTContext &Context = FC->getDeclInfo()->CurrentDecl->getASTContext();
CXTranslationUnit TU = CXC.TranslationUnit;
SourceManager &SM = cxtu::getASTUnit(TU)->getSourceManager();
Modified: cfe/trunk/tools/libclang/CXCompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCompilationDatabase.cpp?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCompilationDatabase.cpp (original)
+++ cfe/trunk/tools/libclang/CXCompilationDatabase.cpp Fri Feb 1 08:13:32 2013
@@ -107,7 +107,7 @@ CXString
clang_CompileCommand_getDirectory(CXCompileCommand CCmd)
{
if (!CCmd)
- return createCXString((const char*)NULL);
+ return cxstring::createNull();
CompileCommand *cmd = static_cast<CompileCommand *>(CCmd);
return createCXString(cmd->Directory.c_str(), /*DupString=*/false);
@@ -126,12 +126,12 @@ CXString
clang_CompileCommand_getArg(CXCompileCommand CCmd, unsigned Arg)
{
if (!CCmd)
- return createCXString((const char*)NULL);
+ return cxstring::createNull();
CompileCommand *Cmd = static_cast<CompileCommand *>(CCmd);
if (Arg >= Cmd->CommandLine.size())
- return createCXString((const char*)NULL);
+ return cxstring::createNull();
return createCXString(Cmd->CommandLine[Arg].c_str(), /*DupString=*/false);
}
Modified: cfe/trunk/tools/libclang/CXString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXString.cpp?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXString.cpp (original)
+++ cfe/trunk/tools/libclang/CXString.cpp Fri Feb 1 08:13:32 2013
@@ -29,6 +29,13 @@ enum CXStringFlag { CXS_Unmanaged, CXS_M
// Basic generation of CXStrings.
//===----------------------------------------------------------------------===//
+CXString cxstring::createNull() {
+ CXString Str;
+ Str.data = 0;
+ Str.private_flags = CXS_Unmanaged;
+ return Str;
+}
+
CXString cxstring::createCXString(const char *String, bool DupString){
CXString Str;
if (DupString) {
Modified: cfe/trunk/tools/libclang/CXString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXString.h?rev=174173&r1=174172&r2=174173&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXString.h (original)
+++ cfe/trunk/tools/libclang/CXString.h Fri Feb 1 08:13:32 2013
@@ -25,6 +25,9 @@ namespace cxstring {
struct CXStringBuf;
+/// \brief Create a CXString object for an NULL string.
+CXString createNull();
+
/// \brief Create a CXString object from a C string.
CXString createCXString(const char *String, bool DupString = false);
More information about the cfe-commits
mailing list