[Lldb-commits] [lldb] r241651 - Fixed the C modules test case on Darwin by streamlining its code.
Sean Callanan
scallanan at apple.com
Tue Jul 7 17:13:49 PDT 2015
Author: spyffe
Date: Tue Jul 7 19:13:49 2015
New Revision: 241651
URL: http://llvm.org/viewvc/llvm-project?rev=241651&view=rev
Log:
Fixed the C modules test case on Darwin by streamlining its code.
We don't need to do the fancy dance with checking whether the iterator
represents a #define -- in fact, that's the wrong thing to do. The thing to do
is check whether the highest-priority module that did something to the module
#defined or #undefd it. If it #defined it, then the MacroInfo* will be non-NULL
and we're good to go.
Modified:
lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
lldb/trunk/test/lang/c/modules/TestCModules.py
Modified: lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp?rev=241651&r1=241650&r2=241651&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp (original)
+++ lldb/trunk/source/Expression/ClangModulesDeclVendor.cpp Tue Jul 7 19:13:49 2015
@@ -18,6 +18,7 @@
#include "lldb/Host/HostInfo.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Frontend/CompilerInstance.h"
@@ -444,18 +445,18 @@ ClangModulesDeclVendorImpl::ForEachMacro
}
ssize_t found_priority = -1;
- clang::MacroInfo *info = nullptr;
+ clang::MacroInfo *macro_info = nullptr;
- for (clang::ModuleMacro *macro : m_compiler_instance->getPreprocessor().getLeafModuleMacros(ii))
+ for (clang::ModuleMacro *module_macro : m_compiler_instance->getPreprocessor().getLeafModuleMacros(ii))
{
- clang::Module *module = macro->getOwningModule();
+ clang::Module *module = module_macro->getOwningModule();
{
ModulePriorityMap::iterator pi = module_priorities.find(reinterpret_cast<ModuleID>(module));
if (pi != module_priorities.end() && pi->second > found_priority)
{
- info = macro->getMacroInfo();
+ macro_info = module_macro->getMacroInfo();
found_priority = pi->second;
}
}
@@ -465,26 +466,20 @@ ClangModulesDeclVendorImpl::ForEachMacro
if (top_level_module != module)
{
ModulePriorityMap::iterator pi = module_priorities.find(reinterpret_cast<ModuleID>(top_level_module));
-
+
if ((pi != module_priorities.end()) && pi->second > found_priority)
{
- info = macro->getMacroInfo();
+ macro_info = module_macro->getMacroInfo();
found_priority = pi->second;
}
}
}
- if (!info)
+ if (macro_info)
{
- continue;
- }
-
- if (mi->second.getLatest()->getKind() == clang::MacroDirective::MD_Define)
- {
std::string macro_expansion = "#define ";
macro_expansion.append(mi->first->getName().str().c_str());
-
- if (clang::MacroInfo *macro_info = mi->second.getLatest()->getMacroInfo())
+
{
if (macro_info->isFunctionLike())
{
@@ -560,9 +555,7 @@ ClangModulesDeclVendorImpl::ForEachMacro
if (invalid)
{
-#ifdef LLDB_CONFIGURATION_DEBUG
- assert(!"Unhandled token kind");
-#endif
+ lldbassert(!"Unhandled token kind");
macro_expansion.append("<unknown literal value>");
}
else
@@ -594,17 +587,11 @@ ClangModulesDeclVendorImpl::ForEachMacro
}
}
}
- }
- else
- {
-#ifdef LLDB_CONFIGURATION_DEBUG
- assert(!"#define with no macro info");
-#endif
- }
-
- if (handler(macro_expansion))
- {
- return;
+
+ if (handler(macro_expansion))
+ {
+ return;
+ }
}
}
}
Modified: lldb/trunk/test/lang/c/modules/TestCModules.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/c/modules/TestCModules.py?rev=241651&r1=241650&r2=241651&view=diff
==============================================================================
--- lldb/trunk/test/lang/c/modules/TestCModules.py (original)
+++ lldb/trunk/test/lang/c/modules/TestCModules.py Tue Jul 7 19:13:49 2015
@@ -16,7 +16,6 @@ class CModulesTestCase(TestBase):
@skipUnlessDarwin
@dsym_test
- @expectedFailureDarwin # use of undeclared identifier 'MIN'
def test_expr_with_dsym(self):
self.buildDsym()
self.expr()
@@ -24,7 +23,6 @@ class CModulesTestCase(TestBase):
@dwarf_test
@skipIfFreeBSD
@expectedFailureLinux('http://llvm.org/pr23456') # 'fopen' has unknown return type
- @expectedFailureDarwin # use of undeclared identifier 'MIN'
def test_expr_with_dwarf(self):
self.buildDwarf()
self.expr()
More information about the lldb-commits
mailing list