@@ -104,6 +104,10 @@ data DeclIndex = DeclIndex {
104104 }
105105 deriving stock (Show , Generic )
106106
107+ -- TODO_PR: Add conflicts to decl index.
108+
109+ -- TODO_PR: Succeeded, external, unusable.
110+
107111emptyIndex :: DeclIndex
108112emptyIndex =
109113 DeclIndex Map. empty Map. empty Map. empty Map. empty Map. empty Set. empty
@@ -115,6 +119,10 @@ emptyIndex =
115119-- | Construction state (internal type)
116120data PartialIndex = PartialIndex {
117121 index :: DeclIndex
122+ -- TODO_PR.
123+ -- indexDomain :: Set C.QualPrelimDeclId
124+ -- State `indexDomain = union [succeeded, notAttempted, failed]`
125+ -- conflicts :: Map C.QualPrelimDeclId (Set SingleLoc)
118126 , errors :: ! (Map C. QualPrelimDeclId DeclIndexError )
119127 }
120128 deriving (Generic )
@@ -228,17 +236,22 @@ fromParseResults results =
228236 -- for macros; for other kinds of declarations, clang will have
229237 -- reported an error already.
230238 --
231- -- TODO: there are cases where one declaration is an actual C
239+ -- There are cases where one declaration is an actual C
232240 -- construct like a variable declaration, but the new
233241 -- declaration is a macro of the same name that simply defers to
234242 -- the C construct. This is apparently a valid pattern, which
235243 -- for example occurs in @stdio.h@:
236244 --
237245 -- > typedef int FILE;
238246 -- > extern FILE *const stdin;
239- -- > #define stdin (stdin)
247+ -- > #define stdin (stdin)
240248 --
241- -- See issue #1155.
249+ -- Note that in examples like this, we will always "succeed" in
250+ -- parsing the macro, because proper macro handling does not
251+ -- happen until after the @DeclIndex@ has been built (at this
252+ -- point the macro is merely a list of tokens). So whether the
253+ -- macro is something we can handle or not is irrelevant at this
254+ -- point.
242255 failure $ Redeclaration {
243256 redeclarationId = C. declQualPrelimDeclId $ new. psDecl
244257 , redeclarationOld = old. psDecl. declInfo. declLoc
@@ -276,9 +289,12 @@ sameMacro = (==) `on` (map tokenSpelling . unparsedTokens)
276289 Construction errors
277290-------------------------------------------------------------------------------}
278291
292+ -- TODO_PR: Delete completely or define "ConflictingDeclarations ::
293+ -- (C.QualPrelimDeclId, Set. SingleLoc)" type and reuse in selection.
279294data DeclIndexError =
280295 Redeclaration {
281296 redeclarationId :: C. QualPrelimDeclId
297+ -- TODO_PR:
282298 , redeclarationOld :: SingleLoc
283299 , redeclarationNew :: SingleLoc
284300 }
@@ -289,12 +305,15 @@ data DeclIndexError =
289305
290306instance PrettyForTrace DeclIndexError where
291307 prettyForTrace = \ case
308+ -- TODO_PR:
292309 Redeclaration {.. } -> PP. hcat [
293310 prettyForTrace (C. Located redeclarationOld redeclarationId)
294311 , " was redeclared at "
295312 , PP. showToCtxDoc redeclarationNew
296313 , " . No binding generated."
297314 ]
315+ -- TODO_PR: Change wording (probably even use the same trace message
316+ -- type).
298317 SharedKey {.. } ->
299318 PP. hang " Duplicate in declaration index detected:" 2 $
300319 prettyForTrace sharedKeyParseResult
0 commit comments