simplify some conditionals, don't copy LangOptions.

llvm-svn: 67674
This commit is contained in:
Chris Lattner 2009-03-25 03:28:08 +00:00
parent 0e0cf39a9e
commit 8c37df4f91
1 changed files with 15 additions and 11 deletions

View File

@ -53,12 +53,15 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
const FileEntry *FE = 0; const FileEntry *FE = 0;
SourceManager &SM = M->getContext().getSourceManager(); SourceManager &SM = M->getContext().getSourceManager();
bool isMain;
if (Loc.isValid()) { if (Loc.isValid()) {
Loc = SM.getInstantiationLoc(Loc); Loc = SM.getInstantiationLoc(Loc);
FE = SM.getFileEntryForID(SM.getFileID(Loc)); FE = SM.getFileEntryForID(SM.getFileID(Loc));
isMain = SM.getFileID(Loc) == SM.getMainFileID();
} else { } else {
// If Loc is not valid then use main file id. // If Loc is not valid then use main file id.
FE = SM.getFileEntryForID(SM.getMainFileID()); FE = SM.getFileEntryForID(SM.getMainFileID());
isMain = true;
} }
// See if this compile unit has been used before. // See if this compile unit has been used before.
@ -69,19 +72,20 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) {
const char *FileName = FE ? FE->getName() : "<unknown>"; const char *FileName = FE ? FE->getName() : "<unknown>";
const char *DirName = FE ? FE->getDir()->getName() : "<unknown>"; const char *DirName = FE ? FE->getDir()->getName() : "<unknown>";
bool isMain = (FE == SM.getFileEntryForID(SM.getMainFileID())); const LangOptions &LO = M->getLangOptions();
unsigned LangTag = llvm::dwarf::DW_LANG_C89; unsigned LangTag;
if (LO.CPlusPlus) {
LangOptions LO = M->getLangOptions(); if (LO.ObjC1)
if (LO.CPlusPlus
&& (LO.ObjC1 || LO.ObjC2 || LO.ObjCNonFragileABI || LO.NeXTRuntime))
LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus; LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus;
else if (LO.CPlusPlus) else
LangTag = llvm::dwarf::DW_LANG_C_plus_plus; LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
else if (LO.ObjC1 || LO.ObjC2 || LO.ObjCNonFragileABI || LO.NeXTRuntime) } else if (LO.ObjC1) {
LangTag = llvm::dwarf::DW_LANG_ObjC; LangTag = llvm::dwarf::DW_LANG_ObjC;
else if (LO.C99) } else if (LO.C99) {
LangTag = llvm::dwarf::DW_LANG_C99; LangTag = llvm::dwarf::DW_LANG_C99;
} else {
LangTag = llvm::dwarf::DW_LANG_C89;
}
// Create new compile unit. // Create new compile unit.
// FIXME: Do not know how to get clang version yet. // FIXME: Do not know how to get clang version yet.